selenium
selenium copied to clipboard
[🚀 Feature]: Allow overriding default Actions duration
Feature and motivation
Add a constructor to Actions class to adjust duration. For reference, Appium prefers 50ms to the default 250ms Putting it in Actions constructor is much lower impact than adding the parameter to each method.
This applies to .NET & Java as other bindings allow changing it.
(I'm splitting this out from #10724 so we can close that one)
Usage example
new Actions(driver, Duration.ofMillis(50))
.moveByOffset(13, 15)
.perform();
Feature and motivation
Add a constructor to Actions class to adjust duration. For reference, Appium prefers 50ms to the default 250ms Putting it in Actions constructor is much lower impact than adding the parameter to each method.
This applies to .NET & Java as other bindings allow changing it.
(I'm splitting this out from #10724 so we can close that one)
Usage example
new Actions(driver, Duration.ofMillis(50)) .moveByOffset(13, 15) .perform();
i see python can change in init , it like class c# and I think it's been around for quite a while https://github.com/SeleniumHQ/selenium/blob/ae655baf5086ccf25eaa840eff4038c4bd79014b/py/selenium/webdriver/common/action_chains.py#L71C1-L71C1
Yes, this can be adjusted everywhere except for Java now.
This issue is looking for contributors.
Please comment below or reach out to us through our IRC/Slack/Matrix channels if you are interested.
@titusfortner I am a newbie to open source contributions, are you fine, if I start working on this issue?
@titusfortner please check the changes n pull request above I have questions about implementation:
- shall we add a default duration like this
private Duration actionDuration;
public Actions(WebDriver driver) {
this.driver = Require.nonNull("Driver", driver);
this.actionDuration = Duration.ofMillis(250);
}
public Actions(WebDriver driver, Duration duration) {
this.driver = Require.nonNull("Driver", driver);
this.actionDuration = duration;
}
- what shall we do with hardcoded durations in Actions class ? examples below
public Actions scrollToElement(WebElement element) {
WheelInput.ScrollOrigin scrollOrigin = WheelInput.ScrollOrigin.fromElement(element);
return tick(getActiveWheel().createScroll(0, 0, 0, 0, Duration.ofMillis(250), scrollOrigin));
}
public Actions scrollByAmount(int deltaX, int deltaY) {
WheelInput.ScrollOrigin scrollOrigin = WheelInput.ScrollOrigin.fromViewport();
return tick(
getActiveWheel().createScroll(0, 0, deltaX, deltaY, Duration.ofMillis(250), scrollOrigin));
}
- shall we use this.actionDuration instead of the harcoded durations ?
I haven't looked at this code in quite a while, but I suspect it will be similar in approach to what @nvborisenko did here: https://github.com/SeleniumHQ/selenium/pull/13229/files
Thank you for the code example. I made similar changes in the Actions class. However, I'm still unclear why some waits with a duration of 250ms are replaced with a class property, while others are not. Would it be correct to replace all 250ms waits with waits from a class property and let the tests run? If all the tests pass, would this guarantee that the custom waits are working as expected?
#14085 is merged could this issue be closed @titusfortner ?
Good call, thank you, @iampopovich!
This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.