uiautomator+脱离PC运行(apk启动uiautomator)的实现方案
终于搞出来了。美滋滋!附上代码:
效果:
打开MyUIautomatorTest.apk,点击run uiautomator 按钮,就能直接运行你的脚本。 方案概述:
新建一个Android app工程MyUIautomatorTest,在Activity中添加Button,用于启动脚本(使用am instrument命令实现脚本的运行) 给这个app添加系统签名(我是在安卓GO源码环境模块编译的;之前搜网上的利用系统签名文件签名,M、N上OK,但是在GO上GG了) 在MyTest中新建一个module,命名为MyUIautomatorTestCase,用于编写脚本
push 、install apk,就ok啦。
adb push mytestcast-debug.apk /data/local/tmp/com.example.mytestcast;
adb shell pm install -r "/data/local/tmp/com.example.mytestcast";
adb push mytestcast-debug-androidTest.apk /data/local/tmp/com.example.mytestcast.test;
adb shell pm install -r "/data/local/tmp/com.example.mytestcast.test";
adb install signedAPK/uiauto.apk;
上图:
GO上亲测ok,有什么问题欢迎评论啦。
