1. 程式人生 > >獲取App上的元素(幾種方法)

獲取App上的元素(幾種方法)

一、java-UISelector()-正則表示式連用: code = ‘new UISelector().text(“我的”).className(“android.widget.TextView”)’ ——注意點:把java語法當成字串賦值給code,java語法中必須用雙引號。 ele = driver.find_element_by_android_uiautomator(code) ——注意點:by_android_uiautomator(),code作為引數,ele就是想找到的元素,可以對ele進行clink()等操作。

——textcontains(“的”),是指包含什麼內容;textMatches(".*的"

)UISelector().UISelector().textMatches("."),是指模糊查詢,UISelector().下面的方法的引數可以用正則表示式,例如:UISelector().textMatches(".*的")。 二、xpath 三、id,class_name 工具:appium、uiautomatorviewer