-
打印出来的 contexts如下
[‘NATIVE_APP’, ‘WEBVIEW_unknown’]
(我跑了一遍切入webview和切出,然后分别出现以下1.2.3.4的报错,看错误提示,具体问题具体百度,哈哈哈哈) -
看报错信息中显示 appium 中没装chrome driver
解决办法:https://www.cnblogs.com/my_captain/p/12796590.html
https://blog.csdn.net/qq_32722729/article/details/103201616
chrome driver下载
https://npm.taobao.org/mirrors/chromedriver -
报错信息:
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command.
Original error: An unknown server-side error occurred while processing the command.
Original error: unknown error: Failed to forward ports to device xxxx.
No port chosen: . Perhaps your adb version is out of date.
ChromeDriver 2.39 and newer require adb version 1.0.38 or newer.
Run 'adb version' in your terminal of the host device to find your version of adb.
chromeDriver2.39的版本要求adb1.0.38以上的版本
解决办法:更新adb。去android官网下载platform-tools的最新版本包(要翻墙)
我的之前是version 1.0.31,现在是version 1.0.41
链接:https://pan.baidu.com/s/1JjpZio1A1PIuSs6jo_uE5g
提取码:nivs
更新adb的方式:
(1)打开任务管理器,找到adb.exe,右键打开文件所在文件夹
(2)在下载好的新版本的adb中找到这三个文件,复制
(3)到旧版本所在目录替换以下三个文件(以下是旧版本所在的目录)
- 报错信息:
Message: An unknown server-side error occurred while processing the command.
Original error: Error executing adbExec.
Original error: 'Command 'E:\\adt-bundle-windows\\sdk\\platform-tools\\adb.exe -P 5037 -s xxxxx shell settings delete global hidden_api_policy_pre_p_apps' exited with code 255';
Stderr: 'Exception occurred while executing 'delete':
java.lang.SecurityException: Permission denial: writing to settings requires:android.permission.WRITE_SECURE_SETTINGS`
手机权限的问题
解决办法:OPPO设备: 开发者选项 - 禁止权限监控 - 开启
小米/红米类手机:设置 - 更多设置 - 开发者选项 - USB调试(安全设置)- 开启
(这个真的是坑到不行,搞了好久)
- 报错信息:
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command.
Original error: Unable to automate Chrome version because it is too old for this version of Chromedriver.
Chrome version on the device: Chrome/83.0.4103.106
chrome driver的版本太旧了
解决办法:参考第2个的解决办法更换适合的chrome driver
- 报错信息:
selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable: element has zero size
(Session info: chrome=83.0.4103.106)
元素不可交互的问题
解决办法:检查写的xpath(我写的xpath定位不准确)
- 报错信息:
executing adbExec
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command.
Original error: Error getting device platform version. Original error: Error executing adbExec.
Original error: 'Command 'E:\\adt-bundle-windows\\sdk\\platform-tools\\adb.exe -P 5037 -s xxxxxx(手机设备号) shell getprop ro.build.version.release' timed out after 200000ms'.
Try to increase the 200000ms adb execution timeout represented by 'adbExecTimeout' capability
在usb调试里,把OEM解锁权限打开,因为如果不给权限,它会把appium脚本阻挡在外,不给安装入手机,因为appium就是靠代码来控制手机里面注入的appium脚本(可以理解为木马),来实现自动控制,不安装根本跑不了,所以它会报执行错误,Error executing。
解决办法:检查手机开发者模式中的OEM开启了没,如果还不行,重启电脑或者手机
(吐血了,浪费了好多时间!!!!!!)