【appium】根据UIAutomator定位元素
text属性的方法
driver.find_element_by_android_uiautomator('new UiSelector().text("Custom View")').click() #text
driver.find_element_by_android_uiautomator('new UiSelector().textContains("View")').click() #textContains
driver.find_element_by_android_uiautomator('new UiSelector().textStartsWith("Custom")').click() #textStartsWith
driver.find_element_by_android_uiautomator('new UiSelector().textMatches("^Custom.*")').click() #textMatches
class属性的方法
driver.find_element_by_android_uiautomator('new UiSelector().className("android.widget.TextView").text("Custom View")').click() #className
driver.find_element_by_android_uiautomator('new UiSelector().classNameMatches(".*TextView$").text("Custom View")').click() #classNameMatches
伪xpath方法定位
driver.find_element_by_android_uiautomator('new UiSelector().text("Custom View").fromParent(new UiSelector().text("Accessibility Service"))').click() #通过同级元素定位同级元素
driver.find_element_by_android_uiautomator('new UiSelector().className("android.widget.ListView").childSelector(new UiSelector().text("Custom View"))').click() #通过父级元素定位子集元素
resourceId属性的方法
driver.find_element_by_android_uiautomator('new UiSelector().resourceId("android:id/text1")') #resourceId
driver.find_element_by_android_uiautomator('new UiSelector().resourceIdMatches(".*id/text1$")') #resourceIdMatches
description属性的方法
driver.find_element_by_android_uiautomator('new UiSelector().description("Custom View")').click() #description
driver.find_element_by_android_uiautomator('new UiSelector().descriptionStartsWith("Custom")').click() #descriptionStartsWith
driver.find_element_by_android_uiautomator('new UiSelector().descriptionMatches("^Custom.*")').click() #descriptionMatches
元素的其他属性
除了以上比较常用的方法外,UIAutomator还支持其他一些方法,比如根据控件属性是否可点击可聚焦可长按等来缩小要定位的控件的范围,具体使用方法不一一列举(checked,clickable,focesed.......)
driver.find_element_by_android_uiautomator('new UiSelector().clickable(true).text("Custom View")').click()
【appium】根据UIAutomator定位元素的更多相关文章
- Appium之uiautomator定位元素
元素定位方式有多种,Android也有自身独有的定位方式.下面就单独介绍其基于uiautomator定位元素的方法: 基本语法: driver.find_element_by_android_uiau ...
- appium 使用findElementByAndroidUIAutomator 定位元素示例
appium 使用findElementByAndroidUIAutomator 定位元素示例 import io.appium.java_client.remote.MobileCapability ...
- Appium+Python3+iOS定位元素
前言: 最近在做IOS自动化测试,IOS的Appium环境都配置OK,执行起来真的慢,慢到怀疑人生,那么今天就来总结一下IOS定位方式和各个定位方式的速度排序. 据我观察,按查找元素的顺序速度,从快到 ...
- Appium 使用android_uiautomator定位元素时报错: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
使用 android_uiautomator 定位元素时(现在用的还不太熟,对于这个方法还需要加深了解)报错: 报错信息:The requested resource could not be fou ...
- 【appium】根据UIAutomator定位元素等等资料
https://www.cnblogs.com/paulwinflo/p/4742529.html http://www.cnblogs.com/meitian/p/6103391.html http ...
- Appium之xpath定位元素
原文:http://www.cnblogs.com/cnkemi/p/9180525.html appium也是以webdriver为基的,对于元素的定位也基本一致,只是增加一些更适合移动平台的独特方 ...
- uiautomator定位元素
- Python+Appium自动化测试(9)-自动选择USB用于传输文件(不依赖appium对手机页面元素进行定位)
一,问题 app自动化测试使用Android真机连接电脑时,通常会遇到两种情况: 1.测试机连接电脑会弹窗提示USB选项,选择USB用于"传输文件",有些手机不支持设置默认USB选 ...
- Appium脚本(4) 使用uiautomator方法定位元素
from app.find_element.capability import driver from time import sleep # 使用uiautomator方法定位元素 accunt_i ...
随机推荐
- Linux C ftruncate 函数清空文件注意事项(要使用 lseek 重置偏移量)
转载:http://blog.csdn.net/a_ran/article/details/43562429 int truncate(const char *path, off_t length); ...
- js上传图片前预览方法(支持预览多个图片)
运用js实现上传图片前的预览(支持多张图片),实现的例子如下: 1.源码例子: 1)Js脚本页面 <!doctype html> <html> <head> < ...
- .net群讨论笔记
本篇为.net群中学到的零碎知识点笔记,将持续更新 感谢群内大神,群号(128485855) 1.关于URL编码问题encodeURIComponent 2.c#直接打开本机的excel(包括其他类型 ...
- 为何 Delphi的 Local Variables 突然没有值显示了
可能是上次编译后 code未再修改过. 试试 随便 输入一个空格,然后F9
- Solrj调用Solr API
在MyEclipse下的SSH项目,要调用Solr接口进行操作. 1.先运行solr 2.在已搭建好的SSH项目中用Solrj调用Solr的接口 3.导入如下solr的jar包到搭建好的SSH项目的W ...
- L1-010 比较大小
本题要求将输入的任意3个整数从小到大输出. 输入格式: 输入在一行中给出3个整数,其间以空格分隔. 输出格式: 在一行中将3个整数从小到大输出,其间以“->”相连. 输入样例: 4 2 8 输出 ...
- Latex的\cite后面的参考文献显示问号
今天编写Latex的参考文献,发现编译之后参考文献都是问号,很疑惑.网上搜到一个帖子,发现他的问题和我的类似,但他比我还多出一个问题,就是Bibtex按钮是灰色的无法使用. 遇到“看不到Bibtex按 ...
- 解决Ubuntu下adb无法联接手机终端
1.首先确认开发者选项中USB调试是否打开. 2.在终端输入lsusb,如下图: 查看设备是否已经连接,如果没有此选项,请检查你的手机数据线是否正常连接,否则你的手机就可以用来防身和砸核桃了. 3.在 ...
- 建立自己的Servlet--成功
1--用记事本新建一个servlet程序,文件名为HelloWorld.java,文件内容如下: import java.io.*; import javax.servlet.*; import ja ...
- 使用jenkins进行项目的自动构建部署
jenkins 简介 Jenkins是基于Java开发的一种持续集成工具,用于监控持续重复的工作,功能包括:持续的软件版本发布/测试项目和监控外部调用执行的工作. 官网地址地址: https://je ...