我正在使用Selenium 3.x和Appium,并使用XCUITest作为自动化名称的原生iOS应用程序。
我可以使用可访问性ID访问单个元素,它工作得很好,例如driver.findElement(MobileBy.AccessibilityId("Location")).click();
有没有办法在单个页面/表单上获得所有可访问性ID(或值)的列表?
提前谢谢。
发布于 2017-09-27 12:28:01
你可以尝试下面这样的东西,只是你必须根据android模式更改代码的第一行,因为我不知道所有元素都包含在应用程序中的哪里。
下面的示例标识了所有div元素的名称(或大小写中的可访问性id属性),因此您只需调整第一行:
List<WebElement> allElems = driver.findElements(By.xpath("//body//div"));
System.out.println("Avaialable Accesible ids :");
int c=0;
for(WebElement ele : allElems) {
c++;
System.out.print("for element " + c +" Accessibility ID is :");
System.out.println(ele.getAttribute("name"));
//or
System.out.println(ele.getAttribute("content-desc"));
}https://stackoverflow.com/questions/46423662
复制相似问题