selene icon indicating copy to clipboard operation
selene copied to clipboard

Add helper for actions_chains

Open Vickgrego opened this issue 7 years ago • 5 comments

Hi! I cannot find actions_chains in selene. Can you point me out to it or, in case it's missing from selene, I suggest to add some helper for it.

Vickgrego avatar Aug 12 '18 18:08 Vickgrego

Hi, @Vickgrego. It seems selene still has no action_chains. I am waiting too for it. I will join the queue for you.

aleksandr-kotlyar avatar Dec 31 '18 11:12 aleksandr-kotlyar

@Vickgrego I think it will be interesting for you. I found few selene's methods which uses selenium's ActionChains

selene.core.entity.Element.double_click()
selene.core.entity.Element.context_click()
selene.core.entity.Element.hover()

image Tell please, if you need more methods, and what.

aleksandr-kotlyar avatar Mar 07 '20 02:03 aleksandr-kotlyar

Yeah... There is no object of ActionsChains class yet in Selene. You can create it quickly as a helper in your code....

Probably It is reasonable to have it in Selene API too... I will add something like browser.actions property

yashaka avatar Mar 07 '20 07:03 yashaka

#188 & #178 could be first candidates - they are about ActionChains too.

aleksandr-kotlyar avatar Mar 07 '20 10:03 aleksandr-kotlyar

So... Seems like we can't just simply add something like browser.actions

class Browser(WaitingEntity):
    # ...

    @property
    def actions(self) -> ActionChains:
        """
        It's kind of just a shortcut for pretty low level actions from selenium webdriver
        Yet unsure about this property here:)
        comparing to usual high level Selene API...
        Maybe later it would be better to make own Actions with selene-style retries, etc.
        """
        return ActionChains(self.config.driver)
# ...

because it will not be consistent with other API...

browser.actions.click(browser.element('#foobar')).perform()

will not work... I mean, if we add something to browser.*, it would be best if it can work with instances of Element class, but in case of ActionChains it will not... First we have to transform selene element to selenium webelement:

element = browser.element('#foobar')
webelement = element()
browser.actions.click(webelement).perform()

Probably best would be to create our own "dynamic retriable" version of Actions over ActionChains from Selenium Webdriver...

Unless we do that, the recommendation is to create your own actions helper;)

yashaka avatar Mar 14 '20 09:03 yashaka