- It is extremely slow
- Every test execution opens up a web browser window
The latter can be seen as an advantage at first, because you may be able to see what happens when a test fails, but it actually turns out to be really annoying. The result might be that you actually never or very occasionally execute the tests.
Before installing the gem, there is one important dependency: Qt.
If you use OS X, you can install it using:
$ brew tap homebrew/versions
$ brew install qt55
$ brew link --force qt55
On Debian / Ubuntu:
$ sudo apt-get install qt5-default libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x
For further information regarding qt’s installation, take a look at the capybara-webkit official documentation.
Then, you want to declare webkit as your default Capybara driver. Open up a new file called capybara.rb in features/support and write:
You can also add this line to your env.rb instead, but I like to keep the configuration files clear and having a dedicated one for Capybara is part of this.
Running them will make use of the webkit driver.
Automatic Screenshot on Scenario failure
First, update your Gemfile with the gem declaration:
group:test do gem 'capybara-screenshot' end
bundle install, open up your Capybara configuration file and add:
# features/support/capybara.rb Capybara.save_and_open_page_path = 'tmp/screenshots'
You also need to reference the gem within your env.rb:
# features/support/env.rb require 'capybara-screenshot/cucumber' ...
Note: there is a depreciation warning saying that save_path should be used over save_and_open_page_path but when doing so, any path set is being ignored and the screenshots are put within the project root path instead. I’ll update the post as soon as this issue is corrected by the gem.