appium獲取手機端頁面元素的操作:
a.AppiumDriver對象的findElementBy方法
b.AppiumDriver對象的driver.findElementByAndroidUIAutomator(方法參數)獲取元素
其中方法參數爲:newUiSelector().className(\""+className+"\").text(\""+text+"\")
或其他實現實例化UiSelector()的String字符串
c.手機屏幕webElement獲取座標並使用js腳本點擊座標
WebElement a = driver.findElementByClassName("");
intwidth = a.getSize().width;
intx = width/2;
inty = a.getLocation().y;
intheight = a.getSize().height;
for (int i = 0 ; i < 10 ; i ++){
avascriptExecutorjs = (JavascriptExecutor) driver;
Map<String, Serializable> element =new HashMap<String, Serializable>();
element.put("touchCount","1");
element.put("x", x);
element.put("y", y + i*height/10);
js.executeScript("mobile: tap",element);
}
d.遇到手機端元素爲webview的控件,參考:
http://blog.csdn.net/wyb199026/article/details/50958662