When I connect to my Windows Server 2012R2 Azure VM via RDP, I have resolution 1600x900, which corresponds to my client PC resolution. However, when I run selenium UI tests on this machine with VSO agent, they are failing because screen resolution for agent session is 1024x768. In Device manager I can see that display adapter is Microsoft Hyper-V Video. When I access Screen Resolution section when connected via RDP, I can see only my resolution selected and grayed out and also message "The display settings can't be changed from a remote session". Is it possible to change default screen resolution for Windows Server 2012R2 running on Azure VM? I tried adding DefaultSettings.XResolution and DefaultSettings.YResolution values to registry but it didn't help.
2 Answers
Try loading the site in an iFrame and declaring the width/height attributes in the iFrame tag. The resulting window opens outside the boundary of the viewable desktop resolution and allows testing more screen resolutions than the desktop resolution would otherwise support.
Calling the iFrame:
driver.Navigate().GoToUrl("file:///E:/iframe.html");
Example iFrame content:
<iframe id="theiframe" src="https://www.SomeSiteToTest.com" width=1800 height=750 align="center" frameBorder="0" ></iframe>
Switch the Selenium driver focus over to the iFrame:
driver.SwitchTo().Frame(driver.FindElement(By.Id("theiframe")));
From here you can now use FindElement or whatever you need using the content inside the iFrame.

- 519
- 1
- 6
- 24
I ran into the same issue and could not manually setup a RDP connection prior to starting the tests. Also the website we test is looking at machine resolution rather than browser size. What I did was make sure the RDP session was setup automatically in the build process to each machine I need to test on. See this answer

- 183
- 1
- 12