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]: Consolidate Actions class features #10724

Closed
titusfortner opened this issue Jun 1, 2022 · 5 comments
Closed

[🚀 Feature]: Consolidate Actions class features #10724

titusfortner opened this issue Jun 1, 2022 · 5 comments

Comments

@titusfortner
Copy link
Member

titusfortner commented Jun 1, 2022

Dependencies

Feature and motivation

Did a comparative analysis of Actions class functionality between languages:
https://www.selenium.dev/documentation/webdriver/actions_api/

Differences of note

  • Python & Ruby can change default durations for scrolling & movement; Java & .NET can't
  • Python & Ruby have a "move to Location" method, Java & .NET don't
  • I just added support for Python & Ruby to specify what button to click on click and hold, release and click methods; Java & .NET don't have this
  • I added support for Java to & Ruby to set an "active" pointer (e.g. use a pen with Actions instead of needing ActionBuilder) Python & .NET can't do this
  • Pointer Event Properties require the Action Builder approach in Java/Python/.NET;
  • Java requires using Sequences instead of having a single ActionBuilder class like Python & .NET

Proposal 1: Allow setting default pointer in Python & .NET

This saves the step of needing to define the action and add to the input and then perform.
Note: this example is Python, I haven't looked to see how difficult in .NET

pen = ActionChains(driver)\
    .set_pointer(PointerInput(POINTER_PEN, "default pen"))\
    .move_to(element)\
    .perform()

Proposal 2: Move to Location method in Java & .NET

Adds one method to Actions class
Currently no option for moving based on Viewport origin, only Element origin
The parameter could be x, y integers or a single Coordinate/Point object instance

new Actions(driver)
        .moveToLocation(100, 200)
        .perform()

Proposal 3: Allow changing of default duration in Java & .NET (tracking in #12118)

Adds one constructor to Actions class
Appium wants a default of 50ms instead of 250ms
Putting it in Actions constructor is much lower impact than adding the parameter to each method
Discuss with Appium Devs First

new Actions(driver, Duration.ofMillis(50))
        .moveByOffset(13, 15)
        .perform();

Proposal 4: Provide a better way to perform action sequences in Java

The Collections.singletonList requirement just feels clunky and unintuitive to me.
It is extra overhead, and might be worth waiting to implement until after we do #10808 since that's where we're going to want to add multiple sequences.

instead of:

((RemoteWebDriver) driver).perform(Collections.singletonList(actions));

Wrap it with this:

new ActionsBuilder(driver)
  .addSequence(actions)
  .perform();

Proposal 5: Allow PointerEvents to be used with Actions Convenience class

This would be lots more methods, and since PointerEvents are mostly not useful at this point, I don't think we should do this one

PointerInput.PointerEventProperties eventProperties = PointerInput.eventProperties()
        .setTiltX(-72)
        .setTiltY(9)
        .setTwist(86);
new Actions(driver)
        .setActivePointer(PointerInput.Kind.PEN, "default pen")
        .moveToElement(pointerArea)
        .clickAndHold()
        .moveByOffset(2, 2, eventProperties)
        .release()
        .perform();

Proposal 6: Specify Buttons

Add parameter for which button to click to clickAndHold(), release(), and click() (Java & .NET)
Adds three methods to Actions class (which is a lot, so probably we shouldn't do this one)
Note: this one is probably not worth it because the use cases are not that interesting.

new Actions(driver)
  .click(PointerInput.MouseButton.BACK)
  .perform();
@alaahong
Copy link
Member

alaahong commented Aug 4, 2022

Just wonder if how to draw a picture based on above features? e.g. drive the Pointer to do the signature on webpage.

@titusfortner
Copy link
Member Author

@alaahong You could do it with a combination of "move by offset from viewport" (or element), "click and hold," "move by offset from current pointer location," and "release," though likely it's more trouble than it's worth?

https://www.selenium.dev/documentation/webdriver/actions_api/mouse/

@titusfortner
Copy link
Member Author

It was agreed in TLC meeting from Aug 17 to implement proposals 1 & 2

@titusfortner titusfortner self-assigned this Sep 14, 2022
@titusfortner titusfortner added this to the 4.6 milestone Sep 26, 2022
@titusfortner titusfortner modified the milestones: 4.6, 4.7 Oct 14, 2022
@titusfortner titusfortner modified the milestones: 4.7, 4.8 Nov 23, 2022
@titusfortner titusfortner modified the milestones: 4.8, 4.9 Jan 3, 2023
pujagani added a commit to pujagani/selenium that referenced this issue Jan 4, 2023
pujagani added a commit to pujagani/selenium that referenced this issue Jan 5, 2023
pujagani added a commit to pujagani/selenium that referenced this issue Jan 6, 2023
pujagani added a commit to pujagani/selenium that referenced this issue Jan 31, 2023
@diemol diemol modified the milestones: 4.9, 4.10 Apr 17, 2023
titusfortner pushed a commit to pujagani/selenium that referenced this issue May 31, 2023
@titusfortner titusfortner modified the milestones: 4.10, 4.11 Jun 6, 2023
titusfortner pushed a commit to pujagani/selenium that referenced this issue Jul 10, 2023
titusfortner pushed a commit to pujagani/selenium that referenced this issue Jul 11, 2023
titusfortner pushed a commit to pujagani/selenium that referenced this issue Jul 11, 2023
titusfortner pushed a commit to pujagani/selenium that referenced this issue Jul 11, 2023
titusfortner pushed a commit that referenced this issue Jul 12, 2023
…ut device (#11513)

* [dotnet] Allow setting a different pointer, keyboard, or pointer on input device

Related to #10724
titusfortner added a commit that referenced this issue Jul 12, 2023
* [java] Add move to location method to Actions

Related to #10724

* [dotnet] Add move to location method to Actions class

* [java] only support one implementation of moveToLocation pointer action

Co-authored-by: titusfortner <titus.fortner@gmail.com>
@titusfortner
Copy link
Member Author

Ok, finally closing out this issue since we've implemented everything we said we would.

Copy link

github-actions bot commented Dec 9, 2023

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants