appium如何支持android7.0

1.报错shell "ps 'uiautomator'"   bad pid uiautomator

1.找到appium的安装目录下的adb.js文件,目录为:Appium\node_modules\appium\node_modules\appium-adb\lib

打开adb.js,找到1035行,如下代码:

     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);
};

2.重启appium

2.避免重复安装setting、unlock、unicode_IME

1.setting和unlock

Appium\node_modules\appium\lib\devices\android.js

打开android.js,找到如下代码,将代码注释掉:
this.pushSettingsApp.bind(this),
this.pushUnlock.bind(this),

2.unicode_IME

Appium\node_modules\appium\lib\devices\android\android-common.js

注释:

androidCommon.pushUnicodeIME = function (cb) {
  cb()
  /*
  logger.debug("Pushing unicode ime to device...");
  var imePath = path.resolve(__dirname, "..", "..", "..", "build",
      "unicode_ime_apk", "UnicodeIME-debug.apk");
  fs.stat(imePath, function (err) {
    if (err) {
      cb(new Error("Could not find Unicode IME apk; please run " +
                   "'reset.sh --android' to build it."));
    } else {
      this.adb.install(imePath, false, cb);
    }
  }.bind(this));
  */
};


问题解决。

猜你喜欢

转载自blog.csdn.net/MiaoDaLengShui/article/details/81012752