做一个被尊重的测试工程师
Appium 滑动问题
上一篇 /
下一篇 2014-08-10 19:02:42
/ 个人分类:Appium
//根据方向滑动
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "left");
scrollObject.put("element", ((RemoteWebElement) element).getId());
js.executeScript("mobile: scroll", scrollObject);
//根据坐标滑动
public void swipe() {
try {
Thread.sleep(2000);
} catch (Exception e) {
e.printStackTrace();
}
JavascriptExecutor js = (JavascriptExecutor) dr;
HashMap<String, Double> swipeObj = new HashMap<String, Double>();
swipeObj.put("startX", 420.0);
swipeObj.put("startY", 400.00);
swipeObj.put("endX", 30.0);
swipeObj.put("endY", 400.0);
swipeObj.put("duration", 0.4);
// 4个滑动页面
for (int i = 0; i < 3; i++) {
try {
js.executeScript("mobile: swipe", swipeObj);
} catch (WebDriverException ex) {
ex.printStackTrace();
}
}
}
相关链接:http://www.51testing.com/html/13/n-863113.html
收藏
举报
TAG:
appium滑动