Capybara Anatomy

Capybara Anatomy

Capybara Anatomy

Let’s understand Capybara Anatomy. Certainly, the capybara is a library/gem useful of an underlying web-based driver. Moreover, it offers a user-friendly DSL (Domain Specific Language) which is useful to describe actions that execute by the underlying web driver.

When the page loads using the DSL (and underlying web driver). Moreover, the Capybara will try to locate the relevant element in the DOM (Document Object Model) and execute the action, such as click button, link, etc.

Here are some of the web drivers supported by Capybara:

rack::test:

By default, it works with rack::test driver. This driver is considerably faster than other drivers, but it lacks JavaScript support and it cannot access HTTP resources outside of the application for which the tests are made (Rails app, Sinatra app).

selenium-webdriver:

Capybara supports selenium-webdriver, which is mostly used in web-based automation frameworks. It supports JavaScript, can access HTTP resources outside of application, and can also be setup for testing in headless mode which is especially useful for CI scenarios. To setup usage of this driver you need to add:

Capybara.default_driver = :selenium

capybara-webkit:

For true headless testing with JavaScript support, we can use the capybara-webkit driver (gem). It uses QtWebKit and it is significantly faster than selenium as it does not load the entire browser. To setup usage of this driver, you need to add:

Capybara.default_driver = :webkit

Capybara Anatomy

Cucumber and Selenium WebDriver are just additional gems. To install them, run the following

gem install cucumber selenium-webdriver

Make your resume stand out and become a Certified Capybara Testing Professional. Try free practice tests here!

A great career is just a certification away. So, practice and validate your skills to become Certified Capybara Testing Professional

Capybara
Capybara vs Cucumber

Get industry recognized certification – Contact us

keyboard_arrow_up