Google chrome 默认情况下如何在chrome中启用设备仿真模式(设备模式)

Google chrome 默认情况下如何在chrome中启用设备仿真模式(设备模式),google-chrome,chromium,touch-event,device-emulation,Google Chrome,Chromium,Touch Event,Device Emulation,如何使用设备模式模拟(将鼠标事件模拟为触摸屏事件)运行chrome,而无需在开发工具中手动启用它 最好更改标志或运行时参数。publicstaticvoidmain(String[]args){ public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "/Users/guolei/tmp/chromedriver"); Map<String, String&

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

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

publicstaticvoidmain(String[]args){
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/");
}
System.setProperty(“webdriver.chrome.driver”,“/Users/guolei/tmp/chromedriver”); Map mobileEmulation=new HashMap(); mobileEmulation.put(“deviceName”、“iPhone6”); ChromeOptions ChromeOptions=新的ChromeOptions(); 色度选项。设置实验选项(“移动模拟”,移动模拟); 添加参数(“开始最大化”); WebDriver驱动程序=新的ChromeDriver(chromeOptions); 驱动程序。获取(“http://m.taoche.com/"); }