导航

原错如下:

  

selenium.common.exceptions.WebDriverException: Message: u'A new session could not be created. (Original error: Could not extract
PIDs from ps output. PIDS: [], Procs: ["/system/bin/sh: grep: not found"])'

  解决方案:

      编辑adb.js脚本;路径 {Appium application package}/Contents/Resources/node_module/appium/lib/devices/android/adb.js)

    

Search for the function ADB.prototype.getPIDsByName
    Replace the line:
    this.shell("ps | grep '" + name + "'", function(err, stdout) {
with
this.shell("ps '" + name + "'", function(err, stdout) {
    Add procs.shift(); after the line var procs = stdout.split("\n");
    var procs = stdout.split("\n");
    procs.shift();
    Save the file, and restart Appium server.
It should looks like this in final:
this.shell("ps '" + name + "'", function(err, stdout) {
if (err) return cb(err);
stdout = stdout.trim();
if (!stdout) {
  logger.info("No matching processes found");
  return cb(null, []);
}
var procs = stdout.split("\n");
procs.shift();