Selenium script to run on mobile mode of chrome Desktop

First step, you can launch mobile mode with chrome developer tool :


public static void main(String[] args) {

// DeviceName = "Google Nexus 5";
// DeviceName = "Samsung Galaxy S4";
// DeviceName = "Samsung Galaxy Note 3";
// DeviceName = "Samsung Galaxy Note II";
// DeviceName = "Apple iPhone 4";
DeviceName = "Apple iPhone 5";
// DeviceName = "Apple iPad 3 / 4";
// String ChromeDriverPath = System.getProperty("user.dir") + "/lib/chromedriver.exe";
// System.setProperty("", ChromeDriverPath);

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

Map<String, Object> chromeOptions = new HashMap<String, Object>();
chromeOptions.put("mobileEmulation", mobileEmulation);

capabilities =;
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
WebDriver driver = new ChromeDriver(capabilities);



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.