I am trying to moveTo an element using the following code
Actions action = new Actions(driver);
action.moveToElement(driver.findElement(By.name("Troubleshooting")));
action.perform();
The test has passed but the element is not scrolled into view. Also , when I perform a click, it gets clicked at the point without scrolling so the element that I desire is not getting clicked.
Any help is much appreciated.
Thanks
Viji
Hi @kviji,
From the code snippet, it is not obvious what language binding you are using for your script. Would you please include the log from the WinAppDriver.exe console when the commands above are executed?
Hi @timotiusmargo
I have used Java with Appium.
Please find the logs from Appium below
[MJSONWP (299f797e)] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Matched '/wd/hub/session/299f797e-d755-44b7-aa5e-03e045157e2e/element' to command name 'findElement'
[JSONWP Proxy] Proxying [POST /wd/hub/session/299f797e-d755-44b7-aa5e-03e045157e2e/element] to [POST http://127.0.0.1:4724/wd/hub/session/BC6782AE-8990-4C9A-9573-46532A27CB28/element] with body: {"using":"name","value":"Troubleshooting"}
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT] ==========================================
[WinAppDriver] [STDOUT] POST /wd/hub/session/BC6782AE-8990-4C9A-9573-46532A27CB28/element HTTP/1.1
[WinAppDriver] [STDOUT] Accept: application/json, /
[WinAppDriver] [STDOUT] Connection: close
[WinAppDriver] [STDOUT] Content-Length: 42
[WinAppDriver] [STDOUT] Content-Type: application/json; charset=utf-8
[WinAppDriver] [STDOUT] Host: 127.0.0.1:4724
[WinAppDriver] [STDOUT] User-Agent: appium
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT] {"using":"name","value":"Troubleshooting"}
[WinAppDriver] [STDOUT] HTTP/1.1 200 OK
[WinAppDriver] [STDOUT] Content-Length: 101
[WinAppDriver] [STDOUT] Content-Type: application/json
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT] {"sessionId":"BC6782AE-8990-4C9A-9573-46532A27CB28","status":0,"value":{"ELEMENT":"7.9988.38535158"}}
[JSONWP Proxy] Got response with status 200: {"sessionId":"BC6782AE-8990-4C9A-9573-46532A27CB28","status":0,"value":{"ELEMENT":"7.9988.38535158"}}
[JSONWP Proxy] Replacing sessionId BC6782AE-8990-4C9A-9573-46532A27CB28 with 299f797e-d755-44b7-aa5e-03e045157e2e
[HTTP] <-- POST /wd/hub/session/299f797e-d755-44b7-aa5e-03e045157e2e/element 200 485 ms - 101
[HTTP]
[HTTP] --> POST /wd/hub/session/299f797e-d755-44b7-aa5e-03e045157e2e/moveto
[HTTP] {"element":"7.9988.38535158"}
[MJSONWP (299f797e)] Driver proxy active, passing request on via HTTP proxy
[JSONWP Proxy] Matched '/wd/hub/session/299f797e-d755-44b7-aa5e-03e045157e2e/moveto' to command name 'moveTo'
[JSONWP Proxy] Proxying [POST /wd/hub/session/299f797e-d755-44b7-aa5e-03e045157e2e/moveto] to [POST http://127.0.0.1:4724/wd/hub/session/BC6782AE-8990-4C9A-9573-46532A27CB28/moveto] with body: {"element":"7.9988.38535158"}
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT] ==========================================
[WinAppDriver] [STDOUT] POST /wd/hub/session/BC6782AE-8990-4C9A-9573-46532A27CB28/moveto HTTP/1.1
[WinAppDriver] [STDOUT] Accept: application/json, /
[WinAppDriver] [STDOUT] Connection: close
[WinAppDriver] [STDOUT] Content-Length: 29
[WinAppDriver] [STDOUT] Content-Type: application/json; charset=utf-8
[WinAppDriver] [STDOUT] Host: 127.0.0.1:4724
[WinAppDriver] [STDOUT] User-Agent: appium
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT] {"element":"7.9988.38535158"}
[WinAppDriver] [STDOUT] HTTP/1.1 200 OK
[WinAppDriver] [STDOUT] Content-Length: 63
[WinAppDriver] [STDOUT] Content-Type: application/json
[WinAppDriver] [STDOUT]
[WinAppDriver] [STDOUT] {"sessionId":"BC6782AE-8990-4C9A-9573-46532A27CB28","status":0}
[JSONWP Proxy] Got response with status 200: {"sessionId":"BC6782AE-8990-4C9A-9573-46532A27CB28","status":0}
[JSONWP Proxy] Replacing sessionId BC6782AE-8990-4C9A-9573-46532A27CB28 with 299f797e-d755-44b7-aa5e-03e045157e2e
[HTTP] <-- POST /wd/hub/session/299f797e-d755-44b7-aa5e-03e045157e2e/moveto 200 40 ms - 63
Hi @kviji,
Thank you for providing the information. The moveto command endpoint is indeed defective as it doesn't scroll the element to view as specified in the JSON wire protocol.
For the time being, can you please try using a basic ElementClick as shown below?
https://github.com/Microsoft/WinAppDriver/blob/v1.1/Tests/WebDriverAPI/ElementClick.cs#L49
Hi @timotiusmargo ,
WindowsElement minuteSelector = session.FindElementByAccessibilityId("MinuteLoopingSelector");
Is this applicable only for accessibilityID?
Hi @timotiusmargo ,
I figured out that the element that I was trying to access had an automation ID and wrote the following code
driver.findElementByAccessibilityId("TroubleShootingTogBtn").click();
Still, the place only is getting clicked and it is not getting scrolled into view as well. Even if it gets clicked implicitly, I would be fine.
Am i missing something?
Hi @kviji,
When you issue an ElementClick, it will attempt to scroll the element into view if it supports ScrollItemPattern just like the minute selector item of Alarms & Clock application. Would you use inspect tool to verify that the element you located indeed has IsScrollItemPatternAvailable attribute set to true?
Hi @timotiusmargo ,
I inspected and it has been set to _false_.
Is _IsScrollItemPatternAvailable_ something that has to be set to true for each element from the development side?
Also, I had a check with Alarms application and the minute selector there seems to be like a date picker. The element that I am trying to click is not associated like a date picker or minute selector but it is one of the elements in my page .
Hi @kviji,
Yes IsScrollItemPatternAvailable has to be set to true for WinAppDriver to implicitly scroll it into view. Beside Alarms & Clock application, you can also see how Microsoft Edge set the property of each element within its scrollable view to true.
Hi @timotiusmargo ,
I have asked my development team to set the property to true and provide me a build.
I will try this out in that and update my status.
Thanks for the support
@kviji,
You're welcome! Let us know how it goes 馃憤
Hi @timotiusmargo
When i send keys for Edittextbox with accessibility ID, it gets implicitly scrolled and the keys are sent to the field. But the same does not happen to Combo box. Any reason?
Also , can you please help how to set the IsScrollItemPatternAvailable to true?
Hi @kviji,
If the Combo box element you mention has the IsScrollItemPatternAvailable set to true it should be implicitly scrolled into view and receive the actions. You may want to consult the UI framework documentation to properly enable UIA pattern above.
Another thing to look out for is the IsOffscreen property of your control element. Unless it is reported as true, WinAppDriver will not attempt to scroll to the element.
Hi @em-lo ,
Thanks for the reply. I will try to see if this works by setting it to true.
Please share docs about how to set the element to true if possible.
@timotiusmargo , Is the moveTo element bug tracked somewhere? Since this issue has been closed, just wanted to confirm.
Hi @kviji.
You are totally right. The original issue was about moveTo API endpoint that does not implicitly move scrollable item into view. I got confused by other unrelated issues that were added into this thread afterwards which led me to think that this is resolved. I'm reopening the bug.
To avoid further confusion, would you please bring other discussion unrelated to moveTo endpoint to a different issue?
Hi @timotiusmargo
Any updates to this issue ?
@timotiusmargo Is there any guidance on how to set the IsScrollItemPatternAvailable flag to true?
Hi @timotiusmargo!
Are there any news regarding this issue?
A few notes from my side:
Click automatically scrolls the item into view. However (as per this issue), this is not true for the MoveToElement method, although the official (Appium) specification requires this.