UIAutomator定位简介
UIAutomator元素定位是 Android 系统原生支持的定位方式,虽然与 xpath 类似,但比它更加好用,且支持元素全部属性定位.定位原理是通过android 自带的android uiautomator的类库去查找元素。 Appium元素定位方法其实也是基于Uiautomator来进行封装的。
使用方法 find_element_by_android_uiautomator() 可以运用UiAutomator元素定位。
定位方法
- id定位
- text定位
- class name定位
id定位
id定位是根据元素的resource-id属性来进行定位,使用 UiSelector().resourceId()方法即可。
by_Uiautomator.py
from find_element.capability import driver
driver.find_element_by_android_uiautomator\
('new UiSelector().resourceId("com.tal.kaoyan:id/login_email_edittext")').send_keys('zxw1234')
driver.find_element_by_android_uiautomator\
('new UiSelector().resourceId("com.tal.kaoyan:id/login_password_edittext")').send_keys('zxw123456')
driver.find_element_by_android_uiautomator\
('new UiSelector().resourceId("com.tal.kaoyan:id/login_login_btn")').click()
text定位
text定位就是根据元素的text属性值来进行定位,new UiSelector()
driver.find_element_by_android_uiautomator\
('new UiSelector().text("请输入用户名")').send_keys('zxw1234')
class name定位
与Appium class定位方式一样,也是根据元素的class属性来进行定位。
driver.find_element_by_android_uiautomator\
('new UiSelector().className("android.widget.EditText")').send_keys('zxw1234')
UIAutomator定位简介的更多相关文章
- Appium之uiautomator定位元素
元素定位方式有多种,Android也有自身独有的定位方式.下面就单独介绍其基于uiautomator定位元素的方法: 基本语法: driver.find_element_by_android_uiau ...
- UIAutomator定位Android控件的方法
UIAutomator各种控件定位的方法. 1. 背景 使用SDK自带的NotePad应用,尝试去获得在NotesList那个Activity里的Menu Options上面的那个Add note菜单 ...
- 【转】UIAutomator定位Android控件的方法实践和建议(Appium姊妹篇)
原文地址:http://blog.csdn.net/zhubaitian/article/details/39777951 在本人之前的一篇文章<<Appium基于安卓的各种FindEle ...
- UIAutomator定位Android控件的方法实践和建议(Appium姊妹篇)
在本人之前的一篇文章<<Appium基于安卓的各种FindElement的控件定位方法实践和建议>>第二章节谈到Appium可以通过使用UIAutomator的方法去定位And ...
- 【appium】根据UIAutomator定位元素
text属性的方法 driver.find_element_by_android_uiautomator('new UiSelector().text("Custom View") ...
- HTML定位简介
转载出处 定位一直是WEB标准应用中的难点,如果理不清楚定位那么可能应实现的效果实现不了,实现了的效果可能会走样.如果理清了定位的原理,那定位会让网页实现的更加完美. 定位的定义:在CSS中关于定位的 ...
- appium python中的android uiautomator定位
text定位:driver.find_element_by_android_uiautomator('new UiSelector().text("请输入手机号")') #模糊定位 ...
- Android UIAutomator 定位
AndroidUIAutomator:Android的源生测试框架的定位方式,定位速度快 一.组合定位 1.一般组合用id,class,text这三个属性会比较好一点,但也可以组合定位 2.id与te ...
- 【appium】根据UIAutomator定位元素等等资料
https://www.cnblogs.com/paulwinflo/p/4742529.html http://www.cnblogs.com/meitian/p/6103391.html http ...
随机推荐
- ZooKeeper的应用场景(转)
应用场景1 :统一命名服务 分布式应用中,通常需要一套完备的命令机制,既能产生唯一的标识,又方便人识别和记忆. 我们知道,每个ZNode都可以由其路径唯一标识,路径本身也比较简洁直观,另外ZNode上 ...
- HDU 4508
祼的完全背包问题 #include <iostream> #include <cstdio> #include <cstring> #include <alg ...
- UML类图符号解释
在UML类图中,常见的有以下几种关系: 泛化(Generalization)和 实现(Realization) - 父子关系 依赖(Dependency) - 局部变量.方法參数 聚合(Aggre ...
- 小议:部署SharePoint 2013时,无法连接SQL Server问题
最近在给学员培训时发现,个别学员在完毕SharePoint 2013部署时,无法连接SQL Server,两种报错情况,例如以下所看到的: :配置SharePointConnect to SQL Se ...
- c++ 11 thread 初试
最新的 c++11标准整合进了 线程支持.以下写一个小程序測试一下. 測试代码: #include <iostream> #include <thread> void hell ...
- selenium IDE 回放报错
解决:Selenium RC未启动,启动即可. java -jar selenium-server-standalone-2.25.0.jar 启动RC报错,提示找不到firefox的path,于是配 ...
- 阿里云 Docker-registry 搭建
阿里云 仓库地址: https://cr.console.aliyun.com/cn-hangzhou/instances/images
- 如何注释ascx中的代码
https://forums.asp.net/t/1783252.aspx?Commented+out+ascx+code+not+treated+as+commented+out+ <%-- ...
- poj 2288 Islands and Bridges ——状压DP
题目:http://poj.org/problem?id=2288 状压挺明显的: 一开始写了(记忆化)搜索,但一直T: #include<iostream> #include<cs ...
- Coursera Algorithms week3 归并排序 练习测验: Shuffling a linked list
题目原文: Shuffling a linked list. Given a singly-linked list containing n items, rearrange the items un ...