appium1.4.16.1關於 shell "ps 'uiautomator'"的問題解決方法(eclipse)

eclipse運行自動化腳本,appium進行報錯,在eclipse裏控制檯出現
"C:\Windows\system32\cmd.exe /s /c “C:\Users\sxie\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell “ps ‘uiautomator’”” 的錯誤。

解決辦法:找到路徑下的adb.js文件用記事本打開,路徑爲C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js(此爲默認路徑,更根據實際情況更改),
使用快捷鍵ctrl+f打開查找,搜索this.shell(“ps '” + name + “’”, function (err, stdout)在這裏插入圖片描述
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);
};
在這裏插入圖片描述appium1.4.16.1此版本必須配置path環境變量,具體操作可百度。
希望我的經驗對各位有用,可能會因爲電腦環境的不同而無法解決問題,僅供參考使用。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章