zoukankan      html  css  js  c++  java
  • Appium学习笔记||七、用UIAutomator API定位

    一、建议添加下边内容到desitred_caps

      'automationName' = 'UiAutomator2'

    appium跨平台,但是uiautomator只针对安卓

    二、UI Automator  (https://developer.android.google.cn/training/testing/ui-automator)

      1. 安卓要求4.3以上

      2. 测试框架:

        A. UIAutomatorViewer:检查布局层次结构的查看器的工具,之前介绍过。

       

        B. UIDevice类,可以访问设备属性,执行系统操作,用于检索状态信息并在目标设备上执行操作的API

      

        C. UIAutomatorAPI,支持跨应用程序UI测试的API

       

     

    三、 通过class name和text属性查找(使用java代码实现)

    • 代码:

      code = 'new UiSelector().className("android.widget.TextView").text("口碑最佳")’

      ele = driver.find_element_by_android_uiautomator(code)

    • 在Appium中验证:

      

    四、通过resorce id属性查找

    • 代码:

      code = 'new UiSelector().resourceId("com.ibox.calculators:id/digit3")'

      ele = driver.find_element_by_android_uiautomator(code)

    • appium中验证:

      

    五、通过child Selector和instance方法

    • 代码:

      code = ‘new UiSelector().resourceId("io.manong.developerdaily:id/tab_bar").childSelector(new UiSelector().className("android.widget.TextView").instance(3))’

    • appium中验证:

      

    六、三种text方法

      1. textContains:文本包含

      2. textStartsWith:文本以什么开头

      3. textMatches:文本匹配什么正则表达式

  • 相关阅读:
    mac 终端常见指令
    git常见指令
    iOS8的autolayout和size class
    UIWindow详解
    操作系统Unix、Windows、Mac OS、Linux的故事
    iOS引用当前显示的UIAlertView
    Unexpected CFBundleExecutable Key
    《CODE》讲了什么?
    exit和return的区别
    php 登录注册api接口代码
  • 原文地址:https://www.cnblogs.com/Lixinhang/p/10997353.html
Copyright © 2011-2022 走看看