Emulating devices on Chrome browser using selenium

How can I emulate mobile devices on Chrome browser ?

For mobile emulation you can use the following capability in your test script using Chrome options :

Map<String, String> mobileEmulation = new HashMap<>(); mobileEmulation.put("deviceName", "Nexus 5");

ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation); WebDriver driver = new ChromeDriver(chromeOptions);

The above code is in Java, to know more on Mobile emulation you can visit: https://chromedriver.chromium.org/mobile-emulation


I was also looking for the same. Thank you so much @vishnukdas for the solution.

1 Like