记使用uiautomator2报错解决方案!

前段时间一直使用的uiautomator1跑appium没有任何问题。后来需要抓取toast弹窗改为uiautomator2,按照网上的教程安装弄了还是不行。

步骤:

1.安装uiautomator2

 pip install --pre uiautomator2 
 pip install pillow (如果需要截图,可安装这个库)

2、设备安装atx-agent

首先设备连接到PC,并能够adb devices发现该设备。 执行下面的命令会自动安装本库所需要的设备端程序:uiautomator-server,atx-agent,openstf / minicap,openstf / minitouch

 # init就是所有USB连接电脑的手机上都安装uiautomator2
 python -m uiautomator2 init
  
 # 指定手机安装uiautomator2, 用 --mirror
 python -m uiautomator2 init --mirror --serial $SERIAL
 ​
 # 嫌弃慢的话,可以用国内的镜像
 python -m uiautomator2 init --mirror

最后提示success,代表atx-agent初始化成功。

3、安装weditor 有了这个,方便我们快速的识别手机上的元素,方便写代码

 1 pip install -U weditor

安装好之后,就可以在命令行运行 weditor --help 确认是否安装成功了。

错误:

然后再配置里将uiautomator1改为uiautomator2,再跑一次。出错了,提示:An unknown server-side error occurred while processing the command. Original error: The instrumentation process cannot be initialized. Make sure the application under test does not crash and investigate the logcat output.

这个好像是配置里面设置了跳过了appium的安装,只需改为:skipServerInstallation: False。或者删除这段配置即可。

然后在运行一次,又报:An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate. Original error Command 'D\:\JAVA\JDK1.8.0_301\Jdk1.8.0_301\bin\java.exe -jar 'C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-adb\jars\sign.jar' 'C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk' --override' exited with code 1

这个百度搜到是因为权限不够什么的,关闭appium,再次用管理员权限打开,在运行即可。终于跑起来了。

最后使用真机出现的问题:

Calling AppiumDriver.getScreenshot() with args: ["63ab9f49-5ae6-4a25-af2a-a07e8f65916e"]
[WD Proxy] Matched '/screenshot' to command name 'getScreenshot'
[WD Proxy] Proxying [GET /screenshot] to [GET http://localhost:8211/wd/hub/session/5f53ff2c-7537-4b0b-ae32-a9232abb70e3/screenshot] with no body

appium连接vivo手机,启动APP后就不动了-其它手机正常
被这个问题卡了很久,终于找到了有效的解决办法。
解决方案:
在网上查了一下com.vivo.abe是ivo系统自带的应用-智能助手,不能删除也不能强制停止,它会自动扫描
系统应用,把认为有问题的应用强制杀掉。如果有应用被它误杀,可以通过添加白名单的方法跳过检查。
在设置->电池>后台高耗电,把appium相关的app都加上,然后再运行appium自动化测试

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值