要使用Appium的TouchAction进行滚动,可以按照以下步骤进行操作:
import io.appium.java_client.MobileElement;
import io.appium.java_client.TouchAction;
MobileElement element = (MobileElement) driver.findElement(By.xpath("Your XPath here"));
TouchAction action = new TouchAction(driver);
action.press(element);
action.waitAction(Duration.ofMillis(1000));
action.moveTo(x, y);
action.release();
action.perform();
完整的代码示例:
import io.appium.java_client.MobileElement;
import io.appium.java_client.TouchAction;
MobileElement element = (MobileElement) driver.findElement(By.xpath("Your XPath here"));
TouchAction action = new TouchAction(driver);
action.press(element);
action.waitAction(Duration.ofMillis(1000));
action.moveTo(x, y);
action.release();
action.perform();
请注意,以上示例中的"Your XPath here"和(x, y)需要根据实际情况进行替换。