chrome
System.setProperty("webdriver.chrome.driver", "./exe/chromedriver.exe");
Map<String, String> mobileEmulation = new HashMap<>();
mobileEmulation.put("deviceName", "iPhone 5/SE");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("mobileEmulation", mobileEmulation);
WebDriver driver = new ChromeDriver(chromeOptions);
Dimension targetSize = new Dimension(500,1500);
driver.manage().window().setSize(targetSize);
driver.get("http://www.google.com/xhtml");
edge
System.setProperty("webdriver.edge.driver", "./exe/msedgedriver.exe");
WebDriver driver = new EdgeDriver();
Dimension targetSize = new Dimension(320,1500);
driver.manage().window().setSize(targetSize);
driver.get("http://www.google.com/xhtml");
firefox
System.setProperty("webdriver.gecko.driver", "./exe/geckodriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver();
Dimension targetSize = new Dimension(320,1500);
driver.manage().window().setSize(targetSize);
driver.get("http://www.google.com/xhtml");