How to swipe across screens for Android in Appium?

I want to swipe across screens with Appium in Android. The swiping is across and I want to traverse each screen and perform actions on it. Any help would be appreciated!

There are several ways to swipe in Appium. Here is the method we wrote in Ruby to make the call a bit simpler:

def swipe(start_x, start_y, end_x, end_y)
  action = start_x, y: start_y).wait(10).move_to(x:end_x, y:end_y).wait(50).release(x: end_x, y: end_y)

You’ll need to determine start and end values for x and y. In the example below, we want to swipe across a tab element in the Android settings.

  tab = appium.driver.find_element(:id, '')
  dimensions = apm.appium_module.window_size
  max_x = dimensions.width - 1
  swipe(max_x, tab.location.y + 5, tab.location.x, tab.location.y + 5)

Hi Will…thanks for your update on the same…but I need a Java code for the issue.

  1. Swiping from top to bottom (Tried the conventional x,y coordinate approach but dint work)
  2. Swiping across the screens.

Help is much appreciated.

You can look at the source for the java implementation at here are some of the pertinent lines from the Java TouchAction Header:

  • The flow is to chain individual touch actions into an entire gesture. e.g.
  • TouchAction action = new TouchAction(driver);

Thanks Will for the update on the answer. Things started to work with Scrollto and swipe functions with the new Java Client library

Better approach, less verbose is the following{start_x: 0.8, start_y: 0.5, end_x:0.2, end_y: 0.5, duration: 500}).perform
1 Like