【发布时间】:2014-11-20 21:07:08
【问题描述】:
在下面的例子中,Appium 能够正确地按类定位元素,但是当我们想要根据每个元素的 content-desc 操作数据时,我们会看到错误。为什么我们不能获取 content-desc 的属性? 任何建议表示赞赏。
List<WebElement> arrayOfProperties2 = driver.findElementsByClassName("android.view.View");
List<WebElement> propertyMarkerEle = new ArrayList<>();
System.out.println("Found arrayOfProperties2 total: "+ arrayOfProperties2.size());
for (WebElement property : arrayOfProperties2){
String contentDesc = property.getAttribute("content-desc");
if (contentDesc.contains("property"))
propertyMarkerEle.add(property);
错误:找到 arrayOfProperties2 总数:32
org.openqa.selenium.NoSuchElementException:一个元素不能是 使用给定的搜索参数位于页面上。 (警告: 服务器没有提供任何堆栈跟踪信息)
【问题讨论】:
-
这可以帮助我猜github.com/appium/appium/issues/5142。我相信代码更改已被推送。