Selenium 2 is a powerful browser emulator which enables you to automate frontend testing (especially JavaScript heavy pages). It can be used with Behat as well for BDD testing.
I prefer using Goutte headless driver to test basic functionality and flow of the application but sometimes there are critical parts of the app that rely heavily on client side technologies like JavaScript. Only way to test to those is to use a browser emulator (Selenium 2, Sahi etc). Enough talking, here is how I installed Selenium 2 server on Mac OS as a service:
wget https://selenium.googlecode.com/files/selenium-server-standalone-2.33.0.jar sudo mkdir /usr/lib/selenium sudo mv selenium-server-standalone-2.33.0.jar /usr/lib/selenium sudo mkdir /var/log/selenium sudo chmod -R a+w /var/log/selenium
Then you need to create a new file:
sudo nano ~/Library/LaunchAgents/org.nhabit.Selenium.plist
With contents:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>org.nhabit.Selenium</string> <key>OnDemand</key> <true/> <key>ProgramArguments</key> <array> <string>/usr/bin/java</string> <string>-jar</string> <string>/usr/lib/selenium/selenium-server-standalone-2.33.0.jar</string> <string>-port</string> <string>4443</string> </array> <key>ServiceDescription</key> <string>Selenium Server</string> <key>StandardErrorPath</key> <string>/var/log/selenium/selenium-error.log</string> <key>StandardOutPath</key> <string>/var/log/selenium/selenium-output.log</string> </dict> </plist>
Load the service:
launchctl load ~/Library/LaunchAgents/org.nhabit.Selenium.plist launchctl start org.nhabit.Selenium
You can also check it’s running:
ps aux | grep selenium richardknop 19880 0.0 0.5 2859020 76648 ?? S 2:09pm 0:07.05 /usr/bin/java -jar /usr/lib/selenium/selenium-server-standalone-2.33.0.jar -port 4443 richardknop 20852 0.0 0.0 2432768 596 s001 R+ 3:17pm 0:00.00 grep selenium
And error logs, just in case you need them:
tail -f /var/log/selenium/selenium-error.log