inconsistent scroll simulation
See original GitHub issueDescription
When using the following code, each time the scroll goes roughly to the same place but not exactly, and there is no way to know exactly how much the element was scrolled:
private void scrollTo(int startX, int startY, int endX, int endY) {
PointerInput finger = new PointerInput(PointerInput.Kind.TOUCH, "finger");
Sequence scrollAction = new Sequence(finger, 0);
scrollAction.addAction(finger.createPointerMove(Duration.ofMillis(0), PointerInput.Origin.viewport(), startX, startY));
scrollAction.addAction(finger.createPointerDown(PointerInput.MouseButton.LEFT.asArg()));
scrollAction.addAction(finger.createPointerMove(Duration.ofMillis(500), PointerInput.Origin.viewport(), endX, endY));
// repeat last action as if to make the finger stay in place for 500 ms
scrollAction.addAction(finger.createPointerMove(Duration.ofMillis(500), PointerInput.Origin.viewport(), endX, endY));
scrollAction.addAction(finger.createPointerUp(PointerInput.MouseButton.LEFT.asArg()));
}
scrollTo(540, 1579, 540, 172);
On BrowserStack I see the correct request arrives:
[{"id":"finger","type":"pointer","parameters":{"pointerType":"touch"},"actions":[{"duration":0,"x":540,"y":1579,"type":"pointerMove","origin":"viewport"},{"button":0,"type":"pointerDown"},{"duration":500,"x":540,"y":172,"type":"pointerMove","origin":"viewport"},{"duration":500,"x":540,"y":172,"type":"pointerMove","origin":"viewport"},{"button":0,"type":"pointerUp"}]}]
but still each time I run that code on a fresh instance I get a bit different result.
Environment
- Appium version 1.21.0 (on BrowserStack)
- Android version 9.0, Google Pixel 2, UiAutomator2
Details
Please provide more details, if necessary.
Link To Appium Logs
https://gist.github.com/itaibh/d8028aa2f13ce3d16e15194101e9327e
In the Appium logs you’ll see I use the Cancel action, but the result is the same as with lifting the finger.
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (5 by maintainers)
Top Results From Across the Web
Scrolling with pleasure - Pavel Fatin
Moreover, because of the lacking application-level support, this presumably unified scrolling can still be very inconsistent in practice.
Read more >Mouse scroll wheel should target focus or hover?
I've noticed an inconsistency with controls responding to scroll input. Different OSs (and even different programs within the same OS) behave ...
Read more >Open simulator xcode 14 by Rosetta to fix scroll - Stack Overflow
I just updated to xcode 14, and it seems the simulator can't run with Rosetta to fix scroll lag. Does anyone have a...
Read more >Microsoft Mouse inconsistent behavior of scroll wheel and button
Microsoft Comfort Optical Mouse 3000 is a wired, USB mouse connected to an ASUS MB w/Intel Quad-Core system running 32 bit Windows 7....
Read more >Inconsistent results are displayed when embedding an iFRAME link ...
When using Chrome and an iFRAME link to a custom Java page, there is a scroll bar to resize the window that you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would say this behaviour is expected. Basically, what this code is doing, it emulates user touches. And usually these are not 100% precise, because they have some inertia. You could also try
mobile:
gestures to see if that helps. These are basically shortcuts to actions, just refined by Google and supplied with optimal parameters for each particular gesture type: https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/android-mobile-gestures.mdIt didn’t get to the server, the exception was thrown from the Java upon calling the
execute
command. The server is BrowserStack. The Java bindings are 8.0.0-beta.