一、根据class name和text属性  包名不可省略

  code= new UiSelector().text("我的").classname("android.widget.TextView")

  driver.find_element_by_android_uiautomator(code)

  driver.find_elements_by_android_uiautomator(code)

二、根据resource id属性  包名不可省略

  new UiSelector().resourceId("com.ibox.calculators:id/account_txt")

三、childSelector  相当于//

  这种方法是在已知父控件的时候如何快速的查找该父控件下面的子控件。

四、instance  index  用于子元素

  index   Set the search criteria to match the widget by its node index in the layout hierarchy.

     设置查询标准根据布局结构中的节点index匹配部件

       多多计算器 ,查询数字元素,查询数字元素每行的第三个元素

       new UiSelector().textMatches("[0-9]").index(2) 结果为3/6/9,结果为每一行的第三个元素

  instance Set the search criteria to match the widget by its instance number

     设置查询标准(条件)根据编号匹配部件

        多多计算器 ,查询数字元素   查询CV的className为TextView的第二个子元素

        new UiSelector().resourceId("com.ibox.calculators:id/cv").childSelector(new UiSelector().className("android.widget.TextView").instance(1))   

五、fromParent 根据元素的父元素找到兄弟元素

      多多计算器 ,查询数字3,根据父元素查找数字1 ,两个元素为(非)兄弟元素,即有相同一个父元素  

      new UiSelector().text("3").fromParent(new UiSelector().text("1"))

UiSelector的官方帮助文档

https://developer.android.google.cn/topic/libraries/testing-support-library/index.html#UIAutomator

最新文章

  1. SQL 事务隔离学习
  2. 常用数据库高可用和分区解决方案(1) — MySQL篇
  3. STL_fill()用法
  4. sql server中sql语句中单引号怎么转义?【转】
  5. web前端开发工程师,你了解吗?
  6. VS2012添加PlaySound引用
  7. 解决Gradle DSL method not found: ‘android()’
  8. 嵌入式 uboot以及kernel添加看门狗临时记录(个人记录未整理乱)
  9. Android Cursor空指针的问题
  10. nginx处理静态资源的配置
  11. JavaScript的DOM编程--12--innerHTML属性
  12. Java集合中的Map接口
  13. c# 工具类(字符串和时间,文件)
  14. nginx nfs服务
  15. Struts,Spring,Hibernate三大框架的
  16. Ansys热应力计算
  17. POIUtils 导出 poi Test 100w 600w 条数据
  18. MVC 获取控制器名称和Action名称(转载)
  19. 在html中控制自动换行
  20. 标准库string的用法探讨

热门文章

  1. Kali Win-KeX Win
  2. RocketMQ消息短暂而又精彩的一生
  3. [BUUCTF]洞拐洞拐洞洞拐
  4. Mysql--回顾提要
  5. 服务器搭建(CenOS 7 Apache + PHP _Mysql环境(LAMP))
  6. 理论+实践,教你如何使用Nginx实现限流
  7. 第三方模块:requests模块和openpyxl模块
  8. 面向对象程序设计(三):C++模板operator Type类型转换
  9. JAVA虚拟机10---内存分配策略
  10. webrtc QOS笔记一 Neteq直方图算法浅读