[英]Not able to find element in pop up in appium
In my app profile I want to select Religion, so when I am clicking on Religion one pop up is opening and I have to choose one element from there, Only "Index" and "text" values are different for each element, "Id" same for all element. 在我的应用程序配置文件中,我想选择“宗教”,因此当我单击“宗教”时,一个弹出窗口正在打开,我必须从中选择一个元素,每个元素“ Id”的唯一“索引”和“文本”值是不同的所有元素都一样。
But while taking "xpath" using "text" and "index" values, not getting the element. 但是在使用“文本”和“索引”值获取“ xpath”时,未获取元素。
I am using scroll to method also but not getting the element. 我也使用滚动到方法,但没有得到元素。
Thanks in advance. 提前致谢。
get all the index and its corresponding religions and click by index number 获取所有索引及其对应的宗教,然后按索引号单击
List<WebElement> ls = driver.findElementsById("android:id/numberpicker_input");
System.out.println("no of religions" + ls.size());
ls.get(0).click
You can click by using click method: 您可以使用单击方法来单击:
driver.findElementByName("your religion name").click();
and scroll by using this method: 并使用以下方法滚动:
public void keepScrollingUntilElementFound(String name) {
for (int i = 0; i < 10; i++) {
if (isElementPresent("name=" + name)) {
break;
} else {
scrollDown();
scrollDown();
}
}
}
public void scrollDown() {
Dimension size = driver.manage().window().getSize();
int x = size.width / 2;
int starty = (int) (size.height * 0.60);
int endy = (int) (size.height * 0.10);
driver.swipe(x, starty, x, endy, 2000);
}
public boolean isElementPresent(String name) {
try {
driver.findElementByName(name);
return true;
} catch (Exception e) {
return false;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.