1.id定位
使用Appium Inspector找到控件的resource-id
androidDriver.findElementById("com.tencent.edu:id/fe").click();
2.class定位
使用Appium Inspector找到控件的class
class会出现重名的情况,获取所有的class,存放在list中,再使用get
List<WebElement> listclass = androidDriver.findElementsByClassName("android.widget.TextView");
listclass.get(4).click();
3.xpath定位
使用Appium Inspector找到控件的class,使用相对定位
androidDriver.findElementByXPath("//android.widget.TextView[@text='手机号']").click();
4.text定位
使用Appium Inspector找到控件的text
findElementByAndroidUIAutomator需使用 JER System Library1.8
androidDriver.findElementByAndroidUIAutomator("new UiSelector().text(\"手机号\")").click();