What are the alternatives for scrollTo() and scrollToExact(), Please suggest other than (x,y) co-ordinators
// android
public boolean scroll_and_tap_byText(String text) {
try {
WebElement el = driver.findElement(MobileBy
.AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView("
+ "new UiSelector().text(\""+text+"\"));")));
// tap on it
} catch (Exception e) {
return false;
}
}
// ios
public boolean scroll_and_tap_byText(String text) { //works ONLY inside scrollView
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap scrollObject = new HashMap<>();
scrollObject.put("predicateString", "value == '" + text + "'");
js.executeScript("mobile: scroll", scrollObject);
WebElement el = ((IOSDriver) driver).findElementByIosNsPredicate("value = '" + text + "'");
// now tap on it
}
1 Like
Which platform version is the recommended one for using Uiautomator, API24 or less than that?
i tried with Android 6.0 and it was working.
1 Like
Scroll is not working with the UiAutomator code.
Click event on the drop down is working but scroll until the text is visible is not working.
Could you please check and let me know?
I think UiScrollable is deprecated in all API versions.
what to check? i have no problem with
AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView("
+ "new UiSelector().text(\""+text+"\"));")));
are you sure you using this code with Scrollable view with your app?
Its working fine. Actually i was trying for both selector and click on searched text