Everybody understands why implementing automated tests is important but at the same time developing them can be costly and time consuming, and tests can be also be fragile and prone to false positives. By using Capybara, you can develop robust tests quickly and run them in multiple drivers ensuring greater re-use; Capybara’s API also extends the human readable style made popular by frameworks such as Cucumber and RSpec.
This book takes you from the basics of installing Capybara, through its API and onto advanced topics. You will learn how to use Capybara’s extensive API to interact with your application, covering topics such as navigation, filling in forms, and querying your page for expected content. Beyond this we will consider why Capybara is so well suited to testing applications written in frameworks such as Rails and Sinatra. We will look at strategies for validating seemingly “untestable” components such as HTML5 or Flash by building out a testable API. Finally we will turn you into a Capybara ninja by covering advanced topics such as accessing functionality in the base driver, advanced driver configuration, and alternative flavours of drivers outside Selenium and Rack-Test.
What you will learn from this book
- Install and configure Capybara
- Use Capybara and Cucumber to test scenarios
- Exploit Capybara’s API for interacting with web pages
- Employ Capybara to test Rack applications implemented using Rails or Sinatra
- Apply Capybara to test “black box” components such as Flash or HTML5 Canvas, Audio, and Video
- Practise Capybara outside Cucumber in bespoke frameworks
- Use Capybara with popular Ruby test frameworks
- Explore advanced driver configuration
- Work with alternative drivers such as Capybara-Webkit and Capybara-Mechanize