appium版本:1_4_16

在CSDN中找到相关解决的方案,根据此解决方案顺利的解决了让人惆怅的问题,再次记录。

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

2、打开adb.js,可使用notepad++编辑器等打开文件(说明:在修改代码的时候先注释掉以前的代码,并且添加自己容易识别的标记,以防出错后还有回旋的余地,或者将代码备份也可行),找到如下代码:

ADB.prototype.shell = function (cmd, cb) {
if (cmd.indexOf('"') === -) {
cmd = '"' + cmd + '"';
}
var execCmd = 'shell ' + cmd;
this.exec(execCmd, cb);
};

在这段代码下面加入如下代码:

ADB.prototype.shell_grep = function (cmd, grep, cb) {
if (cmd.indexOf('"') === -) {
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) !== -) {
procs.push(outline);
}
});
if (procs.length < ) {
logger.debug("No matching processes found");
return cb(null, []);
}
var pids = [];
_.each(procs, function (proc) {
var match = /[^\t ]+[\t ]+([-]+)/.exec(proc);
if (match) {
pids.push(parseInt(match[], ));
}
});
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 ]+([-]+)/.exec(proc);
if (match) {
pids.push(parseInt(match[], ));
}
});
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,连接手机成功运行看到解决问题已ok

appium在android 7.0真机上运行报错command failed shell:............ps:'uiautomator"的解决方式的更多相关文章

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

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

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

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

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

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

  4. xcode6 真机运行报错 Command /usr/bin/codesign failed with exit code 1

    解决方法: 百度下载‘iphone配置实用工具’, 打开此软件之后,选择预配置描述文件, 选中iphone过期和重复的描述文件,按delete键删除.然后重启xcode即可

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

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

  6. Robotframework学习笔记之—Rrobotframework运行报错“command: pybot.bat --argumentfile”

    Rrobotframework运行报错"command: pybot.bat --argumentfile" 解决方案: 1.可能是缺失文件: 1.1.检查python安装目录下的 ...

  7. 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 ...

  8. xcode 运行报错 Command /usr/bin/codesign failed with exit code 1

           因为更换了证书,导致在运行时报错 Command /usr/bin/codesign failed with exit code 1,查看了网上各种方法,最后发现以下两个值没有同步更新

  9. Android studio环境配置(运行报错)

    报错的种类有很多,下面的方法能解决大多数: 所有路径不能用中文,不能有空格,逗号句号也不能用中文,项目文件路径也不行 首先要配置Java环境,这个就不多说了, 这里有以下JAVA_HOME的配置,下图 ...

随机推荐

  1. JVM笔记9-Class类文件结构

    1.Class类文件结构  Class 文件是一组以 8 位字节为基础单位的二进制流,各个数据项目严格按照顺序紧凑地排列在 Class 文件之中,中间没有添加任何分隔符,这使得整个 Class 文件中 ...

  2. 微信小程序-框架详解(1)

    配置 -app.json文件对微信小程序进行全局配置,决定页面文件的路径.窗口表现.设置网络超时时间.tab等 { "pages": [ //决定页面文件的路径 "pag ...

  3. python笔记:#012#函数

    函数基础 目标 函数的快速体验 函数的基本使用 函数的参数 函数的返回值 函数的嵌套调用 在模块中定义函数 01. 函数的快速体验 1.1 快速体验 所谓函数,就是把 具有独立功能的代码块 组织为一个 ...

  4. 为什么「margin:auto」可以让块级元素水平居中?

    知乎链接:http://www.zhihu.com/question/21644198 关于BFC的解释:W3CFans http://www.w3cfuns.com/thread-5595727-1 ...

  5. 航遇项目react踩坑

    1.iconfont应用: a.正常用法如下 <span className='iconfont' > iconfont的代码,例如: </span> b.react不能动态 ...

  6. Spring使用 --- 基本概念(一):DI,依赖注入

    Table of Contents 什么是依赖注入 怎样使用 什么时候使用 好处 本文讲述sprint基本概念之一: DI, 即依赖注入. 什么是依赖注入 说类A依赖于类B,最简单的例子是类A有一个类 ...

  7. msql索引

    从网上找了两种解决方案: 最近要给一个表加一个联合唯一索引,但是表中的两个联合健有重复值,导致无法创建: 解决方案一:ignore(会删除重复的记录(重复记录只保留一条,其他的删除),然后建立唯一索引 ...

  8. arcEngine开发之加载栅格数据

    加载数据思路 在Engine中加载各种各样的数据都是通过这样的格式 IWorkspaceFactory pWorkspace = new IWorkspaceFactory(); IWorkspace ...

  9. Python接口测试之对MySQL/unittest框架/Requests 的操作

    单元测试支持测试自动化. 共享的安装程序和关闭代码测试. 聚合成集合,测试和报告框架从测试的独立性.单元测试模块提供可以很容易地支持这些素质的一组测试的类.关于unittest 测试框架建议可以到官方 ...

  10. redHat linux 修改防火墙设置简略版

    1) 重启后生效 开启: chkconfig iptables on 关闭: chkconfig iptables off 2) 即时生效,重启后失效 开启: service iptables sta ...