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.youkuaiyun.com/wyb199026/article/details/50958662