1.点击与长按

void click()

Clicks on this object.

void click(long duration)

Performs a click on this object that lasts for duration milliseconds.

<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 View represented by this object.

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 condition to be met.

<R> R wait(SearchCondition<R> condition, long timeout)

Waits for given the condition to be met.

UiAutomator -- UiObject2 API的更多相关文章

  1. Android无线测试之—UiAutomator UiScrollable API介绍八

    设置滚动方向 一.设置滚动方向相关API 返回值 API 描述 UiScrollable setAsHorizontalList 设置滚动方向为水平滚动 UiScrollable setAsVerti ...

  2. Android无线测试之—UiAutomator UiScrollable API介绍七

    滑动到某个对象 一.滑动到某个对象相关API 返回值 API 描述 boolean scrollIntoView(UiSelector selector) 滑动到条件元素所在位置,并且尽量让其居于屏幕 ...

  3. Android无线测试之—UiAutomator UiScrollable API介绍六

    向前与向后滚动API 一.向前与向后滚动相关API 返回值 API 描述 boolean scrollBackward(int steps) 自动以步长向后滑动 boolean scrollBackw ...

  4. Android无线测试之—UiAutomator UiScrollable API介绍五

    滑动区域校准常量设置与获取 一.校准概念 校准常量指的是:滑动操作坐标时的偏移量,用来取偏移比例 二.相关API 返回值 API 描述 double getSwipeDeadZonePercentag ...

  5. Android无线测试之—UiAutomator UiScrollable API介绍四

    获取与设置最大滚动次数常量值 一.获取与设置最大滚动次数常量值相关API 返回值 API 描述 int getMaxSearchSwipes() 获取执行搜索滑动过程中的最大滑动次数,默认最大滚动次数 ...

  6. Android无线测试之—UiAutomator UiScrollable API介绍三

    获取列表子元素 一.相关API介绍 返回值 API 描述 UiObject getChildByDescription(UiSelector childPattern, String text, bo ...

  7. Android无线测试之—UiAutomator UiScrollable API介绍二

    快速滑动 一.快速滑动相关概念 1.步长:从一点滑动到另一点所用的时间 2.扫动次数:例如列表,要滑动多少次才能到底部,这个滑动次数就是扫动次数 二.相关API 返回值 API 描述 boolean ...

  8. Android无线测试之—UiAutomator UiObject API介绍七

    判断对象是否存在 1.判断对象是否存在相关API 返回值 API 描述 boolean waitForExists(long timeout) 等待对象出现 boolean waitUntilGone ...

  9. Android无线测试之—UiAutomator UiCollection API介绍

    UiCollection类介绍 一.UiCollection类说明 1)UiCollection类是UiObject类的子类,即UiObject类的所有方法都被UiCollection继承下来了,都可 ...

随机推荐

  1. js 获取时间不能大于当前系统时间

    var dataDate=$.trim($("#dataDate").val()); if(dataDate.length==0){ $("#dataDateTip&qu ...

  2. vi 基本使用命令

    说明:以下的例子中 xxx 表示在命令模式下输入 xxx 并回车以下的例子中 :xxx 表示在扩展模式下输入 xxx 并回车小括号中的命令表示相关命令在编辑模式或可视模式下输入的命令会另外注明 1 查 ...

  3. QGIS Server Quickstart

    http://live.osgeo.org/en/quickstart/qgis_mapserver_quickstart.html

  4. Learning ROS for Robotics Programming - Second Edition(《ROS机器人编程学习-第二版》)

    Learning ROS for Robotics Programming - Second Edition <ROS机器人编程学习-第二版> ----Your one-stop guid ...

  5. android2.1中<shape>圆角的bug

    android的兼容性真是一个不可忽略的问题,今天测试时发现使用xml定义Shape drawable在android 2.1上存在bug <SPANstyle="FONT-SIZE: ...

  6. POJ1066线段交点

    POJ1066 题意:给出一个100*100的正方形区域,通过若干连接区域边界的线段将正方形区域分割为多个不规则多边形小区域,然后给出宝藏位置,要求从区域外部开辟到宝藏所在位置的一条路径,使得开辟路径 ...

  7. (原创)Hibernate 使用过程中(尤其是多对多关联中的级联保存和级联删除)的注意事项(基于项目的总结)

    一.先上知识点: 1.hibernate多对多关联关系中最重要的参数是(基于配置文件xxx.hbm.xml文件形式): 1):inverse属性,如果设置inverse=“true”就代表让对方参与维 ...

  8. 论文笔记(3)-Extracting and Composing Robust Features with Denoising Autoencoders

    这篇文章是Bengio研究的在传统的autoencoder基础上增加了噪声参数,也就是说在输入X的时候,并不直接用X的数据,而是按照一定的概率来清空输入为0.paper中的名词为corrupted.这 ...

  9. 权限管理系统系列之WCF通信

    目录 权限管理系统系列之序言  首先说下题外话,有些园友看了前一篇[权限管理系统系列之序言]博客加了QQ群(186841119),看了我写的权限管理系统的相关文档(主要是介绍已经开发的功能),给出了一 ...

  10. maven仓库地址配置

    # 背景 maven中央存库在国外,访问缓慢,一般国内镜像,这里推荐阿里云的 http://maven.aliyun.com/nexus/content/groups/public 我之前采用的方式是 ...