We have some of our automated functional tests that require a particular screen resolution setting.
What is currently in place is that automatically, a script connects to the test server machine (running Windows Server 2008 R2 Standard 64 bit, in case it matters) via remote desktop, using the particular settings we need from an .rdp settings file.
Then the tests which are running automatically on a scheduled time on the machine seem to use these settings and everything works well. (It seems Windows is using the display settings from the last successful remote connection session?)
Now we want to migrate the test schedule to an automated TFS 2018 build definition.
So a TFS test agent is installed on the server and run via TFS build. But we dont get the right results because of wrong display settings.
Even if i manually connect to the server using rdp with right display settings, and then starting the TFS build, it doesn't work.
Somehow the TFS agent is running in a session that doesn't have (inherit?) the right display settings from the last rdp connection.
The user account is the same in every case.
How can I fix this? How can I force a TFS agent to use specific display settings?
From Microsoft Docs about Automated Testings in TFS/Azure DevOps:
Before running UI tests you mat need to adjust the screen resolution so that apps render correctly. For this, a screen resolution utility task is available from Marketplace. Use this task in your pipeline to set the test screen resolution to a value that is supported by the agent machine. By default, this utility sets the resolution to the optimal value supported by the agent machine.
If you encounter failures using the screen resolution task, ensure that the agent is configured to run with auto-logon enabled and that all remote desktop sessions are safely disconnected using the
tscon
command.
So download the task from the link above, and add the task to your pipeline before the UI tests task.