Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to scroll using coordinates with appium

im trying to scroll in a native android app by using the method below

Dimension size = driver.manage().window().getSize();
int starty = (int) (size.height * 0.80);
int endy = (int) (size.height * 0.20);
int startx = size.width / 2;

driver.swipe(startx, starty, startx, endy, 3000);
Thread.sleep(2000);

but at driver.swipe it gives me an error that says

The method swipe(int, int, int, int, int) is undefined for the type AndroidDriver

can anyone help me fix this? i have been searching forever trying to find a solution but i have had no luck.

like image 253
dam1ne Avatar asked Sep 17 '25 07:09

dam1ne


1 Answers

You can use TouchAction instead .swipe:

TouchAction action = new TouchAction(driver);
action.press(x, y).moveTo(x, y).release().perform();

You can also implement x y with PointOption, like this:

  1. .press(new PointOption().withCoordinates(x, y))

    Or

  2. .press(PointOption.point(x, y))

Following import:

import io.appium.java_client.TouchAction;

TouchAction

PointOption

like image 195
frianH Avatar answered Sep 19 '25 21:09

frianH