licanhua / YWinAppDriver

A open source project provides WinAppDriver compatible functionality
MIT License
49 stars 10 forks source link

Unable to Right click on Alarm Clock Element #25

Closed vjacobjo closed 2 years ago

vjacobjo commented 2 years ago

Hi,

I have attempted to use the YWinAppDriver to automate WPF applications. Similar to the WinAppDriver, I was unable to right click on elements (and I've even logged an issue here with no response: https://github.com/microsoft/WinAppDriver/issues/1677).

I've decided to try using the YWinAppDriver to overcome this issue. I am using the following versions: Appium-Python-Client==2.1.2 Selenium==4.1.0

I've attached the following python Code over here: AlarmClockTest.txt

Here are the logs that are produced as a result: WinAppDriverLog.log

I notice that when trying to right click on the element, the logs report a 404 on line 77 Response 404: 127.0.0.1:4723 /session/279196bb-d37f-4293-80c7-9953fabc984a/actions

does this mean actions has not been implemented yet?

Please advise other alternatives to how I can go about implementing right clicking with the versions of Appium-Python-Client and Selenium provided.

licanhua commented 2 years ago

Thanks. you are hit endpoints: session/279196bb-d37f-4293-80c7-9953fabc984a/actions with parameters

      {"actions": [{"type": "pointer", "parameters": {"pointerType": "pen"}, "id": "mouse", "actions": [{"type": "pointerMove", "duration": 250, "x": 396, "y": 210, "origin": "viewport"}, {"type": "pointerDown", "duration": 0, "button": 2}, {"type": "pointerUp", "duration": 0, "button": 2}]}]}`

and this endpoint is not implemented yet.

Likely it already have right click(RIGHT = 2) in the code base, image

There are two possible solutions:

  1. add the actions endpoint into the codebase to support actions above.
  2. make the client send out click with additional parameters "button":"2" POST Request: 127.0.0.1:4723 /session/279196bb-d37f-4293-80c7-9953fabc984a/element/42.2428328.4.5/click {"id": "42.2428328.4.5", "button":"2"}
licanhua commented 2 years ago

The 2nd solution should already supported because it's defined in [json wire protocol] (https://www.selenium.dev/documentation/legacy/json_wire_protocol/#sessionsessionidclick) by some client image

vjacobjo commented 2 years ago

Thank you so much for the quick response :)

I don't think we can extend the Appium-Python-Client to provide additional parameters based on the documentation: http://appium.io/docs/en/commands/element/actions/click/ https://github.com/SeleniumHQ/selenium/blob/676c4cc8bbb0c113e5218e824df1fbd5d4a02a7d/py/selenium/webdriver/remote/webelement.py#L79

Even when right-clicking worked in version 1.3.0 (Selenium 3~), the right click was executed via action chain. In my python code , lines 42-43 demonstrate the code that used to work in the old version.

I could log a bug on Appium-Python-Client's end to provide this functionality, but if we were to take matters into our own hands, I think the 1st solution where we implement the actions endpoint seems to be the only way.

vjacobjo commented 2 years ago

Dug a little deeper into the issue. So the click functionality from the client side is implemented in Selenium. Someone else already asked about potentially adding the ability to extend click to specifying mouse button: https://github.com/SeleniumHQ/selenium/issues/8654

This issue was posted two years ago. Nevertheless, I did log an issue in the W3C github repo: https://github.com/w3c/webdriver/issues/1647

It would be starting to look like going for option 2 would require a lot of hands to implement.

Is there anything on my end I could do?

licanhua commented 2 years ago

You may choose C# for right click test cases. WinAppDriver has good support with C#, and possible Java.

If you stick with Appium-Python-Client, you may implement Actions endpoint based on YWinAppDriver. Of course, new PRs are welcome.

Some selenium clients allow user to send the raw data, but I don't know if Appium-Python-Client allows you to do it or not.

I didn't have other solutions in mind.