appium查看控件的方法

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')]"); 

原文地址:https://www.cnblogs.com/penghong2014/p/4269862.html