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

问题解决。

appium java 在android7.0真机上测试程序时报错command failed shell "ps 'uiautomator'"的解决方式的更多相关文章

  1. 使用appium1.4在android8.0真机上测试程序时报错command failed shell "ps 'uiautomator'"的解决方式

    appium1.4,运行自动化脚本时提示 org.openqa.selenium.SessionNotCreatedException: A new session could not be crea ...

  2. 使用appium在android9.0真机上测试程序时报错command failed shell “ps ‘uiautomator’”的解决办法

    appium目前最新的windows版本是1.4.16,在android9.0真机上测试程序时会报错:command failed shell “ps ‘uiautomator’”. 网上大多数人的解 ...

  3. appium在android 7.0真机上运行报错command failed shell:............ps:'uiautomator"的解决方式

    appium版本:1_4_16 在CSDN中找到相关解决的方案,根据此解决方案顺利的解决了让人惆怅的问题,再次记录. 1.找到appium安装目录下的adb.js文件,目录为:Appium\node_ ...

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

    要解决的问题:appium在androidV7.0系统上运行时报错 Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install io.a ...

  5. appium 链接真机运行时报错

    今天用appium链接真机时,碰到的第一个问题:Attempt to re-install io.appium.settings without first uninstalling.(这是日志中显示 ...

  6. 使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法

    使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法 添加一行 manager. ...

  7. 编译gd-2.0.35.tar.gz时报错:gd_png.c:16:53: error: png.h: No such file or directory

    编译gd-2.0.35.tar.gz时报错: gcc -DHAVE_CONFIG_H -I. -I. -I. -I/usr/local/freetype/include/freetype2 -I/us ...

  8. Android 6.0以后的版本报错:open failed: EACCES (Permission denied)

    Android 6.0以后的版本报错:open failed: EACCES (Permission denied) 在开发项目中,遇见要进行文件操作,遇见Caused by: android.sys ...

  9. windows7,windows8 64位系统 IIS7.0配置.net网站时报错:未能加载文件或程序集“XXX”或它的某一个依赖项。试图加载格式不正确的程序。

    背景: 在64位的操作系统中, IIS7.0配置.net网站时报错:未能加载文件或程序集“XXX”或它的某一个依赖项.试图加载格式不正确的程序. 解决办法: 把iis 对应的应用程序池 --高级设置- ...

随机推荐

  1. 开源自然语言处理工具包hanlp中CRF分词实现详解

     CRF简介 CRF是序列标注场景中常用的模型,比HMM能利用更多的特征,比MEMM更能抵抗标记偏置的问题. [gerative-discriminative.png] CRF训练 这类耗时的任务,还 ...

  2. kettle判断是否是数据首行(第一行)

    可以用组件:分析查询(Analytic Query) 后面可以通过判断pre_id 是否为空值(null)判断.

  3. MySQL5.7 GTID 浅析

    https://yq.aliyun.com/articles/68441 摘要: # GTID 简介 GTID (global transaction identifier)在MySQL5.6时引入, ...

  4. webGL之three.js入门2

    入门建议: webGL中文翻译教程,基于NeHe的openGL教程:http://www.hiwebgl.com/?p=42 . WebGL中文网 http://www.hewebgl.com/ ,里 ...

  5. JS和AS交互

    这个话题在网上应该说很好找,有很多这方面的资料.比者也看过一些,不过大部分都是AS2与JS进行交互.很少提到AS3,即使有,也让人感觉浅尝辄止.很多东西并没有介绍的太清楚.所有笔者萌生了写这样一篇教程 ...

  6. spring AOP的学习

    1.Spring常用的概念 Joinpoint(连接点): 所谓连接点是指那些被拦截到的点.在spring中,这些点指的是方法,因为spring只支持方法类型的连接点. Pointcut(切入点): ...

  7. Spring mvc Json 的正确返回姿势

    我们经常都需要封装统一JSON格式 例如以下形式 { “data”:“输出的数据”, “code”:“响应代码”, “msg”:“响应信息” } /** * Created by linli on 2 ...

  8. 【转】non-blocking REST services with Spring MVC

    堵塞Controller Controller为单例: 非线程安全: 堵塞方式: 1个request对应1个处理Thread: @RestController public class Process ...

  9. Python 模块EasyGui详细介绍

    转载:无知小德 Python 模块EasyGui详细介绍 EasyGui 官网: http://easygui.sourceforge.net 官方的教学文档:http://easygui-docs- ...

  10. [转]FTP命令字和响应码解释

    FTP命令 命令  描述  ABOR 中断数据连接程序 ACCT <account> 系统特权帐号 ALLO <bytes>  为服务器上的文件存储器分配字节 APPE < ...