This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
1 / 13
Apr 2018

Hi,In Appium (Android) I’m using this line to scroll to element in the APP Screen :

driver.findElementByAndroidUIAutomator(“new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().resourceId(”" + elementID + “”).textContains(""+elementText+"").instance(0))");

the problem is that It’s unstable, sometimes it scroll down to the element and sometimes it starts to scroll and stops in the middle (it’s a long screen of settings and my element is at the end) And does not continue below to the element.

Does anyone have any idea what the problem is and how can it be overcome? It kind of frustrates me

Thanks !!

I have the same probleme since i put in capabilities “uiautomator2”.
before updating appium, it worked.

Hi, can you please remove elementID and just try searching through text? In my case it is working fine with Android 7, UIAutomato2, Appium 1.7.2.

for me i haven t elementID and it doesn t work :
appium.find_element_by_android_uiautomator(“new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains”"("" + languages[i] + “”).instance(0))")

new UiScrollable(new UiSelector().scrollable(true).instance(0))"
					+ ".scrollIntoView(new UiSelector().textContains(\""+your text+"\").instance(0))

Try this syntax.

i don t know where is your difference, i have the same syntax. and your syntax doesn t work

Ok, can you just put static text instead of languages[i] and verify?

o.k … I found a code that someone wrote that helps me :slight_smile:

public void scroll() {
Dimension dimensions = driver.manage().window().getSize();
int Startpoint = (int) (dimensions.getHeight() * 0.5);
int scrollEnd = (int) (dimensions.getHeight() * 0.2);
driver.swipe(200, Startpoint,200,scrollEnd,2000);
}

And the call to the function :slight_smile:

while(!telemessage.general.uiObject.elementByTextContains(element).exist()){
scroll();
Thread.sleep(500); // wait 1 sec
}

I do not go straight to the element but drop every few pixels until it reaches my element (with a loop) it works great!

I do not remember which site I found this but it’s not my code :slight_smile:

Thank you all !!

What is this? Can you briefly explain please?