我正在使用以下代码进行滚动:
eclipse没有错误,但是在执行过程中,我在第一行本身就遇到了“ java.lang.ClassCastException:java.lang.NoSuchMethodError无法转换为java.lang.Exception”错误。它没有执行第二行。请帮忙。
Appium版本:1.10.0 Java客户端:6.1.0
TouchAction操作=新的TouchAction((MobileDriver)driver.getWebDriver()); action.press(PointOption.point(startx,starty))。waitAction(WaitOptions.waitOptions(Duration.ofMillis(50)))。action.moveTo(PointOption.point(startx,endy))。release()。perform() ;
答案 0 :(得分:0)
这是我的滑动方法。它适用于Appium的6.1.0和7.0.0版本。 您可以使用此代码。
public void swipeWithRatio(int startXRatio, int startYRatio, int endXRatio, int endYRatio, int durationMiliSec) {
Dimension d = getPhoneSize();
int height = d.height;
int width = d.width;
int swipeStartWidth = (width * startXRatio) / 100;
int swipeStartHeight = (height * startYRatio) / 100;
int swipeEndWidth = (width * endXRatio) / 100;
int swipeEndHeight = (height * endYRatio) / 100;
new TouchAction(driver)
.press(point(swipeStartWidth, swipeStartHeight))
.waitAction(waitOptions(Duration.ofMillis(durationMiliSec)))
.moveTo(point(swipeEndWidth, swipeEndHeight))
.release()
.perform();
}
// Swipe from up to down example
// It starts from 25 percent of the screen and continues to 75 percent.
swipeWithRatio(50,25,50,75,2000);
// Swipe from down to up example
// It starts from 75 percent of the screen and continues to 25 percent.
swipeWithRatio(50,75,50,25,2000);