appium中Xpath定位

xpath定位

xpath定位是一种路径定位方式,主要是依赖于元素绝对路径或者相关属性来定位,但是绝对路径xpath执行效率比较低(特别是元素路径比较深的时候),一般使用比较少。通常使用xpath相对路径和属性定位。

 

实践案例

使用xpath定位元素来进行登录操作。

by_xpath.py

from find_element.capability import driver

 

driver.find_element_by_xpath('//android.widget.EditText[@text="请输入用户名"]').send_keys('zxw1234')

 

driver.find_element_by_xpath('//*[@class="android.widget.EditText" and @index="3"]').send_keys('zxw123456')

 

driver.find_element_by_xpath('//android.widget.Button').click()

 

# driver.find_element_by_xpath('//*[@class="android.widget.Button"]').click()

猜你喜欢

转载自www.cnblogs.com/wyx1990/p/12907188.html
今日推荐