WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

Element does not get scrolled into view

Open kviji opened this issue 6 years ago • 21 comments

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

kviji avatar Feb 25 '19 12:02 kviji

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?

timotiusmargo avatar Feb 26 '19 07:02 timotiusmargo

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

kviji avatar Feb 26 '19 09:02 kviji

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

timotiusmargo avatar Feb 27 '19 23:02 timotiusmargo

Hi @timotiusmargo ,

WindowsElement minuteSelector = session.FindElementByAccessibilityId("MinuteLoopingSelector");

Is this applicable only for accessibilityID?

kviji avatar Mar 01 '19 10:03 kviji

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?

kviji avatar Mar 01 '19 13:03 kviji

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?

timotiusmargo avatar Mar 06 '19 02:03 timotiusmargo

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 .

kviji avatar Mar 06 '19 05:03 kviji

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.

timotiusmargo avatar Mar 07 '19 00:03 timotiusmargo

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 avatar Mar 07 '19 10:03 kviji

@kviji,

You're welcome! Let us know how it goes 👍

timotiusmargo avatar Mar 12 '19 23:03 timotiusmargo

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?

kviji avatar Apr 12 '19 10:04 kviji

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.

timotiusmargo avatar Apr 15 '19 22:04 timotiusmargo

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.

em-lo avatar Apr 16 '19 15:04 em-lo

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.

kviji avatar Apr 19 '19 13:04 kviji

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?

timotiusmargo avatar Apr 20 '19 00:04 timotiusmargo

Hi @timotiusmargo

Any updates to this issue ?

kviji avatar Aug 13 '19 06:08 kviji

@timotiusmargo Is there any guidance on how to set the IsScrollItemPatternAvailable flag to true?

wildcat111 avatar Jan 14 '20 19:01 wildcat111

Hi @timotiusmargo!

Are there any news regarding this issue?

A few notes from my side:

  • When the ScrollItemPattern is provided (and IsOffscreen is true), 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.
  • Further, I checked the WinAppDriver API doc for the moveto endpoint, which contains outdated tests using the driver's Mouse interface, which is obsolete. Also, tests which cover this issue's case are missing.

ChristoWolf avatar Dec 21 '20 13:12 ChristoWolf

Any followup on this bug? Our development organization is in the process of transitioning from CodedUI to WinAppDriver, and this issue is significantly impeding our progress.

zannett avatar Apr 14 '22 16:04 zannett

Just wanted to check in again and see if there has been any update on the status of this issue.

zannett avatar May 20 '22 17:05 zannett

I am facing similar problem. I got menu and clicking on it shows many items with scrollbar. When I try to click on element which is at bottom, it completes click action and I dont know where it clicked and expected action is not found. In this case, if I try to check is Displayed, I get true, though technically it is not displayed in current view (If I scroll down, item will be visible else it is technically not visible). Any help?

chilakamarthi avatar Jun 16 '22 10:06 chilakamarthi