I'm doing some mobile UI testing using Selenium in a .Net environment using c#.
I'm able to do testing quite successfully using the chrome mobile emulation in portrait mode, but I can not found how to put the emulation in Landscape mode.
I would like to be able to programmatically rotate during testing but through research it appears this is not possible yet.
Working in Portrait mode.
ChromeOptions chromeCapabilities = new ChromeOptions();
chromeCapabilities.EnableMobileEmulation("Apple iPhone 6");
ChromeDriverService service = ChromeDriverService.CreateDefaultService(@"C:\chromedriver");
IWebDriver driver = new ChromeDriver(service, chromeCapabilities);
driver.Navigate().GoToUrl("www.google.com");
However how do I put the iPhone emulation in to a landscape orientation?
I have tried this but it does't work and the browser opens without the size limitations
ChromeMobileEmulationDeviceSettings CMEDS = new ChromeMobileEmulationDeviceSettings();
CMEDS.Width = 66;
CMEDS.Height = 37;
CMEDS.PixelRatio = 1.0;
CMEDS.UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25";
ChromeOptions chromeCapabilities = new ChromeOptions();
chromeCapabilities.EnableMobileEmulation(CMEDS);
ChromeDriverService service = ChromeDriverService.CreateDefaultService(@"C:\chromedriver");
IWebDriver driver = new ChromeDriver(service, chromeCapabilities);
driver.Navigate().GoToUrl("www.google.com");
Any help or advice greatly received!! Thanks in advance
From what I understand, it is not possible to change the screen orientation at the moment.
Here is a related open issue:
There are some and few hints in the source code that got me thinking that it might be possible to have a "landscape" oriented emulated device by adding a custom brand new device (how to add a device programmatically is an open question though).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With