UiAutomator -- UiObject2 API
1.点击与长按
void |
click()
Clicks on this object. |
void |
click(long duration)
Performs a click on this object that lasts for |
<R> R |
clickAndWait(EventCondition<R> condition, long timeout)
Clicks on this object, and waits for the given condition to become true. |
void |
longClick()
Performs a long click on this object. |
2.拖拽与滑动
void |
drag(Point dest)
Drags this object to the specified location. |
void |
drag(Point dest, int speed)
Drags this object to the specified location. |
void |
swipe(Direction direction, float percent, int speed)
Performs a swipe gesture on this object. |
void |
swipe(Direction direction, float percent)
Performs a swipe gesture on this object. |
3.输入文本与清除文本
void |
setText(String text)
Sets the text content if this object is an editable field. |
void |
clear()
Clears the text content if this object is an editable field. |
如clear()不起作用,可采取
//将光标移动到文字末尾,按backspace
//将光标移动到文本开头,按del
4.获取对象属性
String |
getApplicationPackage()
Returns the package name of the app that this object belongs to. |
int |
getChildCount()
Returns the number of child elements directly under this object. |
List<UiObject2> |
getChildren()
Returns a collection of the child elements directly under this object. |
String |
getClassName()
Returns the class name of the underlying |
String |
getContentDescription()
Returns the content description for this object. |
UiObject2 |
getParent()
Returns this object's parent. |
String |
getResourceName()
Returns the fully qualified resource name for this object's id. |
String |
getText()
Returns the text value for this object. |
Rect |
getVisibleBounds()
Returns the visible bounds of this object in screen coordinates. |
Point |
getVisibleCenter()
Returns a point in the center of the visible bounds of this object. |
5.属性判断:
boolean |
isCheckable()
Returns whether this object is checkable. |
boolean |
isChecked()
Returns whether this object is checked. |
boolean |
isClickable()
Returns whether this object is clickable. |
boolean |
isEnabled()
Returns whether this object is enabled. |
boolean |
isFocusable()
Returns whether this object is focusable. |
boolean |
isFocused()
Returns whether this object is focused. |
boolean |
isLongClickable()
Returns whether this object is long clickable. |
boolean |
isScrollable()
Returns whether this object is scrollable. |
boolean |
isSelected()
Returns whether this object is selected. |
6.模拟手势操作
双指缩放
void |
pinchClose(float percent)
Performs a pinch close gesture on this object. |
void |
pinchClose(float percent, int speed)
Performs a pinch close gesture on this object. |
void |
pinchOpen(float percent)
Performs a pinch open gesture on this object. |
void |
pinchOpen(float percent, int speed)
Performs a pinch open gesture on this object. |
其他
boolean |
fling(Direction direction, int speed)
Performs a fling gesture on this object. |
boolean |
fling(Direction direction)
Performs a fling gesture on this object. |
boolean |
scroll(Direction direction, float percent, int speed)
Performs a scroll gesture on this object. |
boolean |
scroll(Direction direction, float percent)
Performs a scroll gesture on this object. |
void |
setGestureMargin(int margin)
Sets the margins used for gestures in pixels. |
void |
setGestureMargins(int left, int top, int right, int bottom)
Sets the margins used for gestures in pixels. |
7.判断对象是否存在
boolean |
hasObject(BySelector selector)
Returns whether there is a match for the given criteria under this object. |
8.获取该对象
UiObject2 |
findObject(BySelector selector)
Searches all elements under this object and returns the first object to match the criteria. |
List<UiObject2> |
findObjects(BySelector selector)
Searches all elements under this object and returns all objects that match the criteria. |
9.等待
<R> R |
wait(UiObject2Condition<R> condition, long timeout)
Waits for given the |
<R> R |
wait(SearchCondition<R> condition, long timeout)
Waits for given the |
UiAutomator -- UiObject2 API的更多相关文章
- Android无线测试之—UiAutomator UiScrollable API介绍八
设置滚动方向 一.设置滚动方向相关API 返回值 API 描述 UiScrollable setAsHorizontalList 设置滚动方向为水平滚动 UiScrollable setAsVerti ...
- Android无线测试之—UiAutomator UiScrollable API介绍七
滑动到某个对象 一.滑动到某个对象相关API 返回值 API 描述 boolean scrollIntoView(UiSelector selector) 滑动到条件元素所在位置,并且尽量让其居于屏幕 ...
- Android无线测试之—UiAutomator UiScrollable API介绍六
向前与向后滚动API 一.向前与向后滚动相关API 返回值 API 描述 boolean scrollBackward(int steps) 自动以步长向后滑动 boolean scrollBackw ...
- Android无线测试之—UiAutomator UiScrollable API介绍五
滑动区域校准常量设置与获取 一.校准概念 校准常量指的是:滑动操作坐标时的偏移量,用来取偏移比例 二.相关API 返回值 API 描述 double getSwipeDeadZonePercentag ...
- Android无线测试之—UiAutomator UiScrollable API介绍四
获取与设置最大滚动次数常量值 一.获取与设置最大滚动次数常量值相关API 返回值 API 描述 int getMaxSearchSwipes() 获取执行搜索滑动过程中的最大滑动次数,默认最大滚动次数 ...
- Android无线测试之—UiAutomator UiScrollable API介绍三
获取列表子元素 一.相关API介绍 返回值 API 描述 UiObject getChildByDescription(UiSelector childPattern, String text, bo ...
- Android无线测试之—UiAutomator UiScrollable API介绍二
快速滑动 一.快速滑动相关概念 1.步长:从一点滑动到另一点所用的时间 2.扫动次数:例如列表,要滑动多少次才能到底部,这个滑动次数就是扫动次数 二.相关API 返回值 API 描述 boolean ...
- Android无线测试之—UiAutomator UiObject API介绍七
判断对象是否存在 1.判断对象是否存在相关API 返回值 API 描述 boolean waitForExists(long timeout) 等待对象出现 boolean waitUntilGone ...
- Android无线测试之—UiAutomator UiCollection API介绍
UiCollection类介绍 一.UiCollection类说明 1)UiCollection类是UiObject类的子类,即UiObject类的所有方法都被UiCollection继承下来了,都可 ...
随机推荐
- KbmMW 服务器架构简介
kbmmw 由于文档比较少,很多同学开始用时很难理解.一直准备写一个关于kbmmw 架构的东西. 这几天与红鱼儿(blog)研究服务器线程时,整理了一下,大概画了一下kbmmw (版本4.5)服务器的 ...
- Django(3)
https://www.cnblogs.com/yuanchenqi/articles/7429279.html
- arduino空调遥控器
参考:http://www.arduino.cn/thread-3487-1-1.html http://www.arduino.cn/thread-3618-1-1.html 注意1:有金属外壳的一 ...
- 【Unity】2.4 层次视图(Hierarchy)
分类:Unity.C#.VS2015 创建日期:2016-03-29 一.简介 层级视图 (Hierarchy) 包含当前场景中的每个游戏对象 (GameObject).有些是三维模型等资源文件的直接 ...
- time & datetime 模块
在平常的代码中,我们常常需要与时间打交道.在Python中,与时间处理有关的模块就包括:time,datetime,calendar(很少用,不讲),下面分别来介绍. 在开始之前,首先要说明几点: 一 ...
- UVaLive 4597 Inspection (网络流,最小流)
题意:给出一张有向图,每次你可以从图中的任意一点出发,经过若干条边后停止,然后问你最少走几次可以将图中的每条边都走过至少一次,并且要输出方案,这个转化为网络流的话,就相当于 求一个最小流,并且存在下界 ...
- js继承——扩展Object方式实现继承
function Parent(name,sex){ this.name = name; this.sex = sex; this.sayName = function(){ console.log( ...
- C语言中 指针的基础知识总结, 指针数组的理解
1: 指针变量所占的字节数与操作系统为位数有关,64位操作系统下,占8个字节,32位操作系统下,占4个字节 2: 指针变量的本质是用来放地址,而一般的变量是放数值的3: 脱衣服法则: a[2] 变成 ...
- MODIS产品分析和数据处理
ENVI+IDL 17种MODIS产品的功能解释 https://wenku.baidu.com/view/6fd329dcf524ccbff0218440.html ENVI读取MODIS数据大致步 ...
- 挂载镜像SD卡的FAT32文件系统分区到Linux中
首先使用fdisk –l命令查看sd卡的分区息 可以看到,sd卡有三个分区,第一个分区是FAT32系统,主要存放内核img文件和dtb文件,第二个分区是Linux系统分区,第三个分区格式未知,实际是U ...