Let’s Talk About Drivers

To understand what Capybara is doing and what you need to do to make JavaScript integration testing work, you need to know about drivers. The driver is the part of Capybara that actually manages a web page as a series of DOM elements. The Capybara query language interacts with the driver, telling it to click a button or fill a form element, or just querying the driver to return DOM elements that match a selector and some other criteria.

Capybara’s default driver is called Rack::Test. It’s relatively simple and relatively fast. Rack::Test is written in Ruby and maintains its own DOM element tree. It’s also dependent on Rack, which is the web stack that underlies nearly all Ruby web frameworks—not only Rails, but also ...

Get Rails 5 Test Prescriptions now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.