標籤:
1.通過ID尋找
尋找1個:WebElement el=driver.findElement(By.id("com.aurora:id/aurora_action_bar_item"));
列表: List<WebElement> e3=driver.findElements(By.id("com.aurora:id/aurora_menu_item_text")); 可能會報錯
2.通過name尋找
列表:
單個:WebElement el = driver.findElement(By.name("Add Contact"));
driver.findElementByName("Save").click();
3.通過uiautomator定位
尋找1個:driver.findElementByAndroidUIAutomator("new UiSelector().clickable(true)").click();
el = driver.findElementByAndroidUIAutomator("new UiSelector().text(\"Add note\")");
列表:driver.findElementsByAndroidUIAutomator("new UiSelector().clickable(true)").click();
4.通過Classname尋找
列表:List<WebElement> textFieldsList = driver.findElementsByClassName("android.widget.EditText");
單個:el = driver.findElementByClassName("android.widget.TextView");
5.通過content-desc(AccessibilityId)尋找
單個:el = driver.findElementByAccessibilityId("menu_add_note_description");
列表:findElementsByAccessibilityId()
6.findElementByTagName
el = driver.findElementByXPath("//android.widget.TextView[contains(@text,‘Add note‘)]");
appium查看控制項的方法