如何使用设备模式模拟运行chrome(将鼠标事件模拟为触摸屏事件)而无需在开发工具中手动启用它?
最好使用标志更改或运行时参数更改。
答案 0 :(得分: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/");
}