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.
jessehouwing
  • 106,458
  • 22
  • 256
  • 341
twinmind
  • 1,440
  • 13
  • 21
  • 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? – starian chen-MSFT Sep 23 '16 at 06:39
  • 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. – twinmind Sep 23 '16 at 06:44
  • what's the result of Get-DisplayResolution (powershell)? (run powershell script during build) – starian chen-MSFT Sep 23 '16 at 06:47
  • 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 0 – twinmind Sep 23 '16 at 16:53
  • Tried with many ways, failed to change resolution remotely. – starian chen-MSFT Sep 24 '16 at 08:27
  • 1
    Is your build agent run in interactive mode? – Eddie Chen - MSFT Sep 26 '16 at 05:17
  • My agent runs as a service, would it be possible to change resolution if I switch it to interactive mode? – twinmind Sep 26 '16 at 05:59
  • 1
    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. – Eddie Chen - MSFT Sep 27 '16 at 08:00
  • @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. – twinmind Sep 28 '16 at 23:25
  • @twinmind Glad to hear that. :) – Eddie Chen - MSFT Sep 29 '16 at 00:34

1 Answers1

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.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341