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

[🚀 Feature]: Allow overriding default Actions duration #12118

Closed
titusfortner opened this issue May 31, 2023 · 10 comments
Closed

[🚀 Feature]: Allow overriding default Actions duration #12118

titusfortner opened this issue May 31, 2023 · 10 comments
Labels
C-java help wanted Issues looking for contributions I-enhancement

Comments

@titusfortner
Copy link
Member

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 titusfortner changed the title [🚀 Feature]: Change default Actions duration [🚀 Feature]: Allow overriding default Actions duration May 31, 2023
@NCLnclNCL
Copy link

NCLnclNCL commented Dec 8, 2023

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

@titusfortner
Copy link
Member Author

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

@titusfortner titusfortner added the help wanted Issues looking for contributions label Dec 31, 2023
Copy link

This issue is looking for contributors.

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

@arefbehboudi
Copy link

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

@iampopovich
Copy link
Contributor

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

@titusfortner
Copy link
Member Author

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

@iampopovich
Copy link
Contributor

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
Copy link
Contributor

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

@diemol
Copy link
Member

diemol commented Jul 29, 2024

Good call, thank you, @iampopovich!

@diemol diemol closed this as completed Jul 29, 2024
Copy link

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 github-actions bot locked and limited conversation to collaborators Aug 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C-java help wanted Issues looking for contributions I-enhancement
Projects
None yet
Development

No branches or pull requests

5 participants