1、unknown error: com.android.chrome is not installed on device
问题:连接Appium的设备未安装浏览器com.android.chrome
解决: 1)安装对应的chrome浏览器
2)更改Appium配置: android settings—— user Browser 勾选,选择Browser。此时使用手机自带浏览器com.android.browser
2、command failed shell “ps ‘uiautomator’”
问题:命令“ps ‘uiautomator’”不支持,
解决:需要更改安装文件 XXXX\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js文件代码。兼容此命令:
1)找到如下代码:
在之后添加
ADB.prototype.shell_grep = function (cmd, grep, cb) {
if (cmd.indexOf('"') === -1) {
cmd = '"' + cmd + '"';
}
var execCmd = 'shell ' + cmd + '| grep ' + grep;
this.exec(execCmd, cb);
};
2)替换如下代码段
全部注释掉,然后替换为如下代码:
ADB.prototype.getPIDsByName = function (name, cb) {
logger.debug("Getting all processes with '" + name + "'");
this.shell_grep("ps", name, function (err, stdout) {
if (err) {
logger.debug("No matching processes found");
return cb(null, []);
}
var pids = [];
_.each(procs, function (proc) {
var match = /[^\t ]+[\t ]+([0-9]+)/.exec(proc);
if (match) {
pids.push(parseInt(match[1], 10));
}
});
if (pids.length !== procs.length) {
var msg = "Could not extract PIDs from ps output. PIDS: " +
JSON.stringify(pids) + ", Procs: " + JSON.stringify(procs);
return cb(new Error(msg));
}
cb(null, pids);
});
};
修改后重启Appium,问题解决
3、Failed to start an Appium session, err was: Error: Command failed: C:\windows\system32\cmd.exe /s /c "C:\Users\Administrator\AppData\Local\Android\Sdk\platform-tools\adb.exe -s VSORTCKVS4HI85FU install "D:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk""
Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.appium.unlock without first uninstalling.]
问题:应用已经安装,需要卸载后重新安装 adb uninstall io.appium.unlock(报错的包名)