How To Use UIAutomator For Appium Testing
你或許會想問:
除了Appium提供的 元件定位方法, 還有其他的選擇嗎?
The answer is "YES", 那就是使用UIAutomator
UI Automator 提供的Locator方法
比較常用的有:- ResourceId
- Content-description
- Text
- By ClassName
- By className + index
- By Xpath
ResourceId
driver.find_element_by_android_uiautomator('new UiSelector().resourceId("com.android.calculator2:id/digit_8")')
Content-description
driver.find_element_by_android_uiautomator('new UiSelector().description("plus")')
Text
driver.find_element_by_android_uiautomator('new UiSelector().text("9")')
className
find_elements_by_android_uiautomator('new UiSelector().className("android.widget.EditText")')
className + index
這招好用, 要牢記
driver.find_element_by_android_uiautomator('new UiSelector().className("android.widget.Button").index(11)')
Comments
Post a Comment