Mobile emulation in Chrome using Selenium Webdriver | Selenium Forum
M
Posted on 23/11/2015
Hi, I am automating the mobile emulator screen using Selenium webdriver in Chrome. I am not able to figure out how to change the screen orientation from Portrait to Landscape or vice versa using desired capabilities.I tried giving below code, but none did worked out. Can any of you please help out?

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(CapabilityType.ROTATABLE, true);
capabilities.setCapability("deviceOrientation","landscape");
WebDriver driver = new ChromeDriver(capabilities);

Tried using javascript executor as well, but no luck.

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("target.setDeviceOrientation(UIA_DEVICE_ORIENTATION_LANDSCAPE);");
js.executeScript("target.setDeviceOrientation(UIA_DEVICE_ORIENTATION_PORTRAIT);");

Any suggestions?


Thanks,
Subhasis

M
Replied on 24/11/2015

i don't think its possible.