Pradap Pandian
Pradap Pandian

Reputation: 406

Finding all elements in list view in appium

I have some 200 items in the List view. When I'm printing the size of the list view it prints only the visible items count(Eg. 10 items). It doesn't scroll and print all the items. How to take all the items in the list view.

Upvotes: 4

Views: 6952

Answers (1)

Raman
Raman

Reputation: 454

//Try this below the code
String a = "Last element name"; /// last element in the list
Boolean found_result = false;

while (!found_result){

    List<WebElement> ele = driver.findElements(By.id("id of your element"));
    int size=0;
     size = size+ele.size();

    for (int i = 0; i < size; i++) {

        String s = ele.get(i).getText();
        if (s.equals(a)) {

            found =true;

             system.out.println(size);
            break;
        }

    }
    if(!found){
    //find startx,starty, and Endy
    driver.swipe(startx, starty, endx, endy, duration);
 }

}

Upvotes: 3

Related Questions