Scrolling not working due wrong element location


#1

Hi,

I have a list of buttons inside a View, some of these elements are visible on screen when the page loads, the others needs to scroll to be on screen. My problem is I can find the element, but I can’t scroll to it.

I’ve already tried to scroll using MobilyBy.AndroidUIAutomator, but it tries to scroll and gives an error. I think it happens because the elements that are off screen have a ‘wrong’ location, all of them shows the same Y coordinate, something like 1092 depends on the device. So, they are not showing the correct location. When I manually scroll, or use swipe to scroll, the elements that were off screen before still with the same location.

I also tried to use a swipe to scroll, but as the locations aren’t correct It’s impossible to scroll to element and click on correct button.

At this moment I’m trying this:
driver.findElement(MobileBy.AndroidUIAutomator(“new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().descriptionContains(”"+TextToFind+"").instance(0))"));

already tried:

driver.findElement(MobileBy.AndroidUIAutomator(“new UiScrollable(new UiSelector().className(“android.view.View”)).scrollIntoView(new UiSelector().descriptionContains(”"+TextToFind+"").instance(0))"));

AND

driver.findElement(MobileBy.AndroidUIAutomator(
“new UiScrollable(new UiSelector().text(“myseats”)).getChildByText(”
+ “new UiSelector().className(“android.widget.Button”), “”+TextToFind+”")"));

Environment
Appium 1.7.2
Java client 6.0.0 - Beta 2
Android real device with Android 6.0.1
Also tried on Android 7.0
UiAutomator 2

Thank you All!


#2

Did you manage to understand the problem? I think I’m also having an issue with wrong locations