2

How to run chrome with device mode emulation (emulating mouse events as touch screen events) without manually enabling it in dev tools?

Preferably with a flag change or a run time parameter change.

udnisap
  • 899
  • 1
  • 10
  • 19

1 Answers1

0
public static void main(String[] args) {
    System.setProperty("webdriver.chrome.driver", "/Users/guolei/tmp/chromedriver");
    Map<String, String> mobileEmulation = new HashMap<>();

    mobileEmulation.put("deviceName", "iPhone 6");

    ChromeOptions chromeOptions = new ChromeOptions();
    chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation);
    chromeOptions.addArguments("start-maximized");

    WebDriver driver = new ChromeDriver(chromeOptions);

    driver.get("http://m.taoche.com/");
}
Sunni Sun
  • 16
  • 2