appiumを使用してandroid 7.0実機上のテストプログラム時報エラーcommand failed shell「ps'uiautomator」の解決方法
3453 ワード
appiumを使用してandroid 7.0実機上のテストプログラム時報エラーcommand failed shell「ps'uiautomator」の解決方法
appiumの現在の最新windowsバージョンは1.4です.16,android 7.0本番でプログラムをテストすると、command failed shell「ps'uiautomator」とエラーが発生します.
ネット上の多くの人の解決方法は以下の通りです.
1、appiumのインストールディレクトリの下のadbを見つける.jsファイル、ディレクトリ:Appiumode_modules\appiumode_modulesappium-adblib 2、adbを開く.js、次のコードが見つかりました.
このコードの下にこの行のコードを追加します.
3、appiumの再起動
私はこの方法で問題を解決していません.最後に次の方法を見つけました.ここで共有します.
1、appiumのインストールディレクトリの下のadbを見つける.jsファイル、ディレクトリ:Appiumode_modules\appiumode_modulesappium-adblib 2、adbを開く.js、次のコードが見つかりました.
このコードの下にこのコードを追加します.
次のコードを見つけます.
このコードを注釈して、次のコードに置き換えます.
3、appiumの再起動
問題が解決する.
appiumの現在の最新windowsバージョンは1.4です.16,android 7.0本番でプログラムをテストすると、command failed shell「ps'uiautomator」とエラーが発生します.
ネット上の多くの人の解決方法は以下の通りです.
1、appiumのインストールディレクトリの下のadbを見つける.jsファイル、ディレクトリ:Appiumode_modules\appiumode_modulesappium-adblib 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("
");
このコードの下にこの行のコードを追加します.
outlines.shift();
3、appiumの再起動
私はこの方法で問題を解決していません.最後に次の方法を見つけました.ここで共有します.
1、appiumのインストールディレクトリの下のadbを見つける.jsファイル、ディレクトリ:Appiumode_modules\appiumode_modulesappium-adblib 2、adbを開く.js、次のコードが見つかりました.
ADB.prototype.shell = function (cmd, cb) {
if (cmd.indexOf('"') === -1) {
cmd = '"' + cmd + '"';
}
var execCmd = 'shell ' + cmd;
this.exec(execCmd, cb);
};
このコードの下にこのコードを追加します.
ADB.prototype.shell_grep = function (cmd, grep, cb) {
if (cmd.indexOf('"') === -1) {
cmd = '"' + cmd + '"';
}
var execCmd = 'shell ' + cmd + '| grep ' + grep;
this.exec(execCmd, cb);
};
次のコードを見つけます.
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("
");
outlines.shift();
_.each(outlines, function (outline) {
if (outline.indexOf(name) !== -1) {
procs.push(outline);
}
});
if (procs.length < 1) {
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);
});
};
このコードを注釈して、次のコードに置き換えます.
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);
});
};
3、appiumの再起動
問題が解決する.