在下面的例子中,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);
Error: Found arrayOfProperties2 total: 32
org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
最佳答案
使用“名字”
property.getAttribute("name");
关于java - Appium 无法获取 "content-desc"属性数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26049651/