Uiautomator 2.0 VS 1.0

来源:互联网 发布:dsa数据 编辑:程序博客网 时间:2024/05/16 14:10



简介:

google早已推出了uiautomator2.0,但是1.0仍然能用,最近由于许多控件不能识别,所以尝试了在2.0上有没有

这种问题存在。惊奇的发现2.0功能实在比1.0强大很多,所以我们也应该适时改变,去拥抱变化。


WHAT'S NEW IN UIAUTOMATOR 2.0

Most Importantly,Uiautomator is now based on android instrumentation

Instrumentation终于把Uiautomator纳入了他的麾下

Google提供的Android Testing Support Library变化挺多的,比如全面拥抱Junit4.0,推荐使用AndroidJunit

Runner,然后使用Android Studio IDE等等。反正不仅在开发端,在测试端,Google也在做一些标准和统一,然后

让我们忘记之前的MonkeyRunner,Instrumentation


只剩下:

    AndroidJunitRunner :  Junit4 compatible test runner for android

    Espresso:   UI Testing framework,suitable for functional UI testing within an app

    Uiautomator:  UI Testing framework,suitable for cross-app functional UI testing across

    system and installed apps

UiAutomator2改进

1. 基于 Instrumentation,可以获取应用Context,使用 Android服务及接口
2. 基于 Junit4,测试用例无需继承于任何父类,方法名不限,使用注解 Annotation进行
3. UI执行效率比 1.0 快,测试执行可使用AndroidJunit 方式及gradle 方式

4. API 更新,新增UiObject2、Until、By、BySelector等:APIFor UI Automator

5. Log 输出变更,以往使用System.out.print输出流回显至执行端,2.0 输出至Logcat



3 0