之前测试用的安卓版本为5.1,可以正常启动真机上的测试app,使用安卓版本7.1时,同样的脚本无法启用测试程序,报错提示
“error: Failed to start an Appium session, err was: Error: Could not extract PIDs from ps output. PIDS: [], Procs: ["bad pid 'uiautomator'"]”
未能启动Appium会话,无法提取PS输出PID
解决方法:
解决Android 7.0系统的手机无法执行appium脚本的问题,改问题的具体解决方法如下:
1、 找到appium的安装目录下的adb.js文件,windows版本的目录如下:Appium\node_modules\appium\node_modules\appium-adb\lib
2、 打开adb.js,手动修改该文件下的内容:
ADB.prototype.getPIDsByName = function (name, cb) {
logger.debug("Getting all processes with '" + name + "'");
this.shell("ps '" + name + "'", function (err, stdout) {
if (err) return cb(err);
stdout = stdout.trim();
var procs = [];
var outlines = stdout.split("\n");
outlines.shift(); //在该处添加此行代码
3、重启appium
感谢大牛的分享,原解决方案链接:https://testerhome.com/topics/7852