Using Appium2.0 and UiAutomator2 3.0.1 Running code

By locator = AppiumBy.androidUiAutomator("new UiScrollable(new UiSelector().scrollable(true)).scrollIntoView(new UiSelector().resourceId(\"elementId\"))");
return driver.findElement(locator);

While running this command and looking at the screen, driver scrolls to element in question (somewhere in the middle of total screen scrolling), and stops like it found the element and then reports NoSuchElementException.

I solved the problem by using try catch block but I don't like it. Takes more time and is not pretty solution.

By locator = AppiumBy.androidUiAutomator("new UiScrollable(new UiSelector().scrollable(true)).scrollIntoView(new UiSelector().resourceId(\"elementId\"))");
try {
   return driver.findElement(locator);
} catch (NoSuchElementException e) {
   return driver.findElement(locator);
}

With this code, I get the element in question. Is there something I missed, any update, capability, appium setting that could make finding element possible without double call

0

There are 0 best solutions below