Increase the screen resolution on Test Agent
Asked Answered
J

6

7

Running a automated test against a desktop WPF application works fine on my local machine and on Azure VM Windows Server 2012R2 when accessed via RDP.

However, when the VM is used as build machine, controlled by test agent on TFS or VSTS, all test fails because of the screen resolution is set to 1024x768 screen resolution. The application is not configure to run until this display settings. Is there any way to change the screen settings when we deploy the test agent?

Change VSTS agent session screen resolution when running protractor tests

Jerkwater answered 23/8, 2017 at 2:41 Comment(10)
Is the agent running as interactive mode?Seraph
Log on that machine and check whether it opens the WPF application correctly.Seraph
The machine was able to open the WPF application correctly via RDP. It also works on the local machine.Jerkwater
What task that used to run test? Visual Studio Test or Run Functional Test?Seraph
On the other hand, I mean log on to test machine via RDP (same account), then queue build and check whether the WPF app opens fine.Seraph
It is very similar to this issue here social.msdn.microsoft.com/Forums/vstudio/en-US/…Jerkwater
We are using run functional test. When we deploy the test agent it has interactive process checked so this means we should be running in interactive mode. We also tried to log on to the test machine via RDP (same account) and run the test and it works fine.Jerkwater
do we have to have to configure the test agent to interact with the Desktop (interactive process) and build agent running as interactive Mode? We are using tfs 2015 update 3.Jerkwater
The WPF app opens fine. It is the screen resolution that always default to something not supported by the applicationJerkwater
More updates, when we are login via RDP (same account), we queue the build, the WPF app opens fine and the screen resolution is good. The problem happens when we disconnect the session and run while the VM is disconnected that is when the problem happens.Jerkwater
A
8

We've encountered the same issue on our Visual studio + Azure solution. To be able to execute the tests we need a higher resolution on the VM than 1027 x 768. But since it's Azure and you pay for machines that are turned on, we also want to turn them off after each run top keep the cost down (especially helpful when you want to scale up a bit).

Therefore it's a real pain that there is no simple option to let the VM boot in a certain (specified) resolution. If there is something more simple than what I'm going to show you, please let me know, but I could not find any. So I up-voted the idea mentioned by Nessi. What we did as a workaround was the following.

Idea's for possible solution

In essence we used this post as a guideline. The most important things we used from this was the Windows credentials part and the TERMSRV.

Our Setup

  • Visual Studio Build server
  • Four Azure VM's, one machine is the selenium-grid-hub the other three are nodes

Our Solution

First we let the Build server start all machines in the resource group (so far so good). Then we created a Powershell script that runs on the build server to the nodes to check and waits for the RDP service to become available. This was needed since it can take up to 10 minutes before we see that this service is active. And finally we trigger a Powershell on the selenium-grid-hub VM to make RDP connections to all nodes in a certain resolution.

In a bit more detail to make sure it all goes automatically and without any manual input needed:

  • Creating and export/import certificates from each node into the hub
  • Making sure that the credentials are stored in the credential manager > Windows Credentails (we created one user on all machines to make life a tiny bit easier)
  • Creating a script for checking if the RDP service is active
    • We call this script C:\Scripts\RDPServiceRunCheck.ps1 (see example below) in a VS build block with the arguments $(Password) $(Chrome-node) $(Username)
    • Where all these arguments have been stored in variables on the build server
    • Here is the code for the script on github
  • Creating a executable for starting a RDP in a certain resolution
    • We call this script C:\Scripts\Resolution.RDP.Remoting.exe (see example below) in a VS building block with the arguments "C:\Scripts\$(Chrome-node).rdp" 1600 1200
    • Where the *.rdp file for each machine was stored (upfront) in this folder and 1600 1200 is the resolution we want to set
    • Here is the code for the executable on github
Ambie answered 20/12, 2017 at 13:32 Comment(0)
M
4

This is an older question, so thought it best to throw this out there if it helps anyone.

There is a Screen Resolution Utility AzureDevOps Build/Release task to change the screen resolution of the agent machine. Useful when running UI tests such as Selenium, Coded UI etc.

https://marketplace.visualstudio.com/items?itemName=ms-autotest.screen-resolution-utility-task

Mandamandaean answered 4/6, 2019 at 16:21 Comment(1)
@Yoiku I'm not familiar with TFS on-premise. I believe the latest version is now referred to as Azure DevOps Server. If release pipelines are managed in the same way I would assume you can use marketplace tasks?Mandamandaean
K
3

Try using the below Powershell command, it is a 100% working solution

Set-DisplayResolution -Width 1024 -Height 768 -Force
Kherson answered 11/3, 2021 at 14:30 Comment(3)
perfect solution!Korte
This only works with server core I believeLucio
Install to Windows Server for e.g.: ``` Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Confirm:$false Install-Module -Name DisplaySettings -Force -AllowClobber -SkipPublisherCheck ```Caudal
T
2

Try running the test headless I had the same issue with TFS and this is the only way it works for me

args: [
    '--headless',
    '--window-size=1920,1040',
],
Town answered 19/11, 2018 at 14:37 Comment(0)
D
0

This is a limitation with Azure VM since it use RDP to set the screen resolution. Refer to this link for details: Why is not possible increase or change display resolution in Azure VM.

The RDP session uses the RDP display driver, not the Microsoft Virtual Machine Bus Video Device.

Although the RemoteFX feature enables a broader range of graphics workloads than regular RDP, RemoteFX is not available for Azure VMs.

Dyan answered 30/8, 2017 at 3:19 Comment(4)
any idea how to fix this? We don't want to run our automated test on a low resolution setting.Jerkwater
@GSTeam There isn't any way to change this as far as I know. You'd either keep RDP connected or deploy a test agent on your local machine.Dyan
Is there a way to keep the session alive continuously? thanksJerkwater
@GSTeam No unless you keep the RDP connected.Dyan
G
0

I am having the same problem. As there is a way to specify a resolution for an RDP session (even for an Azure VM), I created a UserVoice idea to get this desired feature (specify a resolution when running UI tests with "Run Functional Tests" task).

In the meantime, I am using a workaround. Our build VM opens an RDP session in the desired resolution (currently to cover different browser sizes this session runs at 4800x2700) to the test machine with the account, the UI tests are executed with. When there is an active session, the UI tests just connect to that session and uses the resolution that is currently shown. This way we have a constant RDP session from the Azure build VM to the Azure test VM, but it works :)

Gravois answered 21/10, 2017 at 9:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.