appium_server_v1.4.16版本不适配android7.0系统

appium_server_v1.4.16版本不适配android7.0系统,运行报错“Attempt to re-install io.appium.settings withoutfirst uninstalling”

 

第一步:

原因分析:appiumuiautomator版本与androidV7.0不适配。

预置条件:手机端已经安装完Appium Settings Unlock两个应用

解决步骤:1.修改源码文件-注释安装appiumSettingsunlock的两行代码

            文件路径: C:\Program Files(x86)\Appium\node_modules\appium\lib\devices\android\android.js

           

第二步:

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

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("\n");

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



作者:栗子_2019
链接:https://www.jianshu.com/p/c1f604d9a6a1
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值