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

问题描述 投票:2回答:1

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

优选地,具有标志改变或运行时参数改变。

google-chrome chromium touch-event device-emulation
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/");
}
© www.soinside.com 2019 - 2024. All rights reserved.