首页 > 移动平台 > 详细

appium元素定位以及启动

时间:2021-09-11 11:04:18      阅读:48      评论:0      收藏:0      [点我收藏+]

一.获取包名

adb shell dumpsys window windows | findstr mFocusedApp

技术分享图片

com. wuba 就是包名

.activity.launch.launchActivity t68 启动入口

斜杠前面包名斜杠后面执行入口

二.Capability配置

配置文档地址

http://appium.io/docs/en/writing-running-appium/caps/index.html

基础配置

{

  "platformName": "Android",

  "platformVersion": "5.1.1",

  "deviceName": "127.0.0.1:62025",

   "automationName": "UiAutomator1",

  "appPackage": "com.tal.kaoyan",

  "appActivity": "com.tal.kaoyan.ui.activity.SplashActivity",

  "noReset": true

}

公用配置

技术分享图片

三,Appium常用元素定位方法

常用id定位,xpath定位

id定位,name定位(text定位),class_name定位,
accessibility_id定位,xpath定位

技术分享图片

 

1. id定位 根据元素的resource-id(与id一样)属性值进行定位
2. name定位 根据元素的text属性值进行定位 Appium1.5之后移除了这种方式
3. class_name定位 根据元素的class属性值进行定位
4. accessibility_id定位 根据元素的content-desc属性值进行定位Android IOS->labelname属性)
5. xpath定位 uiautomatorview没有xpath路径,inspector有,可以直接复制
? appium中使用xpath定位需要自己去写xpath路径
? Xpath用法:find_element_by_xpath("//标签名[@属性名称=‘属性值‘]")
? 如:find_element_by_xpath("//android.widget.TextView[@text=‘同意‘]")
? 如:find_element_by_xpath("//*[@text=‘电子邮件‘]") 星号表示模糊匹配

 

 

 

 

 


appium元素定位以及启动

原文:https://www.cnblogs.com/mik-hello/p/15253306.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!