2

如何使用设备模式仿真(将鼠标事件模拟为触摸屏事件)运行 chrome 而无需在开发工具中手动启用它?

最好使用标志更改或运行时参数更改。

4

1 回答 1

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/");
}
于 2017-12-18T09:53:20.580 回答