博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
appium使用过程中的踩坑集
阅读量:2159 次
发布时间:2019-05-01

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

1. nodejs 版本不匹配问题

错误:
error: uncaughtException: Cannot find module ‘internal/fs’ date=Thu May 17 2018 20:39:28 GMT+0800 (中国标准时间), pid=8620, uid=null, gid=null, cwd=D:\appium\node_modules\appium, execPath=C:\Program Files\nodejs\node.exe, version=v10.0.3, argv=[C:\Program Files\nodejs\node.exe

解决方案:

nodejs和appium版本不匹配
appium的版本为1.4.16,对应的nodejs的版本是6.9.4
卸了nodejs重新装一个 v 6.9.4

2. 端口拒绝访问 

错误:
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host=‘127.0.0.1’, port=4725): Max retries exceeded with url: /wd/hub/session (Caused by NewConnectionError(’<urllib3.connection.HTTPConnection object at 0x00000248683A6FD0>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。’,))

解决方案:

端口拒绝访问,原因可能有:
1) 端口被占用(找到端口被占用的进程,如果是残留进程则选择直接关闭;或者可以选择更换其他端口)
查看当前端口被什么进程占用的方法有很多,就不在这里介绍了
2) 端口服务未开启(未开启appium服务,或者开启appium服务的端口和访问的端口不一致)
appium客户端:

脚本代码:

driver=webdriver.Remote('http://127.0.0.1:4725/wd/hub',desired_caps)

检查这两者设置和访问的端口是否一致

3.Original error: Could not extract PIDs from ps output.

错误:
selenium.common.exceptions.SessionNotCreatedException: Message: A new session could not be created.
(Original error: Could not extract PIDs from ps output. PIDS: [], Procs: [“bad pid ‘uiautomator’”])

解决方案:

修改Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js文件

var procs = [];var outlines = stdout.split("\n");// 添加下面这行outlines.shift()

4.appium 运行时向手机安装的两个apk
分析:
Appium settings 用于设置网络状态
Unclock 用于自动解锁,在手机是滑动锁屏的情况下,则会自动解锁并启动apk,注意:图案锁屏与数字锁不可以自动解锁,只能是滑动锁屏

解决方案:

修改Appium\node_modules\appium\lib\devices\android\android.js文件

Android.prototype.start = function (cb, onDie) {				······				this.pushAppium.bind(this),				this.initUnicode.bind(this),				//this.pushSettingsApp.bind(this),    手动注释此2行代码,即可解决问题				//this.pushUnlock.bind(this),				function (cb) {this.uiautomator.start(cb);}.bind(this),				······

5. 找不到apk
错误:
selenium.common.exceptions.SessionNotCreatedException: Message: A new session could not be created. (Original error: Bad app: C:\Users\xxx\Downloads\com.tencent.mobileqq.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat ‘C:\Users\xxx\Downloads\com.tencent.mobileqq.apk’)

解决方案:

原因 可能是路径错了
如果路径正确的情况下,添加如下代码:

PATH = lambda p: os.path.abspath(   os.path.join(os.path.dirname(__file__), p))desired_caps['app'] = PATH('×××(最好是相对路径,本人使用绝对路径失败了)/com.tencent.mobileqq.apk')

6. 缺少appActivity的参数
错误:
selenium.common.exceptions.SessionNotCreatedException: Message: A new session could not be created. (Original error: Parameter ‘appActivity’ is required for launching application)

解决方案:

找到apk的appActivity(传送门),然后再代码中添加

desired_caps['appActivity'] = 'com.tencent.mobileqq.activity.SplashActivity'

7. Requested a new session but one was in progress
错误:
selenium.common.exceptions.SessionNotCreatedException: Message: A new session could not be created. (Original error: Requested a new session but one was in progress)

解决方案:

在重新开启测试脚本时,已经有一session在执行还未关闭
关闭appium的服务,重新开启

 

转载地址:http://zxgwb.baihongyu.com/

你可能感兴趣的文章
什么是 Dropout
查看>>
用 LSTM 做时间序列预测的一个小例子
查看>>
用 LSTM 来做一个分类小问题
查看>>
详解 LSTM
查看>>
按时间轴简述九大卷积神经网络
查看>>
详解循环神经网络(Recurrent Neural Network)
查看>>
为什么要用交叉验证
查看>>
用学习曲线 learning curve 来判别过拟合问题
查看>>
用验证曲线 validation curve 选择超参数
查看>>
用 Grid Search 对 SVM 进行调参
查看>>
用 Pipeline 将训练集参数重复应用到测试集
查看>>
PCA 的数学原理和可视化效果
查看>>
机器学习中常用评估指标汇总
查看>>
什么是 ROC AUC
查看>>
Bagging 简述
查看>>
详解 Stacking 的 python 实现
查看>>
简述极大似然估计
查看>>
用线性判别分析 LDA 降维
查看>>
用 Doc2Vec 得到文档/段落/句子的向量表达
查看>>
使聊天机器人具有个性
查看>>