selenium icon indicating copy to clipboard operation
selenium copied to clipboard

[🚀 Feature]: Allow overriding default Actions duration

Open titusfortner opened this issue 1 year ago • 7 comments

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();

titusfortner avatar May 31 '23 03:05 titusfortner

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

NCLnclNCL avatar Dec 08 '23 15:12 NCLnclNCL

Yes, this can be adjusted everywhere except for Java now.

titusfortner avatar Dec 08 '23 15:12 titusfortner

This issue is looking for contributors.

Please comment below or reach out to us through our IRC/Slack/Matrix channels if you are interested.

github-actions[bot] avatar Dec 31 '23 18:12 github-actions[bot]

@titusfortner I am a newbie to open source contributions, are you fine, if I start working on this issue?

arefbehboudi avatar Mar 30 '24 07:03 arefbehboudi

@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 ?

iampopovich avatar Jun 05 '24 17:06 iampopovich

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

titusfortner avatar Jun 05 '24 17:06 titusfortner

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?

iampopovich avatar Jun 05 '24 17:06 iampopovich

#14085 is merged could this issue be closed @titusfortner ?

iampopovich avatar Jul 29 '24 13:07 iampopovich

Good call, thank you, @iampopovich!

diemol avatar Jul 29 '24 13:07 diemol

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.

github-actions[bot] avatar Aug 28 '24 22:08 github-actions[bot]