As all testing suites grow, we eventually introduced the awesome Parallel Tests gem, cutting run-times dramatically. An unfortunate side effect however, multiple instances of Firefox randomly opening in the foreground and stealing focus.
Some digging into the selenium-webdriver codebase found the culprit in the Selenium::WebDriver::FireFox::Launcher class:
1 2 3 4 |
|
Removing the -foreground parameter has the desired effect of loading Firefox behind the terminal, and not stealing focus. But since the selenium-webdriver codebase is hosted in google code a pull request was out of the question, time for some monkey patching.
The following code goes at the base of spec_helper:
1 2 3 4 5 6 7 8 9 10 |
|
The patch is disabled by default, to opt-in set the environment variable as part of your testing command:
1
|
|
Happy testing folks!
]]>