在appium中查找列表视图中的所有元素
Finding all elements in list view in appium
我在列表视图中有大约 200 个项目。当我打印列表视图的大小时,它仅打印可见项目计数(例如 10 项)。它不会滚动和打印所有项目。如何获取列表视图中的所有项目。
//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);
}
}
我在列表视图中有大约 200 个项目。当我打印列表视图的大小时,它仅打印可见项目计数(例如 10 项)。它不会滚动和打印所有项目。如何获取列表视图中的所有项目。
//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);
}
}