【问题标题】:How to enable device emulation mode (device mode) in chrome by default如何在chrome中默认启用设备仿真模式(设备模式)
【发布时间】:2017-04-22 02:20:43
【问题描述】:

如何在没有在开发工具中手动启用的情况下,通过设备模式模拟(将鼠标事件模拟为触摸屏事件)运行 chrome?

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

【问题讨论】:

    标签: google-chrome chromium touch-event device-emulation


    【解决方案1】:
    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/");
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-05
      • 1970-01-01
      • 2014-12-08
      • 2010-12-26
      • 2016-07-17
      • 1970-01-01
      • 2011-03-24
      相关资源
      最近更新 更多