使用appium1.4在android8.0真机上测试程序时报错command failed shell "ps 'uiautomator'"的解决方式
appium1.4,运行自动化脚本时提示
org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Command failed: "D:\Program Files\android-sdk-windows\platform-tools\adb.exe" -s GSL0217302005195 shell "ps 'uiautomator'"
ps: uiautomator
解决办法:
找到appium的安装目录:D:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib下,打开abd.js
1、找到这段代码:
ADB.prototype.shell = function (cmd, cb) {
if (cmd.indexOf('"') === -1) {
cmd = '"' + cmd + '"';
}
var execCmd = 'shell ' + cmd;
this.exec(execCmd, cb);
};
在该代码下边加上:
//解决 ps uiautomator问题
ADB.prototype.shell_grep = function (cmd, grep, cb) {
if (cmd.indexOf('"') === -1) {
cmd = '"' + cmd + '"';
}
var execCmd = 'shell ' + cmd + '| grep ' + grep;
this.exec(execCmd, cb);
};
2、找到第二段代码,注释掉该方法:
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");
_.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、保存adb.js,重启appium,可以解决
使用appium1.4在android8.0真机上测试程序时报错command failed shell "ps 'uiautomator'"的解决方式的更多相关文章
- 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,找到如下 ...
- 使用appium在android9.0真机上测试程序时报错command failed shell “ps ‘uiautomator’”的解决办法
appium目前最新的windows版本是1.4.16,在android9.0真机上测试程序时会报错:command failed shell “ps ‘uiautomator’”. 网上大多数人的解 ...
- appium在android 7.0真机上运行报错command failed shell:............ps:'uiautomator"的解决方式
appium版本:1_4_16 在CSDN中找到相关解决的方案,根据此解决方案顺利的解决了让人惆怅的问题,再次记录. 1.找到appium安装目录下的adb.js文件,目录为:Appium\node_ ...
- 解决Android8.0之后开启service时报错IllegalStateException: Not allowed to start service Intent ...
项目测试时发现的,在双击返回键关闭应用后(并未杀死后台)重新打开APP,其他手机都OK,但是8.0的手机会出现较频繁的crash.检查代码,问题锁定在重新开启应用时的startService()上. ...
- appium 链接真机运行时报错
今天用appium链接真机时,碰到的第一个问题:Attempt to re-install io.appium.settings without first uninstalling.(这是日志中显示 ...
- 使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法
使用AFNetworking 2.0 请求数据时出现错误 Request failed: unacceptable content-type: text/html 解决方法 添加一行 manager. ...
- 编译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 ...
- Android 6.0以后的版本报错:open failed: EACCES (Permission denied)
Android 6.0以后的版本报错:open failed: EACCES (Permission denied) 在开发项目中,遇见要进行文件操作,遇见Caused by: android.sys ...
- windows7,windows8 64位系统 IIS7.0配置.net网站时报错:未能加载文件或程序集“XXX”或它的某一个依赖项。试图加载格式不正确的程序。
背景: 在64位的操作系统中, IIS7.0配置.net网站时报错:未能加载文件或程序集“XXX”或它的某一个依赖项.试图加载格式不正确的程序. 解决办法: 把iis 对应的应用程序池 --高级设置- ...
随机推荐
- 前端学习(二十七)存储&es6(笔记)
cookie 存储 以站点为单位的. 必须配合服务器环境 不能跨浏览器 cookie有生命周期 默认是session session ...
- python5数据存储
1 txt文件存储 正常调用文件python文件操作 https://www.cnblogs.com/x2x3/p/9979919.html 2 json文件存储 在JavaScript语言中,一切都 ...
- 力扣 — Rotate List()
题目描述: 中文: 给定一个链表,旋转链表,将链表每个节点向右移动 k 个位置,其中 k 是非负数. 示例 1: 输入: 1->2->3->4->5->NULL, k = ...
- Java运行显示无待入值
忘记添加@Param()
- 23.倒计时器CountDownLatch
门闩是concurrent包中定义的一个类型,是用于多线程通讯的一个辅助类型. 门闩相当于在一个门上加多个锁,当线程调用await方法时,会检查门闩数量,如果门闩数量大于0,线程会阻塞等待. 当线程调 ...
- djangorestframework-jwt产生对方token
第一步是 通过jwt组件获得当前用户的token 第二步是 进行加密规则 需要用到base64模块进行加密 第三步 进行解密 按照规定的header payload signature 这种方式解密 ...
- Python--MySql(主键的创建方式、存储引擎、存储过程、索引、pymsql)
主键的创建方式 1. create table stud( id int not null unique, name ) ); mysql> desc stud; +-------+------ ...
- 初学Linux基本的命令操作应当记牢
Linux管理文件和目录的命令 命令 功能 命令 功能 pwd 显示当前目录 ls 查看目录下的内容 cd 改变所在目录 cat 显示文件的内容 grep 在文件中查找某字符 cp 复制文件 touc ...
- Comet OJ 三元组 推导+两个指针+分类讨论
题目:https://www.cometoj.com/contest/59/problem/F?problem_id=2681 题意:给你n个三元组 ai,bi,ci,如果某一对三元组满足 2* ...
- mysql5.7-my.cnf
[client] port = socket=/tmp/my3306.sock [mysql] no-auto-rehash [mysqld] #########base############ us ...