Shane Gleeson
Shane Gleeson

Reputation: 75

Alternative ways of swiping in Appium without inputting x and y co-ordinates?

I have a scroll bar but want it to find the element without having to input x and y co-ordinates all the time is there a way of doing so?

WebElement start = androidDriver.findElement(By.id("........."));
TouchAction action = new TouchAction(androidDriver);
action.longPress(start).moveTo(202,120).release().perform();

Upvotes: 0

Views: 427

Answers (1)

Shahid
Shahid

Reputation: 2330

There can be one alternative way to scroll without co-ordinates, if you have two elements. From one element scrolling will start and to the other scrolling will stop. This will look like:

WebElement start = androidDriver.findElement(By.id("id_of_the_start_element"));
WebElement end = androidDriver.findElement(By.id("id_of_the_end_element"));
TouchAction action = new TouchAction(androidDriver);
action.press(start).moveTo(end).release().perform();

Upvotes: 1

Related Questions