I wrote some Javascript code with the touchstart
and touchmove
event. I want to test it using Selenium. I just discovered the TouchActions class with t
So, to be able to do that, one needs to first add the mobile capability to the driver (see Mobile Emulation):
Map<String, String> mobileEmulation = new HashMap<>();
mobileEmulation.put("deviceName", "Galaxy S5"); // Choose a device available in your version of chromimum
Map<String, Object> options = new HashMap<>();
options.put("mobileEmulation", mobileEmulation);
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
RemoteWebDriver remoteWebDriver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
Then at the moment you need the touch actions, you need to "augment" the driver, to be able to cast it:
TouchActions builder = new TouchActions(new Augmenter().augment(remoteWebDriver));
Then from that builder you can do builder.down(), move(), scroll(), up()...
whatever you need.