I am facing an issue with my build pipeline using VSTS.
Environment details are: Agent server is Windows Server 2012 R2 The VSTS agent is running on network service For running my client side test cases, I have created a gulp task. Karma runner is used with IE as the browser launcher.
The issue I am facing here is with IE as browser in karma.conf file. Whenever this gulp task is ran using VSTS then the karma runner is not connecting. The output is:
[33m20 09 2018 17:32:43.924:WARN [IE 11.0.0 (Windows 8.1.0.0)]: [39mDisconnected (1 times) 2018-09-20T12:02:43.9339866Z IE 11.0.0 (Windows 8.1.0.0) ERROR 2018-09-20T12:02:43.9342689Z Disconnectedundefined 2018-09-20T12:04:14.1287942Z [33m20 09 2018 17:34:14.125:WARN [IE 11.0.0 (Windows 8.1.0.0)]: [39mDisconnected (2 times) 2018-09-20T12:04:14.1289323Z IE 11.0.0 (Windows 8.1.0.0) ERROR 2018-09-20T12:04:14.1299244Z Disconnectedundefined 2018-09-20T12:05:43.7605115Z [33m20 09 2018 17:35:43.758:WARN [IE 11.0.0 (Windows 8.1.0.0)]: [39mDisconnected (3 times) 2018-09-20T12:05:43.7635052Z IE 11.0.0 (Windows 8.1.0.0) ERROR 2018-09-20T12:05:43.7641486Z Disconnectedundefined 2018-09-20T12:07:13.2066049Z [33m20 09 2018 17:37:13.205:WARN [IE 11.0.0 (Windows 8.1.0.0)]: [39mDisconnected (4 times) 2018-09-20T12:07:13.2110144Z IE 11.0.0 (Windows 8.1.0.0) ERROR 2018-09-20T12:07:13.2112337Z Disconnectedundefined
This same task works fine if the browser is set to GoogleChrome only. In case it is set either to IE only or GoogleChrome and IE then this task is not working. Also, if I run this task manually through cmd, then it is working fine.
Is there some issue with the VSTS agent service running account?
I think the problem is that IE (and Edge for that matter) can't be run under a service account - they have to be run in an environment which has an interactive desktop session.
The hack I used in the the question you linked to was to logon to the build agent using the Team City agent account and then manually start IE. This allowed me to accept that annoying first run dialog it has, and for it to layout what ever files it needs in the user profile folder to run. I would hazard a guess to say this is still unsupported, as when the Team City agent spawns an IE process it's still in a non-interactive session.
The approach I've taken recently with Selenium is as follows:
- Configure a Windows 10 box to auto login with a Selenium service account.
- Have an auto run script which immediately locks the machine and starts the Selenium node server in a console app.
- Manually start IE as the Selenium user (
runas /user:selenium-account "C:\Program Files\Internet Explorer\iexplore.exe"
) to accept that first run dialog. - Set all the registry settings needed for Selenium / IE.
You may be able to rig up something similar to work the VSTS / Karma. Do post a note here with your solution if you get it working.
If it would help you (and others), I can post my scripts to a GitHub repro. I had been planning to publish them as a Chocolatey package, but I didn't get round to that yet.
I hope that helps.
Update
From the Microsoft docs:
You can run your agent as either a service or an interactive process. Whether you run an agent as a service or interactively, you can choose which account you use to run the agent. Note that this is different from the credentials that you use when you register the agent with Azure Pipelines or TFS. The choice of agent account depends solely on the needs of the tasks running in your build and deployment jobs.
For example, to run tasks that use Windows authentication to access an external service, you must run the agent using an account that has access to that service. However, if you are running UI tests such as Selenium or Coded UI tests that require a browser, the browser is launched in the context of the agent account.
After you've configured the agent, we recommend you first try it in interactive mode to make sure it works. Then, for production use, we recommend you run the agent in one of the following modes so that it reliably remains in a running state. These modes also ensure that the agent starts automatically if the machine is restarted.
And
- As an interactive process with auto-logon enabled. In some cases, you might need to run the agent interactively for production use - such as to run UI tests