当前位置:网站首页>Appium 滑动问题

Appium 滑动问题

2022-08-02 07:14:00 51CTO


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();
}
}
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://blog.51cto.com/u_14754853/5535102