APP元素定位操作(APP端自动化测试)

APP元素定位操作:

namevalue
id属性值id属性值
classclass属性值
xpathxpath表达式

前置代码:

from appium import webdriver
# server 启动参数
desired_caps = {}
# 设备信息
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1'
desired_caps['deviceName'] = '192.168.56.101:5555'
# app的信息
desired_caps['appPackage'] = 'com.android.settings'
desired_caps['appActivity'] = '.Settings'

# 声明我们的driver对象
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)

通过xpath定位:

*** android端xptah常用属性定位:
1. id ://[contains(@resource-id,‘com.android.settings:id/search’)]
2. class ://
[contains(@class,‘android.widget.ImageButton’)]
3. text ://*[contains(@text,‘WLA’)]

*** 模糊定位 contains(@key,value): value可以是部分值
另一种方式:find_element_by_xpath("//*[(@text=‘继续’)]")

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值