问题:
1.如何通过content-desc属性定位元素
2.如何获取content-desc文本内容
解决1:
通过driver.find_element_by_accessibility_id()方法,可定位元素(其实就是name属性,ios与Android均可以此方法定位元素)
driver.find_element_by_accessibility_id('搜索或输入网址')
解决2:
title = driver.find_element_by_accessibility_id('搜索或输入网址')
if title is not None:
print(title.get_attribute(name='content-desc')+'======1')#搜索或输入网址======1
print(title.get_attribute('name')+'======2')#text中的内容======2
print(title.text+'======3')#text中的内容======3
print('OK')
else:
print('False')
更多推荐
appium如何如何通过content-desc属性定位元素并且获取content-desc文本内容
发布评论