Appium_Java_API
1. driver.findElement(MobileBy.AndroidUIAutomator("邀请")).click();
2. driver.findElementById("resourceId").click();
3. import io.appium.java_client.remote.AutomationName;
import io.appium.java_client.remote.MobileCapabilityType;
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, AutomationName.ANDROID_UIAUTOMATOR2);
4. assertNotEquals(driver.findElement(MobileBy.AndroidUIAutomator("new UiSelector().clickable(true)")).getText(), null);
5. assertNotEquals(driver.findElements(MobileBy.AndroidUIAutomator("new UiSelector().clickable(true)")).size(), 0);
6. assertNotEquals(driver.findElementById("android:id/content")
.findElement(MobileBy.AccessibilityId("Graphics")).getText(), null);
7.assertEquals(driver.findElementById("android:id/content").findElements(MobileBy.AccessibilityId("Graphics")).size()
8. driver.findElement(MobileBy.AndroidUIAutomator("resourceId(\"io.appium.android.apis:id/edit\")"));
9. editElement.sendKeys("value");
10. driver.findElementByAccessibilityId("Views").click();
11. AndroidElement list = driver.findElement(By.id("android:id/list"));
MobileElement radioGroup = list.findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector())
.scrollIntoView("+ "new UiSelector().text(\"Radio Group\"));"));
12.driver.findElementByAndroidUIAutomator("new UiSelector().index(0)");
13. findElementByAndroidUIAutomator("text(\"Accessibility\")");
14. 通过index查找: driver.find_element_by_android_uiautomator("new UiSelector().index(5)")
15. 通过text查找: driver.find_element_by_android_uiautomator("new UiSelector().text(\"6\")")
16. 通过clickable查找: driver.find_element_by_android_uiautomator("new UiSelector().clickable(true)")
17. 通过content-desc查找: driver.find_element_by_android_uiautomator("new UiSelector().description(\"\equals")")
18. 通过resource-id查找: driver.find_element_by_android_uiautomator("new UiSelector().resourceId(\"com.android.calculator2:id/digit_3\")")
19. 通过两个以上属性共同查找: driver.find_element_by_android_uiautomator("new UiSelector().clickable(true).index(5)")
20. 使用ByName定位
路径: appium\node_modules\appium-android-driver\build\lib
修改文件:driver.js,只需要修改其中一行即可
this.locatorStrategies = ['xpath', 'id', 'class name', 'accessibility id', '-android uiautomator','name'];--------再此行代码中添加上name
修改完成之后,保存文件,再次重启appium服务,就可以继续使用ByName定位
21) text 方式
driver.find_element_by_android_uiautomator('new UiSelector().text("%s")')
22) description 方式
driver.find_element_by_android_uiautomator('new UiSelector().description("%s")')
23) className 方式
driver.find_element_by_android_uiautomator('new UiSelector().className("%s")')
24) index 方式
driver.find_element_by_android_uiautomator('new UiSelector().index("%s")')
25) className + index 方式
driver.find_element_by_android_uiautomator(
'new UiSelector().className("%s").childSelector(new UiSelector().index("%d"))')
26) 伪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() #通过父级元素定位子集元素
27) resourceId 方式
driver.find_element_by_android_uiautomator('new UiSelector().resourceId("%s")')
参考资料:
1) https://github.com/appium/java-client/tree/master/docs
2) http://appium.io/docs/en/writing-running-appium/caps/index.html
3) On Windows, ensure that you always run Appium in Administrator mode
4)https://blog.csdn.net/eldencheng/article/details/79491579
5) https://testerhome.com/topics/10071
Appium_Java_API的更多相关文章
随机推荐
- OpenCV中InputArray和OutputArray使用方法
原文链接:http://blog.csdn.net/yang_xian521/article/details/7755101 看过OpenCV源代码的朋友,肯定都知道很多函数的接口都是InputArr ...
- Python正则表达式初识(九)
继续分享Python正则表达式的基础知识,今天给大家分享的特殊字符是[\u4E00-\u9FA5],这个特殊字符最好能够记下来,如果记不得的话通过百度也是可以一下子查到的. 该特殊字符是固定的写法,其 ...
- shell的结构化命令
shell在逻辑流程控制这里会根据设置的变量值的条件或其他命令的结果跳过一些命令或者循环执行的这些命令.这些命令通常称为结构化命令 1.if-then语句介绍 基本格式 if command then ...
- python3 类、对象的基础概念
类:具有相同特性和方法的抽象概念称为类 对象:从类中具体描述的一个事物称为对象 类和对象的关系:类是对象的抽象概念,对象是类的具体实例 class test001: #创建类 def __init__ ...
- Linux学习总结(5)——CentOS常用的目录文件操作命令
CentOS常用的目录文件操作命令 一.路径操作的CentOS常用命令 cd pwd NO1. 显示当前路径 [root@rehat root]# pwd NO2. 返回用户主目录 [roo ...
- hdu1856 More is better (并查集)
More is better Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 327680/102400 K (Java/Others) ...
- C语言的有符号与无符号,二进制整数的扩展与截断
C语言的有符号与无符号,二进制整数的扩展与截断 前一节说了整数的表示方式,,也就是无符号编码与补码编码.这一届说一下二进制整数的扩展与截断,这部分内容与C语言挂钩.so,我们先看下面C语言的有符号和无 ...
- 改动UINavigationBar (导航栏)上NavigationBarItem 的字体大小和颜色的用法
//创建一个左边button UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithTitle:@"<" ...
- Apache Spark 1.6公布(新特性介绍)
Apache Spark 1.6公布 CSDN大数据 | 2016-01-06 17:34 今天我们很高兴可以公布Apache Spark 1.6,通过该版本号,Spark在社区开发中达到一个重要的里 ...
- js---- localStorage的基本用法
<body> <div> <span>用户名</span> <input type="text" class='usernam ...