Код: Выделить всё
Dimension ScreenSize = driver.manage().window().getSize();
// System.out.println(ScreenSize);
// Current device size (720, 1465) //
//Finding Starting point/mid of the screen size
int Xaxis = ScreenSize.getWidth() / 2;
int Yaxis = ScreenSize.getHeight() / 2;
//Finding End Point of the finger swipe
//In this we assumpting the size of 1000 and diving in 4 sides. So, 250 1 4th of the screen size
int Xend = Xaxis;
int Yend = (int) (ScreenSize.getHeight() * 0.25);
//Adding the pointer then using to create a Sequence
PointerInput Touch = new PointerInput(PointerInput.Kind.TOUCH, "Touch");
//Adding the Sequence of Action
Sequence Action = new Sequence(Touch, 0);
for (int i = 0; i < 5; i++) {
Action.addAction(Touch.createPointerMove(Duration.ZERO, PointerInput.Origin.viewport(), Xaxis, Yaxis))
.addAction(Touch.createPointerDown(PointerInput.MouseButton.LEFT.asArg()))
.addAction(new Pause(Touch, Duration.ofSeconds(1)))
.addAction(Touch.createPointerMove(Duration.ofMillis(1000), PointerInput.Origin.viewport(), Xend, Yend))
.addAction(Touch.createPointerUp(PointerInput.MouseButton.LEFT.asArg()));
try {
driver.perform(Collections.singletonList(Action));
Thread.sleep(1000); // Pause between scrolls
} catch (Exception e) {
e.printStackTrace();
// Handle or log the exception as needed
}
}
Thread.sleep(3000); // Wait at the end
Исследовал, менял скрипт, добавлял Thread.sleep и многое другое, но безрезультатно.
Подробнее здесь: https://stackoverflow.com/questions/787 ... ice-appium
Мобильная версия