【Mac + Appium + Python3.6学习(五)】之常用的Android自动化测试API总结
Github测试样例地址:https://github.com/appium-boneyard/sample-code/tree/master/sample-code/examples
①定位text,通过UiSelector定位
# text定位
self.d.find_element_by_android_uiautomator("new UiSelector().text(\"手机相册\")").click() ②中文输入问题,输入中文不显示:
《appium自动化不能输入中文的解决办法》
# 在参数设置中配置:"unicodeKeyboard": True, "resetKeyboard": True
如果一直弹unicode框提示重新安装,则参考我的另一篇文章《【Mac + Appium学习(二)】之Android自动化测试,appium-desktop配置和简易自动化测试脚本》(第一节第4小点)
# 配置完成之后再运行,还是采取UiSelector定位self.d.find_element_by_android_uiautomator("new UiSelector().text(\"请输入内容\")").send_keys("安全隐患") 但是又发现变为乱码了,参考解决办法:《appium+python自动化61-中文输入乱码问题解决》
1.将unicodeKeyboard和resetKeyboard参数设置为True 2.手机设置设置-语言与输入框,Appium Android Input Manager for Unicode设置默认
③父子级定位
待续
④滑动:
《appium\selenium+python 滑动屏幕直至某元素出现》
⑤获取相同元素的最后一个元素定位:
# 元素1
list = self.d.find_elements_by_id("cn.sqm.citymine_safety:id/item_tv_personnel_name")
num = len(list)
list[num-num].click()
self.d.find_element_by_android_uiautomator("new UiSelector().text(\"xxx\")").click()
self.d.find_element_by_id("cn.sqm.citymine_safety:id/tv_complete").click()
# 元素2
list = self.d.find_elements_by_id("cn.sqm.citymine_safety:id/item_tv_personnel_name")
num = len(list)
list[num-1].click()
⑥其他常用元素定位请参考:
《Github-Appium提问网址》
《Appium Appium Python API 中文版 By-HZJ》*
《appium+python自动化30-list定位(find_elements)》
《Appium python+appium 如何判定某元素存在》
《appium定位相同属性的元素》
《Appium+Python 自动化-appium常用元素定位方法》
《appium\selenium+python 滑动屏幕直至某元素出现》
《Appium学习路—Android定位元素与操作》
《Appium python自动化测试系列之元素的定位(六)》
《python+appium-desktop:安卓(android)7.0以上使用appium无法定位元素(无法refresh)且 无法运行脚本》
《Appium 在 Android UI 测试中的应用》
转自:https://www.cnblogs.com/Owen-ET/p/9970965.html
转载于:https://www.cnblogs.com/dreamhighqiu/p/10990014.html
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
