Selenium / Protractor not able to run browser tests (E2E) if the user running it is not interactively logged-in

964 Views Asked by At

We have a Continuous Integration agent that runs with the identity of a non-logged-in user (non interactive) - i.e. the agent does work with sufficient Windows user credentials, but no user is "physically" logged-in to Windows and the agent run as a scheduled task with sufficient privileges.

The problem is that under these circumstances Selenium is not able to open a browser to actually run browser tests.

What could be the solution?

This guide just briefly mentions how to configure the Windows user to be able to run a browser with a non-logged-in user (using control userpasswords2) but that advice doesn't work.

To clarify, this problem is not specific to the Bamboo CI agent (referred to in the above link). It's common to all scenarios where Selenium running on behalf of a non-logged-in user would try to run a browser.

1

There are 1 best solutions below

4
On

You need to have an interactive session to interact with. I believe this question on SuperUser Run interactive task even if user is not logged on Windows as well as the instructions from Atlassian you linked are the correct answer.

Once the user is set to auto-login, you need to reboot the system to cause that auto-login to occur. The recommendation in the linked question of forcing a lock after the login is a good one for security, but still provides an interactive session for the CI/Selenium to work against and without running under System with limitless privileges.

If this does not fix your problem after following all the directions and rebooting, and you have verified that the user is in-fact logged in at the time you run the CI/Selenium (typically you can check this with Remote Desktop and looking at that logged in user for the console session in Task Manager > Users tab), then there is most likely a different problem.