1

I am using the following method while scrolling android. but It doesn't always scroll to the same place, even though it's on the same page. what would be the reason.

public void ScrollToCampaignNotice(){
    try {
        getDriver().findElement(AppiumBy.androidUIAutomator(
                "new UiScrollable(new UiSelector().scrollable(true)).flingToEnd(35)"));
    } catch (InvalidSelectorException e) {
        // ignore
   

 }
    }

At the same time, I tried the following method differently, it has the same problem.

enter image description here

Onurcan
  • 31
  • 2

1 Answers1

1

You could scroll to exact element instead of flinging 35 times.

Here is an example how to scroll to specific text that is visible:

new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains("<include your text>").instance(0))

You can also scroll to an element that has specific id like this:

new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().resourceId("<insert element ID here>").instance(0))
  • Thanks for support but when i try this method works is very slow I recorded video Is there any way I can speed this up? https://drive.google.com/file/d/1MZeJIkpklV1AtqdfMTk6kOjb1y5RqLBV/view – Onurcan Jan 30 '23 at 11:53