appium使用过程中的踩坑集

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的服务,重新开启

8、解决Appium连接报错Could not find ‘apksigner.jar‘

搜索 :apksigner.jar(一般在Build Tools下)文件复制到platform-tools/下即可,其他文件也是这样处理

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值