I am trying to automate the mobile emulator that chrome provides in selenium, however, the issues that I am facing at the moment are that the browser opens up with the wrong device metrics, I am trying to set the height and width specifically but without any luck here is my code:
Map<String, Object> deviceMetrics = new HashMap<String, Object>();
deviceMetrics.put("width", 360);
deviceMetrics.put("height", 640);
Map<String, Object> mobileEmulation = new HashMap<String, Object>();
mobileEmulation.put("deviceMetrics", deviceMetrics);
mobileEmulation.put("deviceName", "Nexus 5");
Map<String, Object> chromeOptions = new HashMap<String, Object>();
chromeOptions.put("mobileEmulation", mobileEmulation);
DesiredCapabilities capabilityMob = DesiredCapabilities.chrome();
capabilityMob.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
this.driver = new RemoteWebDriver(_url, capabilityMob);
However I am getting the following error:
org.openqa.selenium.WebDriverException: unknown error: cannot parse capability: chromeOptions from unknown error: cannot parse mobileEmulation from unknown error: 'deviceName' must be used alone