I am trying to find certain cards or tiles in an Android Recycler view, using the below code I can get it to work sometimes.
MobileElement element = (MobileElement) driver.findElement(MobileBy.AndroidUIAutomator(
"new UiScrollable(new UiSelector().resourceId(\"" + resourceID + "\")).getChildByText("
+ "new UiSelector().className(\"" + className + "\"),\"" + buttonText +"\")"));
The issue is, about half the time it will quit looking before finding the desired text, so I’ve been trying to use the above code with setMaxSearchSwipes(20)
I’ve tried the following, but the code seems to only try swiping 5 times before it quits.
MobileElement element = (MobileElement) driver.findElement(MobileBy.AndroidUIAutomator(
"new UiScrollable(new UiSelector().resourceId(\"" + resourceID + "\")).setMaxSearchSwipes(20).getChildByText("
+ "new UiSelector().className(\"" + className + "\"),\"" + buttonText +"\")"));
and
MobileElement element = (MobileElement) driver.findElement(MobileBy.AndroidUIAutomator(
"new UiScrollable(new UiSelector().resourceId(\"" + resourceID + "\")).getChildByText("
+ "new UiSelector().className(\"" + className + "\"),\"" + buttonText +"\").setMaxSearchSwipes(20)"));