“mobile: scroll” these gestures are deprecated with java client new versions.
driver.swipe, Touch Action class help in scrolling. Below code works for me in android. You can modify it as per your needs
public class TouchActions{
public static AndroidDriver<WebElement> _driver;
@BeforeClass
public void setUpAppium() throws InterruptedException, IOException {
DesiredCapabilities capabilities = new DesiredCapabilities();
AppCapabilitiesSetUp(capabilities);
_driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4725/wd/hub"), capabilities);
}
@Test
public void installAndLaunchSecondAppTest() throws InterruptedException{
// Wait for launced app to load
Thread.sleep(10000);
// Press Home Key to minimize launched app
_driver.sendKeyEvent(AndroidKeyCode.HOME);
Thread.sleep(3000);
// Press Menu button to view all installed app's
_driver.findElementByAccessibilityId("Apps").click();
// Using Touch Action Classes
TouchAction tAction=new TouchAction(_driver);
int startx = _driver.findElement(By.name("Email")).getLocation().getX();
int starty = _driver.findElement(By.name("Email")).getLocation().getY();
int endx = _driver.findElement(By.name("Dev Settings")).getLocation().getX();
int endy = _driver.findElement(By.name("Dev Settings")).getLocation().getY();
System.out.println(startx + " ::::::: " + starty + " ::::::: " + endx + " ::::::: " + endy);
//First tap on the screen and swipe it right using moveTo function
tAction.press(startx+20,starty+20).moveTo(endx+20,endy+20).release().perform();
Thread.sleep(1000);
//Second tap on the screen and swipe it left using moveTo function
tAction.press(endx+20,endy+20).moveTo(startx+20,starty+20).release().perform();
Thread.sleep(1000);
}
@AfterClass(alwaysRun=true)
public void teardown(){
_driver.closeApp();
_driver.quit();
}
public DesiredCapabilities AppCapabilitiesSetUp(DesiredCapabilities cap){
cap.setCapability(CapabilityType.BROWSER_NAME,"");
cap.setCapability("platformVersion","4.4.4");
cap.setCapability("platformName","Android");
cap.setCapability("deviceName","emulator-5554");
cap.setCapability("appPackage","appPackage");
cap.setCapability("appActivity","appActivity");
return cap;
}
}