One of the main points people get interested on Behat is not only because you can use natural language to describe and test your application but also because all the tests are able to run in a real browser.
Let’s make an overview of the main pieces available to achieve a broader testing strategy.
Automated testing in browsers started to get mainstream with a tool called Selenium that allowed developers to interact with a browser by clicking and typing and then replay that interaction as many times as needed. Selenium evolved to give birth to a component called webdriver that defines a protocol to drive real web browser opening the door to automation.
In our laptops we have a screen and is easy to run graphical applications like a browser but in a server without a display or graphical environment is a bit more tricky.
The first tool that appeared and the the first that we used was Selenium server. To run properly it needs xvfb to simulate a screen in memory, the Selenium Java server to send commands to the browser and Firefox to render and execute our web application.
This is a big stack of dependencies and it needs control over how to start the different daemons and processes and kill them when you are finished.
To simplify the stack PhantomJS is a tool that integrates the three components: it renders the page internally (even if it runs with a graphical interface), understands the webdriver commands sent by Mink (we still use the same Selenium2 driver in Behat) and it has a full webkit browser(similar engine to chrome and safari) inside. This will speed up the execution of the tests because we got rid of a lot of overhead. You can even install it with Composer!
Remember that you can swap between the Selenium + Firefox stack and PhantomJS to debug at any moment since they are just services listening on a port of your computer.
Tag the scenarios
By changing the underlying software we gained some speed but such a high level of testing will be slow by definition. The reason for this is because we are trying to get as close as possible to a real world scenario with a full Drupal installation and a full web browser.
This a is brief introduction to the most popular tools to automate the process and how they work together. We plan to continue this series with specific configurations on how to make it work on your day to day development. Stay tuned.