Monday, 20 June 2016

Executing the selenium tests on iPhone 5 and 6S using mobile emulation in Chrome

Below example illustrates how to execute the Selenium tests on iPhone 5 S using mobile emulation feature provided in chrome. Similarly we can run tests on other devices like Apple iPad, Google Nexus 5 etc.

package browsertests;

import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.util.HashMap;
import java.util.Map;

 * Created by sagar on 06-12-2015.
public class MobileEmulationOnChrome {
            public void launchChrome() {
        Map<String, String> mobileEmulation = new HashMap<String, String>();
       // mobileEmulation.put("deviceName", "Google Nexus 5");
        mobileEmulation.put("deviceName", "Apple iPhone 5");
        //mobileEmulation.put("deviceName", "Apple iPad");
        Map<String, Object> chromeOptions = new HashMap<String, Object>();
        chromeOptions.put("mobileEmulation", mobileEmulation);

        DesiredCapabilities capabilities =;
        capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

        WebDriver driver = new ChromeDriver(capabilities);

What do you think on above selenium topic. Please provide your inputs and comments. You can write to me at

No comments:

Post a Comment

Buy Best Selenium Books