apt-get install xvfb firefox openjdk-7-jre-headless
wget http://selenium-release.storage.googleapis.com/2.48/selenium-server-standalone-2.48.2.jar. You’ll probably want to put it somewhere sensible. —NOTE: I found that there were issues when using an earlier version of selenium. Version matters here.
This is assuming that you’re doing this on a server that has your project on it, and that your project has behat installed, etc.
At this point you should be able to run your tests on the headless server with minimal fuss using a command like this to start selenium in the background:
DISPLAY=:1 xvfb-run -e /dev/stdout -a --server-args="-screen 0 1280x1024x8" java -jar ./selenium-server-standalone-2.48.2.jar &, and then running the tests as normal (ie,
This allows for running browser tests in CI, which is great. In our situation it lets us script out all of the set up and put the EC2 instances that are doing the work behind some autoscaling. Since we have lots of users sometimes running loads of tests concurrently, this is fairly important. It also allows for much better browser interaction and higher quality screenshots than using something like PhantomJs, which is critical for our use case. Note that these instructions are generic and minimalistic - anyone following them will very likely need to tweak and adapt the code samples to work for their particular situations. For instance, when setting it up in my local dev environment (I use homestead), I also needed to apt-get install libgconf-2-4.
Extra Credit: if you need to kill the selenium process, use
lsof -i -n -P | grep 4444 and kill the process it says is on :4444.