Ensure Turn Off Display Setting is set to Never for Automated UI Test Machines

Image

March 1, 2023

We were working with a client where our automated UI tests were working perfectly on our local machines but started failing randomly when running them nightly. I want to share a few of the symptoms that we ran into and how we fixed it.

Our configuration was using TFS 2013 and a standard lab environment with the test agents to handle automatically logging in and disabling the screensaver so the machines would always be ready to run the tests. We added a reboot of the servers 15 minutes before the test run started. We were running LogiGear TestArchitect UI tests but any UI test would have this issue. The tests would run fine for several days and then the test runs would start randomly failing on one ore more of the machines. The test runs would end with failures explaining that the first element on the page couldn't be found no matter what we did. We eventually discovered that a setting in the Power Options called "Turn Display Off after..." was set to 15 minutes. If there was no activity on the VM, it would turn the screen off, essentially locking it so the tests couldn't run. Since the machine would reboot 15 minutes before the run, by the time the reboot finished it was just a under 15 before the tests would start. Therefore the randomness of the tests failing was caused by slight variations of timing that it might trigger the 15 minute "Turn Display Off after" setting before the test run activity started. Once we discovered this, we changed the setting to Never and now the screen will never turn off for inactivity on the VM. The tests have run fine ever since. This was very difficult to pinpoint the issue but it was easy to fix. Hopefully if you are running into this issue, you were able to find and this and get your UI tests running again.

Below are the steps to where you can find the setting and turn it to Never.

power_saving_turn_off_display_after.jpg