Appium Appium 版本 1.4.16,Android 设备固件 7.x,执行脚本时,报错

Z · 2017年01月18日 · 最后由 独行数息 回复于 2017年04月18日 · 1210 次阅读

使用语言:python
报错如下:
WebDriverException: Message: A new session could not be created. (Original error: Could not extract PIDs from ps output. PIDS: [], Procs: ["bad pid 'uiautomator'"])

这个是因为 appium 版本 1.4.16 使用的 uiatumator1.0 不支持的原因导致?如果不升级 appium 版本,是否有解决方案?

共收到 2 条回复 时间 点赞

uiautomator1.0 应该是不支持 7.0,不升版本就换用 uiautomator2.0 吧。

—— 来自 TesterHome 官方 安卓客户端

原因:
1. adb.js 中 1035 行 this.shell("ps '" + name + "'", function (err, stdout) {
对应执行的指令是 ps 'uiautomator', Android7 不支持这个指令格式,所以执行结果是 bad pid 'uiautomator'
目前 Appium 未对此进行处理,所以需要修改此指令的执行方式
即将
this.shell("ps '" + name + "'", function (err, stdout) {
if (err) return cb(err);
替换成
this.shell_grep("ps", name, function (err, stdout) {

if (err) {

logger.debug("No matching processes found");
return cb(null, []);

}

并增加上面用到的 shell_grep 函数:
ADB.prototype.shell_grep = function (cmd, grep, cb) {
if (cmd.indexOf('"') === -1) {
cmd = '"' + cmd + '"';
}
var execCmd = 'shell ' + cmd + '| grep ' + grep;
this.exec(execCmd, cb);

};

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册