If the country i.e. Algeria is directly passed in place of country in quotes, it works fine, however, if the variable is used, an error pops up.
Please suggest how to scroll and find an element, when the element is in a variable.
String country = “Algeria”;
driver.findElementByAndroidUIAutomator(“new UiScrollable(new UiSelector()).scrollIntoView(text(country))”).click();
Error: Could not parse expression new UiScrollable(new UiSelector()).scrollIntoView(text(country)) : UiScrollable doesn’t have suitable method scrollIntoView with arguments [text(country)]
Thanks a lot, but all of these methods require one to pass values directly as String.
There’s nothing mentioned where we replace it with its variable and it’ll work the same.
String country = "Algeria";
MobileElement element = (MobileElement) driver.findElement(MobileBy.AndroidUIAutomator(
"new UiScrollable(new UiSelector().scrollable(true))" +
".scrollIntoView(new UiSelector().text(\"" + country + "\"))"));
for horizontal resource id i am not able to get it in appium inspector , is there any other option to replace resource id
MobileElement element = driver.findElement(MobileBy.AndroidUIAutomator(
“new UiScrollable(new UiSelector().resourceId(“com.android.vending:id/items”)).setAsHorizontalList().scrollIntoView(”
+ “new UiSelector().descriptionContains(“Family”))”));
String country = "Nigeria";
WebElement selectCountryCode = driver.findElement(new AppiumBy.ByAndroidUIAutomator(
"new UiScrollable(new UiSelector().scrollable(true)" +
".scrollIntoView(new UiSelector().text(\"" + country + "\"))"));
selectCountryCode.click();
But got this error: org.openqa.selenium.InvalidSelectorException: Could not parse selector expression new UiScrollable(new UiSelector().scrollable(true).scrollIntoView(new UiSelector().text("Nigeria")): Unclosed paren in expression
Any guide on how to resolve this will be much appreciated. I couldn’t figure out where the unclosed paren issue is coming from
MobileElement is deprecated so I had to opt for WebElement