gilb
April 12, 2018, 7:17am
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 !!
langme
April 13, 2018, 8:54am
2
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.
langme
April 13, 2018, 10:08am
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))")
new UiScrollable(new UiSelector().scrollable(true).instance(0))"
+ ".scrollIntoView(new UiSelector().textContains(\""+your text+"\").instance(0))
Try this syntax.
langme
April 13, 2018, 12:21pm
6
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?
gilb
April 15, 2018, 4:57am
9
Hi, i try to do it but its still not working
gilb
April 15, 2018, 5:01am
10
o.k … I found a code that someone wrote that helps me
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
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
Thank you all !!
What is this? Can you briefly explain please?
langme
April 18, 2018, 8:18am
12
no more suggestion to use UiScrollable
gilb
April 18, 2018, 8:30am
13
Its only my class name that have all elements id