老的Appium启动时候的一些问题

Appium版本:1.4.16.1

问题1:selenium.common.exceptions.SessionNotCreatedException: Message: A new session could not be created. (Original error: Command failed: C:\Windows\system32\cmd.exe /s /c "D:\SDK\SDK\platform-tools\adb.exe -s 78f59013 shell "ps 'uiautomator'""

解决方法:

adb.js(你的安装目录\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js) 大概1035 行this.shell(“ps '” + name + “’”, function (err, stdout) {

对应执行的指令是ps ‘uiautomator’, Android7不支持这个指令格式,所以执行结果是bad pid ‘uiautomator’
目前Appium未对此进行处理,所以需要修改此指令的执行方式

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

};


提示:这是老的appium每次运行都去安装Unlock,AppiumSetting,等3个应用的解决办法,老的appium不支持android7.0了,建议用新的appium

问题2:因为执行appium的时候,会先往手机中安装几个应用,现在的手机(vivo,小米)都会出现未知来源的安全提示,必须要装sim卡和输密码,这个问题怎么解决?

解决方法:

1.自己手动安装 你的安装目录\Appium\node_modules\appium\build 目录下的 settings_apk ,unicode_ime_apk ,unlock_apk 这三个apk

2.找到appium的安装路径\Appium\node_modules\appium\lib\devices\android\android.js 大概109行,注释掉下面我注释掉的这四行代码~

   this.installAppForTest.bind(this),
    this.forwardPort.bind(this),
    this.pushAppium.bind(this),
//    this.initUnicode.bind(this),
 //   this.pushSettingsApp.bind(this),
//    this.pushUnlock.bind(this),
    function (cb) {this.uiautomator.start(cb);}.bind(this),
    this.wakeUp.bind(this),
 //   this.unlock.bind(this),

    this.getDataDir.bind(this),

3.重启appium

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值