当前位置: 首页 > 知识库问答 >
问题:

Appium无法获取“Content-Desc”属性数据

轩辕炎彬
2023-03-14

在下面的例子中,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:使用给定的搜索参数在页面上找不到元素。(警告:服务器未提供任何stacktrace信息)

共有1个答案

令狐建修
2023-03-14

使用“名称”

属性.GetAttribute(“name”);

 类似资料:
  • “content-desc”是“submit”,但click()似乎不起作用?如有任何建议,不胜感激?我也试过轻敲触碰动作? (使用Python)我得到了一个...在页上找不到元素..‘尝试单击“提交”按钮时出错。 我通过Accessibility id和xpath进行了如下尝试:

  • 我正在尝试使用以下方法获取元素的content-desc属性 但是得到这个错误 [debug][MJSONWP]调用AppiumDriver.getAttribute(),参数为:[“XPath”,“19”,“F0EA41E6-DFee-4B9B-B756-0B204863D0D4”] [debug][AndroidBootstrap]向Android发送命令:{“cmd”:“action”,“a

  • 我刚开始在appium测试。我能够设置一切并运行测试。我使用UiAutomatorViewer访问了一些按钮,现在我需要单击一个按钮,但我只是得到了cont-desc。我尝试了以下XPath,但最终得到一个错误。任何帮助都会很好。 @findby(xpath=“//*[@contentdescription='登录  登录']”) driver.findElement(by.xpath(“//an

  • 我正在尝试使用appium(java)来自动化Google Hangouts应用程序。 我使用的是Appium客户端V1.3.7,我使用的是三星Galaxy S5 Android os版本5.0。

  • 所以,昨天一切都很好,但现在Android Studio和我的项目抛出了这个错误: 我谷歌了很长时间,但还没有找到任何解决方案。我的项目没有任何单词“Assemble”(项目中的Ctrl+Shift+F)。 gradlew clean Build-StackTrace:

  • 我想读取build.gradle中local.properties中定义的属性(如本文所述),因此在根build.gradle文件中有以下内容: 在模块的build.gradle文件中,我有以下内容: 但同步后出现以下错误: 无法获取类型为com.android.build.gradle.internal.dsl.defaultconfig得defaultconfig得defaultconfig{