Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] Add methods clear for actions #100

Closed
wants to merge 2 commits into from
Closed

[Python] Add methods clear for actions #100

wants to merge 2 commits into from

Conversation

bayandin
Copy link
Contributor

Added method clear for ActionChains and TouchActions to clear stored actions. It does not break backward compatibility and design.
As a continuation of issues #99.

CLA signed as Alexander Bayandin

@shs96c
Copy link
Member

shs96c commented Jul 28, 2013

Why not just create a new instance of the ActionChains? After all, a cleared instance is an empty instance.

@bayandin
Copy link
Contributor Author

In my opinion, it is better to reuse than to create each time a new instance of the object.

For example:

ActionChains(driver).some_chain_of_actions(elements).perform()
ActionChains(driver).some_other_chain_of_actions(elements).perform()
ActionChains(driver).and_some_other_chain_of_actions(elements).perform()

VS

chain = ActionChains(driver)

chain.some_chain_of_actions(elements).perform().clear()
chain.some_other_chain_of_actions(elements).perform().clear()
chain.and_some_other_chain_of_actions(elements).perform()

And store actions after performing is a unpredictable result for some situations (see #99).

@barancev
Copy link
Member

Wha't the principal difference between a "cleaned" instance and a new one?

@bayandin
Copy link
Contributor Author

There is no difference except the small overhead of creating an object.

@barancev
Copy link
Member

This is an excessive optimization that does not worth adding a new method to the API.

@barancev barancev closed this Jul 29, 2013
@bayandin bayandin deleted the clear-for-action-chains branch July 30, 2013 02:23
@richardmodis
Copy link

It's a pity that this implementation wasn't accepted. For instance, I use ActionChains a lot of time, and I could create much more readable (and shorter) code by reusing the instance.

@andreastt
Copy link
Member

We'd like to actively encourage people to build optimizations like this on top of the WebDriver libraries, though. As you say it could allow for more readable and less verbose code, but in the eyes of WebDriver it bloats the API for very little benefit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants