Touch Events with Selenium on chrome

294 views
Skip to first unread message

Balaram Vineeth Venugopal.P

unread,
Oct 15, 2019, 4:04:41 PM10/15/19
to Selenium Users
Hi guys,

Is there a way to simulate touch events in chrome with the touchactions class
I can see that chrome has mobile emnulation as per this page on the chrome driver website

I get the following exception message :
Exception in thread "main" org.openqa.selenium.UnsupportedCommandException: touchFlick


Exception in thread "main" org.openqa.selenium.UnsupportedCommandException: touchFlick
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:24:21.231Z'
System info: host: 'SKYNET', ip: '10.181.6.82', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.2'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.http.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:218)
at org.openqa.selenium.remote.http.AbstractHttpCommandCodec.encode(AbstractHttpCommandCodec.java:117)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:152)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:35)
at org.openqa.selenium.remote.RemoteTouchScreen.flick(RemoteTouchScreen.java:96)
at org.openqa.selenium.interactions.touch.FlickAction.perform(FlickAction.java:54)
at org.openqa.selenium.interactions.CompositeAction.perform(CompositeAction.java:36)
at org.openqa.selenium.interactions.Actions$BuiltAction.perform(Actions.java:633)
at Test.main(Test.java:68)



With the following  code :

  public static void main(String[] args) {
    WebDriverManager.chromedriver().setup();
    Map<String, String> mobileEmulation = new HashMap<>();
    mobileEmulation.put("deviceName", "Nexus 5");
    ChromeOptions chromeOptions = new ChromeOptions();
    chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation);

    WebDriver driver = new ChromeDriver(chromeOptions);

    driver.get("https://www.google.com");

    WebElement element = driver.findElement(By.cssSelector("a[title=\"Google apps\"]"));
    element.click();
    WebElement element1 = driver.findElement(By.cssSelector("a[href*=\"/calendar\"]"));
    new TouchActions(driver).flick(element1, 0, 200, 0).build().perform();

  }


Is this a chrome issue?

Would appreciate some help with this. 
Thanks
Reply all
Reply to author
Forward
0 new messages