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

[py] Rounded pause duration #6300

Merged
merged 5 commits into from Aug 21, 2018
Merged

[py] Rounded pause duration #6300

merged 5 commits into from Aug 21, 2018

Conversation

Dakkaron
Copy link
Contributor

WebDriver standard expects "duration" parameter of "pause" action to be integer. ChromeDriver does not care, but GeckoDriver is very strict on this. See mozilla/geckodriver#1355

WebDriver standard expects "duration" parameter of "pause" action to be integer. ChromeDriver does not care, but GeckoDriver is very strict on this. See mozilla/geckodriver#1355
In Python2 round returns a float
@cgoldberg
Copy link
Contributor

@Dakkaron
Do you have a good reason for why this should be changed?

currently, passing a non-integer will raise a InvalidArgumentException with a clear message that 'duration' was not a positive integer.

Following the principles of "exclicit is better than implicit" and "errors should never pass silently", I feel like that behavior is more correct than implicitly rounding duration to an integer.

@Dakkaron
Copy link
Contributor Author

In Selenium for Python the pause action takes seconds as parameter, while the WebDriver protocol takes milliseconds. To convert that, the Selenium for Python implementation multiplies the input by 1000.

If you want to wait for fractions of seconds, this is currently not possible (as laid out in the linked thread), because what happens there is you pass 0.5 seconds, these get multiplied to 500.0 milliseconds. The problem here is that when you multiply an integer by a float you get a float, not an integer, so this raises said exception.

There is no way to pass fractions of a second as an integer second value.

The ChromeDriver is very lax on the standard and allows floats there, but GeckoDriver is very strict and forbids floats here.

Because of this, it is absolutely necessary to allow floats and cast them to int, except you want to rework Selenium so that pause takes milliseconds (as the WebDriver protocol do), which would break existing tests.

@Dakkaron
Copy link
Contributor Author

This problem also has been reported here #6295.

@lmtierney
Copy link
Member

@Dakkaron thanks for the explanation. We definitely want to allow fractions of a second. I don't think we need the round() but am indifferent on it. The difference would be half a millisecond

@Dakkaron
Copy link
Contributor Author

@lmtierney Thanks for the answer. Should I remove the round()?

@lmtierney
Copy link
Member

lmtierney commented Aug 21, 2018

@Dakkaron yeah go ahead and remove the round and I'll get it merged

@Dakkaron
Copy link
Contributor Author

@lmtierney Did it, can be merged now. Thank you!

@lmtierney lmtierney merged commit 3b5e720 into SeleniumHQ:master Aug 21, 2018
@lmtierney
Copy link
Member

Merged, thank you for your contribution!

@Dakkaron
Copy link
Contributor Author

Thank you!

grigaman pushed a commit to grigaman/selenium that referenced this pull request Sep 20, 2018
When specifying a fraction of a second, the multiplication of 1000 causes a float value to be sent to the endpoint which causes an error
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

3 participants