码迷,mamicode.com
首页 > Windows程序 > 详细

Uiautomator UiDeviceAPI介绍

时间:2017-05-10 19:57:34      阅读:570      评论:0      收藏:0      [点我收藏+]

标签:etl   launcher   erp   auto   article   java   tor   home   结果   

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 用UIautomator的流程  

  (1)获得一个UiDevice对象,代表我们正在执行测试的设备
   (2)通过findObject()方法获取到一个UiObject对象,代表我们需要执行测试的UI组件
   (3)
对该UI组件执行一系列操作。

     (4)检查操作的结果是否符合预期。

3 UiDevice api
  (1)getInstance(),通过getInstance()方法获取到当前设备,入参为一个Instrumentation对象:

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

    (2) 其余常见的接口

  技术分享

// Start from the home screen   
mDevice.pressHome();

  (3)getLauncherPackageName   

  // wati for launch
  final String mDevice.getLauncherPackageName(); 有关java final关键字的说明请看http://www.cnblogs.com/lwbqqyumidi/p/3513047.html
  
mDevice.wait(Until.hasObject(By.pkg(launcherPackage).depth(0)),
LAUNCH_TIMEOUT);

(4)

 

Uiautomator UiDeviceAPI介绍

标签:etl   launcher   erp   auto   article   java   tor   home   结果   

原文地址:http://www.cnblogs.com/liuzhipenglove/p/6837612.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!