SW Designs

Technology and Photography

Behat, Selenium2 and SauceLabs

I’ll be honest, last time I used Selenium (1.x) the experience wasn’t great. The server component had serious stability issues and the IDE was clunky and slow to use. So it was with some trepidation that I revisited the project recently as I was looking for an automated, in-browser, cross-platform (inc. mobile) platform for automated web applications.

Introducing WebDriver

Since my initial Selenium experience there has been a new major release, Selenium 2. It uses the WebDriver API, relying on drivers to be supplied for individual browsers, with some being vendor supported. Current browser support includes Chrome, Firefox, Opera, Internet Explorer, Android and Safari on iOS. A marked improvement on Selenium 1!

Adding some Sauce

Here’s where it gets interesting, companies such as SauceLabs and TestingBot provide a SaaS-style Selenium Grid/Hub product, covering multiple OSes and browser combinations. TestingBot even has support for iOS and Android using their respective emulators, with SauceLabs planning to add support in late 2012.

Behat integration

For this example, I’ll be using the SauceLabs platform to run the MinkExtension-example tests. Follow the instructions in the README to get it running with Selenium running locally. Done? Let’s move on.

Open behat.yml.dist and add the following new profile, setting your own SauceLabs username and password details.

That’s it! Just re-run behat using your new profile.

bin/behat -p saucelabs

After that’s complete, you should have something like in your SauceLabs job history, http://bit.ly/BehatWebDriverSauceLabs