美文网首页
appium常用定位元素方式

appium常用定位元素方式

作者: lwlwlwlw | 来源:发表于2019-12-31 17:52 被阅读0次

appium常用定位元素方式

一、id定位 

方法:find_element_by_id("id_value")     #id_value为元素的id属性值

二、class定位

方法:find_element_by_class_name("class_value")     # class_value 为元素的class属性值

三、xpath表达式定位

方法:find_element_by_xpath("xpath_value")     # xpath_value 为可以定位到元素的xpath语句

android端xpath常用属性定位

1,id: //*[contains(@resource-id,'id_value')]

find_element_by_xpath("//*[contains(@resource-id,'id_value')]")

2,class://*[contains(@class,'class_value')]

find_element_by_xpath("//*[contains(@class,'class_value')]")

3,text://*[contains(@text,'text')]

find_element_by_xpath("//*[contains(@text,'text')]")

定位一组元素

butt = driver.find_elements_by_class_name("android.widget.TextView")

for i in butt:

    if i.text == "收藏":

        i.click()

        break

相关文章

网友评论

      本文标题:appium常用定位元素方式

      本文链接:https://www.haomeiwen.com/subject/pckioctx.html