Selenium Firefox Webdriver in Java (run parameters)

firefox, java, selenium, unix, xvfb

Solution

We're actually using Xvfb and Selenium in production with a dozen Firefox instances that work continuously. We use `xvfb-run java -jar xxx.jar` which select a free display to run all the firefox instances for this program. If screenshot is your concern, you can use only one display and still have a dozen Firefox taking screenshots for different websites at the same time

We wrapped this under a shell script, and that's transparent.

If you really want each selenium server to have its very display, you can overwrite it in the browser string specified in configuration. just make a shell script that do `xvfb-run /usr/bin/firefox` and pass this script to your config. That should do the trick

Have a good testing

Problem

I've developed a testing unit with Selenium 2 in Java that uses Firefox engine. The deploy machine has no display so I'm using Xvfb to create it. Unfortunatly that forces me to start java using `DISPLAY=:0 java -jar xxx.jar`. I've searched selenium javadoc and searched some sources but can't find the method that java uses to launch Firefox, witch is my goal, making java launch firefox using same method `DISPLAY=:0 firefox ...`. Long story short: I must do `DISPLAY=:0 java -jar xxx.jar` but I want java to do `DISPLAY=:XX firefox ...` instead of `firefox ...` so I can also use multiple displays. Any advice?

Original source