1. Text Location text
text ( "text text") loc = 'text ( "discovery")'
driver.find_element_by_android_uiautomator(loc).click()
2. Text a long time, you can use textContains fuzzy matching, as long as the text contains a matching content on it.
textContains ( "text text")
loc = 'textContains("发")'
driver.find_element_by_android_uiautomator(loc).click()
3.resourceId positioning
loc_id = 'resourceId("com.baidu.yuedu:id/webbooktitle")’
driver.find_element_by_android_uiautomator(loc_id).click()
4.class Name Positioning
class property on the page is generally not unique, mostly used in the plural positioning time. Such as by positioning the class attribute 'Top' is the subscript button 2
loc_class = 'className("android.widget.Button")'
driver.find_element_by_android_uiautomator(loc_class).click()
5.description positioning
desc = 'description("contenet-des属性")'
driver.find_element_by_android_uiautomator(desc).click
Integrated Positioning:
1.id text attribute combination
id_text = 'resourceId("com.baidu.yuedu:id/webbooktitle").text("发现")'
driver.find_element_by_android_uiautomator(id_text).click()
2.class text attribute combination
class_text = 'className("android.widget.TextView").text("发现")'
driver.find_element_by_android_uiautomator(class_text).click()
Father and son positioning childSelector
1. sometimes can not directly locate an element, but it's well positioned parent element, this time to locate the parent element, to find his son by the parent element.
For example: Do you really like a girl, but she did not direct contact. You have her father's contacts, so you can go first to her father, to find her.
son = 'resourceId("com.baidu.yuedu:id/rl_tabs").childSelector(text("发现"))'
driver.find_element_by_android_uiautomator(son).click()
Brothers positioning fromParent
1. Sometimes the parent element positioning is not good, but with his good positioning adjacent sibling, this time by siblings find child elements under the same parent element.
For example: Do you like a girl, but she did not direct contact. Your relationship with her brother buddies, so you'll be able to find her by her brother.
brother = 'resourceId("com.baidu.yuedu:id/lefttitle").fromParent(text("发现"))'
driver.find_element_by_android_uiautomator(brother).click()