【问题标题】:Android app automation using UIAutomator2 tool使用 UIAutomator2 工具实现 Android 应用自动化
【发布时间】:2019-06-29 11:33:33
【问题描述】:

我正在研究应用程序的自动化,并且根据要求,需要使用 UiAutomator2 自动化 android 设备。我在一些教程中看到这只是一种定位器技术。我没有在任何时候使用过这个工具。我之前在Appium 工作过。如果任何人都可以分享示例脚本,将会很有帮助。

【问题讨论】:

    标签: android selenium appium


    【解决方案1】:

    假设您列出了所有要求:

    您会注意到的唯一区别是将此功能添加到您的驱动程序实例中:

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

    并且您的测试将运行得更快。 UiAutomator2 不是定位器技术。它是用于自动化 Android 应用程序的不同框架。

    如果您确实需要使用新型定位器,您可能指的是 UiSelector。

    java中的示例代码:

    driver.findElement(MobileBy.AndroidUIAutomator("new UiSelector().resourceId(\"appPackage:id/LoginButton\")");
    

    更多 UiSelector 策略可以在这里找到:https://developer.android.com/reference/android/support/test/uiautomator/UiSelector

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-08-11
      • 2019-02-06
      • 2020-06-20
      • 1970-01-01
      • 2014-08-30
      • 2012-03-25
      • 2015-04-09
      相关资源
      最近更新 更多