Here's a special April Fool's Day trick for Behat: swap out your Selenium Driver with Phantomjs.

Materials that you will need:

  • Phantomjs
# Somewhere in your provisioning script.
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2 -O - | tar xj -C /tmp
cp /tmp/phantom*/bin/phantomjs /opt
  • A browser
# Somewhere in that same provisioning script.
sudo apt-get update -y && sudo apt-get install -q -y iceweasel

Kick that driver into gear:

# Somewhere in that same provisioning script.
/opt/phantomjs --webdriver=8643 &> /dev/null &

Now here is the tricky part, in your behat.yml tell behat to use the Selenium Driver at the same point where you have phantomjs listening:

# Your behat.yml
...
  extensions:
    Behat\MinkExtension:
      goutte: ~
      selenium2:
        wd_host: "http://127.0.0.1:8643/wd/hub"
      base_url: http://your-alias.dev

Behat will get the last laugh, though: phantomjs is far more efficient than Selenium.

What do you think?

I'd love to hear from you. Contact Michelle.