Uiautomator Uideviceapi Introduction

Source: Internet
Author: User
Tags home screen

1 https://developer.android.com/training/testing/ui-testing/uiautomator-testing.html http://www.cnblogs.com/ By-dream/p/4921701.html http://blog.csdn.net/maocaowu_csdn/article/details/50684309

2 The process of using uiautomator

(1) Obtain an UiDevice object that represents the device on which we are executing the test .
   (2)通过findObject()方法获取到一个UiObject对象,代表我们需要执行测试的UI组件
   (3)
perform a series of actions on the UI component.
(4) Check whether the results of the operation are in line with expectations.

3 Uidevice API
(1) getinstance (), getInstance() obtained by method to the current device, into an Instrumentation object:

   UiDevice mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());

(2) Other common interfaces

  

Start from the home screen   
Mdevice.presshome ();

(3) Getlauncherpackagename   

Wati for launch
Mdevice.getlauncherpackagename (); For a description of the Java final keyword, see http://www.cnblogs.com/lwbqqyumidi/p/3513047.html
  Mdevice.wait (Until. Hasobject (by. Pkg (launcherpackage). Depth (0)),
Launch_timeout);

(4)

Uiautomator Uideviceapi Introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.