Change VSTS agent session screen resolution when running protractor tests
Asked Answered
T

1

8

My protractor tests work fine on my local machine and on Azure VM Windows Server 2012R2 when accessed via RDP. I explicitly set browser window resolution in my tests using browser.driver.manage().window().setSize(1600, 900); and it allows tests to work properly.

However, when the VM mentioned above is used as build machine, controlled by VSO (VSTS) agent, my protractor tests are failing. I suspect it happens because screen resolution for VSO agent session is smaller then desired resolution specified in my tests and WebDriver(ChromeDriver) can't set resolution higher than OS limitation.

My question is how to change screen resolution of Azure VM for VSO agent session?

I tried custom utility for changing screen resolution from here and it works on my PC, however when it is executed by VSTS agent on Azure VM it throws error:

System.InvalidOperationException: The display driver failed the specified graphics mode.
Timmerman answered 22/9, 2016 at 5:44 Comment(10)
I created a VM on Azure (windows server 2012 R2) and connected to that machine through RDP, the resolution is 1600 X 900, also based on this tool (dccmd -listmonitors), the resolution is 1600 X 900 too. What's your VM's resolution?Hebrides
When I connect to Azure VM via RDP resolution is 1600x900, as on my laptop, but I guess this is set by RDP video adapter. When UI tests are run by VSO agent on this VM, there is no RDP session, so Microsoft Hyper-V Video adapter is used and its default resolution 1024x768. Need to understand if it's possible to change it.Timmerman
what's the result of Get-DisplayResolution (powershell)? (run powershell script during build)Hebrides
it returns 1 0 2 4 x 7 6 8 during build. If I run it when I'm connected via RDP, it returns 1 6 0 0 x 9 0 0Timmerman
Tried with many ways, failed to change resolution remotely.Hebrides
Is your build agent run in interactive mode?Sieracki
My agent runs as a service, would it be possible to change resolution if I switch it to interactive mode?Timmerman
I haven't try to change resolution. But run protractor test required the build agent to run in interactive mode since it need to interact with the browser.Sieracki
@Eddie-MSFT It did help to run agent in interactive. When I connect to my build machine via RDP it gets screen resolution of my client machine. Then when I launch vso agent and disconnect by RDP, this display resolutioin remains on build machine, so selenium can maximize browser window.Timmerman
@Timmerman Glad to hear that. :)Sieracki
P
2

In order to run the protractor tests, the agent needs an interactive session. Configure the agent to run interactively, instead of as a service.

It did help to run agent in interactive. When I connect to my build machine via RDP it gets screen resolution of my client machine. Then when I launch vso agent and disconnect by RDP, this display resolution remains on build machine, so selenium can maximize browser window.

Pilpul answered 18/12, 2016 at 12:43 Comment(1)
have you found a way to run it without need of login into RDP?Encapsulate

© 2022 - 2024 — McMap. All rights reserved.