Appium无法获取"content-desc"属性数据

gor*_*sbm 6 java android appium

在下面的例子中,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);
Run Code Online (Sandbox Code Playgroud)

错误:找到arrayOfProperties2 total:32
org.openqa.selenium.NoSuchElementException:使用给定的搜索参数无法在页面上找到元素.(警告:服务器未提供任何堆栈跟踪信息)

Tin*_*oni 17

使用名称"

property.getAttribute("name");