Getting error while using mobile:swipe method for automating android phone

I am getting error when using the the code snippet given in appium document

JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, Double> swipeObject = new HashMap<String, Double>();
swipeObject.put(“startX”, 0.95);
swipeObject.put(“startY”, 0.5);
swipeObject.put(“endX”, 0.05);
swipeObject.put(“endY”, 0.5);
swipeObject.put(“duration”, 1.8);
js.executeScript(“mobile: swipe”, swipeObject);

As I am using RemoteWebDriver I am not able to use driver.swipe method is there any other way I could do it?

Please use appiumdriver and do swipe like below :

First declare driver as appium driver and then instead of remote web driver do :

 driver = new AndroidDriver(new URL(""), capabilities);  

Then for swipe you can easily use :

 driver.swipe(require co-ordinates);

Above will work for sure.

As I mentioned I am Using RemoteWebDriver working on framework and I cann’t use the AndroidDriver or IOSDriver. Do you know any way to make the swipe work with RemoteWebDriver.


U can cast RemoteWebDRiver to AndroidDriver…


import java.util.concurrent.TimeUnit;

import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class demo {
private AndroidDriver driver;

public void setup() throws Exception {

    DesiredCapabilities capabilities = new DesiredCapabilities();

    driver = (AndroidDriver) new RemoteWebDriver(new URL(""),


public void test() throws Exception {

    driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);


thanks sudhanvam,
But i am getting exception while using this I tried this before. and is there a ways to do it just reverse of this – (RemoteWebDriver) new AndroidDriver(new URL(“”),

I think swipe will work with android driver only…