0

I’m trying to scroll my country list to find specific country and after first attempt list is shaking which provides error.

Video with app behaviour:

https://youtube.com/shorts/6SOI4YQbJlk?feature=share 1

Code:

public void tapOnElementByText(String element) {
    HashMap<String, Object> scrollObject = new HashMap<>();
    JavascriptExecutor js = driver;

    scrollObject.put("direction", "down");
    js.executeScript("mobile: scroll", scrollObject);
    try {
        driver.findElementByIosNsPredicate("label == \"" + element + "\"").click();
    } catch (NoSuchElementException exception) {
        System.out.println("Element not found");
    }
}

I tried all kind of stuff from stackoverflow and appium tutorial(http://appium.io/docs/en/writing-running-appium/tutorial/swipe-tutorial/), but it didn’t helped me

J.Klimov
  • 93
  • 10

1 Answers1

1

The scroll that you are using I think just does a swipe so isn't really controlled. Plus when you do a FindElementByXYZ I think there is a limit of 50 elements when searching for something off screen, so if you are looking for a country beginning with Z after the scroll it still might not find it.

As you have a search box could you just type in the country name you want or even just the first few characters and then select from the resulting shortened list?

I do something similar in an app I test and this strategy works well.

Javageddon
  • 76
  • 3