Search code examples
javafirefoxseleniumfocusacceptance-testing

How do I prevent Selenium RC from stealing window focus while my tests are running?


I know I'm probably in a small minority, but I have to use my machine at the same time my tests are running. The thing that always gets in my way is that the browser window is always stealing focus when I run test cases using Selenium RC. Which prevents me from running my tests more than once a day, at the end of the day right before I log out. I tried Selenium Grid, but I can't get it to only listen for requests on localhost, not 0.0.0.0 (a requirement from my network admin).

I've dug through the Selenium documentation, and tons of Selenium sites, but I haven't been able to find a definitive answer. Can I prevent Selenium RC tests from Stealing windows focus while my test are running?

I'm using Firefox 3.6.13.


Solution

  • UPDATE

    I found a work-around to my focus stealing Firefox window. If you are running Selenium as a stand-alone server as I am, then you can add this:

    -browserSessionReuse
    

    To the ant task that launches your Selenium test cases. This saves considerable time as well because I don't have to wait for two new Firefox windows to open up while the selenium tests are running. The work around is that you will have to log out of your site every time a test starts, if each of your tests is a standalone test. I accomplished this quickly by editing my log in method to look for my log out link. If the log out link is present then my test clicks the log out link, and waits for the log in page to be available, then continues on with the test.