博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
appium安卓7.0以上报错:Original error: Command failed: ps: uiautomator,及sessionId":null的情况...
阅读量:4664 次
发布时间:2019-06-09

本文共 2014 字,大约阅读时间需要 6 分钟。

appium安卓7.0以上报错:Original error: Command failed: ps: uiautomator

解决方法:步骤如下

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

  

3.找到如下代码:

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

  

4.重启appium,问题解决

转载于:https://www.cnblogs.com/chen-xia/articles/10631945.html

你可能感兴趣的文章
红橙黄绿蓝靛紫-RGB-十六进制
查看>>
while read line无法循环read文件
查看>>
kFreeBsd 国内开源镜像站汇总
查看>>
.net开源后可以查看的源代码
查看>>
比较结构的关联词(二)
查看>>
Windows10系统在VMware中安装CentOS7操作系统并实现图形化用户界面Gnome
查看>>
分布式文件系统
查看>>
线程同步工具 Semaphore类的基础使用
查看>>
Bug的等级程度(Blocker, Critical, Major, Minor/Trivial)及修复优先级
查看>>
js多图预览及上传功能
查看>>
Mac下安装ionic和cordova,并生成iOS项目
查看>>
caffe介绍
查看>>
MongoDB副本集和分片模式安装
查看>>
Spring Mvc Url和参数名称忽略大小写
查看>>
Python之常用模块学习(一)
查看>>
CSS------如何让大小不一样的div顶部对齐
查看>>
SOCKET.IO 前后端使用
查看>>
CodeForces 122G Lucky Array(一脸懵逼的树状数组)
查看>>
【开发实例】C#调用SAPI实现语音合成的两种方法
查看>>
Django实战(15):Django实现RESTful web service
查看>>