uiautomator中运用adb

在编写自动化测试,经常用到adb,在uiautomator中,我们怎么调用adb呢?

例如,我们要调用一个app程序,这首先得需要获取app的报名(如何获取app包名,详情查看我另篇文章)

谷歌浏览器app为例(包名:com.android.chrome/com.google.android.apps.chrome.firstrun.FirstRunActivity),

我们要打开谷歌浏览器,用adb的方法:

adb shell am start com.android.chrome/com.google.android.apps.chrome.firstrun.FirstRunActivity

但是在我们uiautomator怎么调用:

Runtime.getRuntime().exec("am start com.android.chrome/com.google.android.apps.chrome.firstrun.FirstRunActivity");//打开浏览器
注意,在uiautomator中就不用加adb shell了,因为Runtime.getRuntime().exec相当于adb shell了。


---------------------------------完,不明白的给我留言·······················

猜你喜欢

转载自blog.csdn.net/bbs11007/article/details/80016181
今日推荐