【问题标题】:Couldn't able to use Xpath in Appium + Robot Framework where in Appium Log its displaying error message as contextId: ' multiple: true'无法在 Appium + Robot Framework 中使用 Xpath,在 Appium 中将其显示的错误消息显示为 contextId: 'multiple: true'
【发布时间】:2019-07-19 17:00:16
【问题描述】:

将机器人框架与 Appium 和 Selenium2Library/SeleniumLibrary 结合使用。如果我尝试使用一些 xpath 定位器运行我的脚本,如下所示

 AppiumLibrary.Click Element                       xpath=//android.widget.TextView[@text='Site Control'] 

在关键字文件中,然后在错误消息下方。

错误信息:

Finding '//android.widget.EditText[@index='4']' using 'XPATH' with the contextId: '' multiple: true

Appium 日志:

 [debug] [35m[AndroidBootstrap][39m [BOOTSTRAP LOG] [debug] Got command of type ACTION
 [debug] [35m[AndroidBootstrap][39m [BOOTSTRAP LOG] [debug] Got command action: find
 [debug] [35m[AndroidBootstrap][39m [BOOTSTRAP LOG] [debug] Finding '//android.widget.EditText[@index='4']' using 'XPATH' with the contextId: '' multiple: true

机器人脚本:

 Click on Site Control and Create Case
      AppiumLibrary.Click Element                       xpath=//android.widget.TextView[@text='Site Control']
      sleep                                             ${timeout}
      AppiumLibrary.click element                       xpath=//android.widget.EditText[@index='4']
      sleep                                             ${timeout}
      AppiumLibrary.input text                          xpath=//android.widget.EditText[@text='Intallationid']   site212

【问题讨论】:

    标签: appium robotframework appium-android selenium2library


    【解决方案1】:

    这意味着您的定位器不是那么独特。请尝试添加更多独特的属性,例如 //android.widget.EditText[@index='4' 和 @attribute='value']

    【讨论】:

    • 定位器只工作一次,第二次执行。多个:真实错误显示在 Appium 日志中,自动化暂停,直到手动停止
    • 我已经尝试了所有 abs 和相对 xpath 组合
    【解决方案2】:

    终于找到了这个错误信息的答案。问题是开发团队在他们的 React Native 代码中维护 UI 元素的通用变量名称以重用它并克服此错误是添加 UiAutomator2 功能,如下所示:

    对于带有 Appium 的 Java(Appium Java 客户端)

    capabilities.setCapability("automationName", "UiAutomator2");
    

    对于机器人框架(机器人 AppiumLibrary)

    automationName=UiAutomator2 (inside open application keyword)
    

    为什么会出现这个错误?如果我们的设备/模拟器操作系统版本 >= 6,Appium 不支持 UiAutomator 自动化。我使用的是 7+。所以,我已经切换到 UiAutomator2 并确保 JAVA_HOME 和 ANDROID_HOME 设置正确。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-05
      • 2022-10-20
      • 2020-12-15
      • 2018-10-30
      • 1970-01-01
      • 2020-11-25
      相关资源
      最近更新 更多