Search code examples
ui-automationncrunchflaui

How can I run UI tests with FlaUI on a remote machine whilst not RDP'd into it?


We have some UI tests that use FlaUI to automate interaction with the windows UI.

When we run these tests on the build server, they fail to interact with the UI unless someone is connected via RDP.

The error we get from the tests is just a Could not send mouse input. ErrorCode: 5

The machine is set up to log in a user on startup and if we log in to an RDP session as that user and 'watch' the tests then they run ok and can interact with the desktop. As soon as we disconnect that user then they stop being able to interact again.

We are running the tests via NCrunch grid nodes, using NCrunch grid node console app, which starts on log in (ie its not running as a service so it can interact with the desktop).

Is there some way to make the tests run in a way that means we don't have to watch them continuously?


Solution

  • If you simulate a mouse click, there has to be an active desktop session (https://github.com/Roemer/FlaUI/wiki/FAQ#how-can-i-run-flaui-tests-on-a-build-serveragent).

    You have two options: test without mouse clicks (use UIA patterns) or ensure an active desktop session for the build agent. As stated in the FAQ, make sure the session is not closed after disconnecting RDP by running tscon 1 /dest:console