Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

Our test suite is written in Python and makes use of the WebDriver Python bindings. We are looking into moving to TeamCity for continuous integration. The setup I have in mind is a build triggered for the UI tests when the source code build finishes.

The problem is that if TeamCity build agent is running as a Windows service, then the WebDriver tests are run in the background (and it takes forever to run even a single test). The workaround is to start the TeamCity build agent manually. Now the browser is visible, has focus and the tests run fine. The catch is, if the machine running the build agent is restarted, one would need to remember to start the build agent again.

Has anybody implemented a similar setup ?

How can I get around this problem of having to run the build agent manually?

share|improve this question
    
Have you seen "The problem is that Windows Services running as a user cannot interact with the desktop," at stackoverflow.com/questions/2291639/… ? –  dzieciou Nov 15 '12 at 6:35
    
@testarab: "run slowly" != "takes forever", so the title now seems a bit bit misleading. Maybe the author should quantify "forever"... –  dzieciou Nov 15 '12 at 13:08
    
@dzieciou a test which normally executes in 8 seconds now takes 1250 seconds. –  user1411110 Nov 15 '12 at 18:06
    
The result of the test is the same? No problems with launching the browser? –  dzieciou Nov 15 '12 at 18:12
    
The test executes successfully, but the browser is not visible, my guess is that it runs in the background (probably in a headless state ?) but as webddriver needs active browser focus it takes that long to execute. There are no problems when Teamcity build agent is started manually. –  user1411110 Nov 15 '12 at 18:17
add comment

3 Answers

The two steps I had to take on a windows 7 machine were:

  1. For Win7 machines, set the registry key HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\AllowRemoteRPC to 1. This allows the remote task to execute on a remote machine.
  2. Change the windows service "Interactive Service Detection" to startup "Automatic". This allows us to remote desktop in to a client machine and view a remote task being executed.

I'm able to execute selenium tests via a windows service with little delay. My test suite is using the .net libraries and all of the supported browsers.

share|improve this answer
add comment
  1. In recent versions of Windows, Microsoft decided to give services their own hidden desktop, and so even if you check "interact with desktop" and running as current user, the service still is referring to a hidden background desktop. There is no way to change this, as Microsoft did this on purpose. So, for example, to run Selenium tests from a executor, you need to run the executor as current user in the foreground.

    I ran into this problem when using Jenkins job server to schedule and run all my tests.

    If you need your executor program to auto start when restarting the computer, then set your machine to "auto-logon" on startup and then run the executor as a startup program in the foreground.

  2. Another solution would be to convert your tests to using a Grid and a Node. Then, you can run TeamCity as a background service, run the Grid Hub in the foreground, and run the Grid node in the foreground. Then, your tests just talk JSON protocol to Grid Hub and your "running as a service" problem is solved because Grid Node runs them as the foreground user.

share|improve this answer
add comment

We have this same problem with Ranorex and Teamcity. Running on a build agent that runs as a service is ok, but screenshots wouldn't come through right. What we ended up doing was logging in at console and running the build agent at console and running tests on that build agent. It's not an ideal solution, but it's solved all of our problems, so it's workable.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.