Scroll to element Not working properly


#1

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 !!


#2

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


#3

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.


#4

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))")


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

Try this syntax.


#6

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


#7

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


#8

i have the same probleme


#9

Hi, i try to do it but its still not working :frowning:


#10

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 !!


#11

What is this? Can you briefly explain please?


#12

no more suggestion to use UiScrollable


#13

Its only my class name that have all elements id :slight_smile: