appium元素定位之AndroidUiAutomator
UIAutomator 元素定位是 Android 系统原生支持的定位方式,虽然与 xpath 类似,但比它更好用,并且支持元素全部的属性定位,定位原理是通过 android 自带的android uiautomator 的类库去查找元素
方法名:find_element_by_android_uiautomator('uiSelector 表达式')
该方法的参数为 UiSelector 类定位元素的表达式:new UiSelector().函数名称("定位表达式")
实例化一个 UiSelector 对象,然后通过实例调用对应的方法,每一个方法返回的都是UiSelector 对象本身
注意:UiSelector 类下面的函数的参数如果是字符串,必须是双引号,这是 Java 的语法风格,在 Java 中,双引号才表示字符串
UiSelector 类的函数如下:
1.资源id方法
- resourceId(String id) 资源 id
- resourceIdMatches(String regex) 资源 id 正则
2.文本方法
- text(String text) 文本匹配
- textContains(String text) 文本包含
- textStartsWith(String text) 文本开始字符
- textMatches(String regex) 文本正则
3.描述方法
- description(String desc) 描述
- descriptionContains(String desc) 描述包含
- descriptionStartsWith(String desc) 描述开始字符
- descriptionMatches(String regex) 描述正则
4.类名方法
- childSelector(UiSelector selector) 子类
- fromParent(UiSelector selector) 父类
- className(String className) 类名
5.索引、实例方法
- index(int index) 编号
- instance(int instance) 索引
6.特有属性方法
- checked(boolean val) 选择属性
- checkable(boolean val) 点击属性
- enabled(boolean val) enabled 属性
- focusable(boolean val) 焦点属性
- longClickable(boolean val) 长按属性
- scrollable(boolean val) 滚动属性
- selected(boolean val) 选择属性
7.包名方法
- packageName(String name) 包名
- packageNameMatches(String regex) 包名正则
示例:
new UiSelector().text("text") # 使用元素 text 属性定位
new UiSelector().resourceId("id") # 使用 id 定位
new UiSelector().className("className") # 使用元素类型定位
# 还可以元素多个属性自由组合
new UiSelector().className("className").text("text")
new UiSelector()..resourceId("id").clickable(val)
appium元素定位之AndroidUiAutomator的更多相关文章
- 4、通过uiautomatorviewer实现appium元素定位
熟悉selenium自动化的小伙伴应该知道WebDriver 提供了八种元素定位方法: idnameclass nametag namelink textpartial link textxpathc ...
- Python Appium 元素定位方法简单介绍
Python Appium 元素定位 常用的八种定位方法(与selenium通用) # id定位 driver.find_element_by_id() # name定位 driver.find_ ...
- appium元素定位总结
appium元素定位方法总结 使用uiautomator定位 driver.find_element_by_android_uiautomator(uia_string) 根据resourceId属性 ...
- appium元素定位工具
appium元素定位工具介绍 使用uiautomatorviewer定位工具 使用Appium Inspector定位工具 使用uiautomatorviewer定位工具 谷歌在Android S ...
- APP 自动化之appium元素定位(三)
APP自动化测试关键环节--元素定位,以下我们来了解appium提供的元素定位方法! 1. id定位,id一个控件的唯一标识,由开发人员在项目中指定,如果一个元素有对应的resource-id,我们就 ...
- appium 元素定位方法汇总
以上图为例,要定位到右下角的 我的 ,并点击 # appium的webdriver提供了11种元素定位方法,在selenium的基础上扩展了三个,可以在pycharm里面输入driver.find_e ...
- appium 元素定位工具
两种元素定位工具: 1.uiautomatorviewer是android-sdk自带的一个元素定位工具,目录D:\androidsdk\androidsdk\tools\bin . 双击启动uiau ...
- appium 元素定位与操作:
一.常用识别元素的工具 uiautomator:Android SDK自带的一个工具,在tools目录下 monitor:Android SDK自带的一个工具,在tools目录下 Appium I ...
- appium===元素定位
一.常用识别元素的工具 uiautomator:Android SDK自带的一个工具,在tools目录下 monitor:Android SDK自带的一个工具,在tools目录下 Appium Ins ...
随机推荐
- 205K+程序员关注过的问题:为什么不应该使用Java的原始类型?
在逛 Stack Overflow 的时候,发现了一些访问量像熊耳山一样高的问题,比如说这个:为什么不应该使用Java的原始类型?访问量足足有 205K+,这不得了啊!说明有很多很多的程序员被这个问题 ...
- 1. 初探--prometheus调研
一.基本概念 Prometheus 是由前 Google 工程师从 2012 年开始在 Soundcloud 以开源软件的形式进行研发的系统监控和告警工具包,自此以后,许多公司和组织都采用了 Prom ...
- 《Java基础知识》Java锁详解(volatile,synchronized等)
volatile: 让变量每次在使用的时候,都从主存中取. volatile具有synchronized关键字的“可见性”,但是没有synchronized关键字的“并发正确性”,也就是说不保证线程执 ...
- 微服务架构 SpringBoot(一)
spring Boot:官网地址 https://spring.io/ 由来: 随着spring组件功能的强大,配置文件也越来越复杂繁琐,背离了spring公司的简洁快速开发原理,2015年就推出Sp ...
- Ubuntu找不到stdio.h等头文件_安装c库_build-essential安装失败解决
最近安装的Ubuntu1804系统,vim.gcc都是现安的,用gcc编译时出现找不到头文件情况: 于是百度. 原来linux类的操作系统上面开发程序,光有了gcc 是不行的,它还需要一个 build ...
- 千呼万唤始出来——uFUN开发板2.0开箱评测
前言 今年3月,我参与了面包板社区组织的第一批uFUN开发板评测活动,并有幸能获得试用机会,那是我第一次了解到uFUN这个项目及背后的故事,4月份,uFUN 2.0版本来了,收到了张工送的一块样板,后 ...
- C# get md5 from bytes
static byte[] GetBytesFromDic(Dictionary<string,string> dic) { if(dic==null || !dic.Any()) { r ...
- Python学习之while
count = 0while count <= 5: print('人生苦短,我用Python!', 'count = ', count) count += 1
- JS---案例:美女时钟
案例:美女时钟 思路: 打开页面就有图片按每秒1张的顺序轮换,用到了日期对象,获取小时和秒. 封装到一个命名函数后,为了使页面打卡就有图片的轮换,先调用下f1,再设置setInterval <! ...
- linux 定时备份数据库
说明 检查Crontab是否安装 若没有 需要先安装Crontab定时工具 安装定时工具参考(https://www.cnblogs.com/shaohuixia/p/5577738.html) 需要 ...