安卓Appium采坑记录

1. Error: Unable to find an active device or emulator with OS 7.0.0. The following are available: emulator-5554 (7.0)

用adb devices 命令查看安卓真机或者模拟器的设备名称,见下图的
在这里插入图片描述

2. 输入汉字乱码显示

原因一:代码上的修改如图,在汉字前面加个u在这里插入图片描述
原因二:安装Appium Android Input Manager for Unicode、
安卓手机系统语音默认设置为Appium Android Input Manager for Unicode;注意:华为手机系统设置了这个输入法之后,手动操作手机键盘无法调出
在这里插入图片描述

3. Appium 每次执行用例提示Appium Android Input Manager for Unicode 问题

按照下面的链接更改appium的android-helpers.js文件
https://www.jianshu.com/p/1878cd713106

4. 无法定位元素,安卓7.0版本会出现元素定位不到问题

原因一:在desired_caps中配置’automationName’: ‘uiautomator2’,
原因二:运行出现错误如下错误
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate.
解决办法:win10上带了管理员功能,将appium关闭,以管理员身份运行appium

5. selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy ‘name’ is not supported for this session

a、这句话的意思是不支持‘name’查找元素,更改appium源码,到appium安装目录下,C:\Program Files (x86)\Appium\resources\app\node_modules\appium\node_modules\appium-android-driver\build\lib
更改driver.js,加上name即可
this.locatorStrategies = [‘xpath’, ‘id’, ‘class name’, ‘accessibility id’, ‘-android uiautomator’,‘name’];

https://blog.csdn.net/fox990152806/article/details/79081622
b、查看元素属性clickable是否为true,false不可点击,true可点击
安卓Appium采坑记录_第1张图片

6、appium自动化测试APP,APP内一直提示手机的相册或者存储弹窗权限

把desired_caps加上这个’autoGrantPermissions’: True,

7、升级appium之后,运行报错找不到io.appium.uiautomator2.server.test等问题

Unable to find instrumentation target ‘io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner’: The instrumentation target is not listed by Package Manager
升级appium之后出现这个问题,具体原因不知道,应该是按装到手机上的io.appium.uiautomator2.server.test和以前的appium版本冲突的问题
解决办法:把手机上安装的io.appium.uiautomator2.server,io.appium.uiautomator2.server.test,卸载(adb uninstall io.appium.uiautomator2.server),重新运行项目安装一遍之后,成功运行

7、使用xpath定位不到元素

原因一:检查下,是不是把find_element_by_xpath,写成了find_elements_by_xpath 这两个是不一样的!!!!

8、appium录制脚本,提示An unknown server-side error occurred while processing the command. Original error: You must include a platformName capability

在这里插入图片描述
查看DesriedCapabilities中红色线标记首字母要大写,因为python的项目中是小写的,直接复制过来搞了半天是这样原因 安卓Appium采坑记录_第2张图片

9、小米手机连接appium报错,手机连接权限问题,检查开发者选项打开问题

An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: ‘Command ‘F:\java\android-sdk-windows\platform-tools\adb.exe -P 5037 -s xxxxxx shell pm clear aaaaaaaa’ exited with code 1’; Stderr: ‘Error: java.lang.SecurityException: PID 10774 does not have permission android.permission.CLEAR_APP_USER_DATA to clear data of package aaaaaaaa’; Code: ‘1’
开发者选项中,除了开启开发者选项打开和打开USB调试、还要打开USB调试(安全设置)
安卓Appium采坑记录_第3张图片

selenium错误

https://blog.csdn.net/mufenglin01/article/details/72627675

你可能感兴趣的:(python)