views:

233

answers:

3

I'm trying to setup CI environment for QA department. They use SeleniumRC to run UI tests in IE and FF browsers to test some web application. I had a success configuring it to run as a windows service as described here. However when i run the test it hangs. I can see iexplore.exe process spawned by Selenium service in the process list but nothing more happens. No browser window appears, no entries in the windows event log. I did a lot of googling and as fas as i understand the problem is interaction with desktop. I tried to run the service under SYSTEM account with "Allow service to interact with desktop" check-box set as well as under a regular user account with local admin permissions. So my question is if it's possible at all?

+2  A: 

I'm skeptical about running anything as a windows service that is supposed to interact with a desktop application. Windows services run in their own sandbox; they're not supposed to interact with a user's desktop or its applications. To do so requires special efforts to communicate with the service, so if it is possible at all, I would think there would be some kind of desktop client running as well, acting as a liaison between the browser and the windows service.

I can't tell you it won't work, though, because it is obviously possible if people are blogging about it.

Why does it need to run as a Windows service, by the way? Is that how Selenium has set up their automation, or can you do it without the Windows service? Because I think that would be the shortest distance between two points.

Robert Harvey
Thanks, Robert! They need to automate it as much as possible so Selenium tests are part of the whole build process (build -> deploy -> tests). The service can help to have the environment to be independent from humans (no need to login and start Selenium manually each time servers reboot, for example). However, i spent so much time in vain so i'm leaving it as it is.
UserControl
A: 

My recommendation would be to have a dedicated machine (or virtual machine) for running Selenium RC. In my experience it's best to let Selenium run interactively rather than in a headless mode.

Dave Hunt
In fact they have a few boxes for Selenium RC (and each has a few VMs with different configurations). More servers -> more manual work, i hoped it could be automated somehow.
UserControl
+4  A: 

In our organization we have a continuous integration server (Cruise Control) running the build including Selenium RC tests. The CI server is run as a Windows service (on MS Windows 2003 Server) and Selenium tests are just part of the test suite.

That is quite a straightforward setup and frankly I see no reasons for giving up with it. Currently in our setup the Selenium server (and client) is started directly from the tests (however we used to have Selenium as a separate service).

In Java code (actually in the super class of all web tests) we do something like:

// to start the server
RemoteControlConfiguration config = new RemoteControlConfiguration();
config.set(...)  // set the serverHost and port
...
SeleniumServer server = new SeleniumServer(config);
server.start();

// and then to start the client
Selenium selenium = new DefaultSelenium(serverHost, port, "*firefox", "http://www.google.com");
selenium.start();
selenium.open("http://www.google.com");

// now the browser should be visible for you (if you run it locally, not as a service)

So I would suggest you trying the following (whatever language you are using):

  1. Try to run the Selenium server and client from just a standalone application. The browser should show up as a window. Adjust the settings to your needs (browser type, etc.).

  2. Try to incorporate the code within your test framework (xUnit or whatever). Run them manually. The result should be the same.

  3. Then you can try to have the tests run from the continuous-integration. Run the CI server as a service and let it build your project. The browser wouldn't be visible, but that's not required for the tests to be run, isn't it?

NOTE: if you wanted to peep what Selenium is doing, I believe it would be easier on UNIX machine. You could point the tests to use the X-server DISPLAY of your choice - a fake one or a true one connected to some monitor.

Grzegorz Oledzki
Thanks for your answer! We have almost the same configuration here (Win2003 and CruiseControl) except it is .NET platform (tests compiled to c# code using NUnit). All works fine either in local or remote mode but only if Selenium is started via console (a browser shows up and the test is green). But if we start it as a windows service it doesn't work. I'll try your suggestion about starting the server from the code as soon as i can switch back to this task.
UserControl
I checked the permissions of the user the CruiseControl service runs on. And here it's member of: `Distributed COM users, Power users, Remote Desktop Users, TelnetClients, Users`. Not quite sure if all of them are needed. I am almost sure that no other customizations of the user's privileges have been made.
Grzegorz Oledzki
Thanks for your help! The problem was in outdated Selenium RC. Version 1.0.1 works as a service just fine!
UserControl