Note: Make sure to run Grid Extras at least once prior to setting it up as a service, so it can ask you the first run questions.
Windows
There are two major ways to make windows automatically start the Grid Extras binary
-
Insert a batch file into StartUp directory
-
Using the Task Scheduler to add the java start command, where the executable will be the path to java.exe and the path to Grid Extras passed in as an argument
Linux
There are a lot of security issues with setting up a cron job as a âbuild userâ and letting that user run in the normal display desktop (DISPLAY=:0 aka the one you see when it is connected to the computer monitor). There is a work around to allow the service to run in DISPLAY=:0 but thatâs not recommended.
Instead, it is a much better practice to set up a XVNC server on a Linux computer, with a light desktop manager (FluxBox seems to be a good lightweight choice http://fluxbox.org/). Once VNC server and desktop managers are installed, run the following command to start a virtual DISPLAY:
vncserver :1 -geometry 1024x768
This will start an XVNC server on DISPLAY=:1 with screen resolution of 1024x768. You can tweak these parameters as needed. Note: You might need to add a cron job to restart vncserver in similar fashion, since vncserver will not automatically start after reboot
After you have the virtual display running, add run this command to edit the cron list for current user (vi is the editor used)
crontab -e
Add following lines to the cron list:
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
*/5 * * * * bash -i -c 'cd WORKING_DIRECTORY; export DISPLAY=:1 java -jar SELENIUM_GRID_EXTRAS.jar' >> WORKING_DIRECTORY/log/log.out 2>&1
Where the WORKING_DIRECTORY needs to be replaced with the location where grid extras jar was downloaded, and SELENIUM_GRID_EXTRAS represents the name given to the grid extras jar. This cron will run every 5 minutes.
OS X
Download the SeleniumGridExtras.plist to your computer, open it in editor of choice.
Update the XML file replacing WORKING_DIRECTORY with the location of the selenium grid extras working directory Update the XML file replacing SELENIUM_GRID_EXTRAS.jar with the name Selenium Grid Extras was saved as
Move the com.groupon.SeleniumGridExtras.plist to ~/Library/LaunchAgents/
run
launchctl load ~/Library/LaunchAgents/com.groupon.SeleniumGridExtras.plist
Source: https://github.com/groupon/Selenium-Grid-Extras