The Capybara API

Even though we have used only four of Capybara’s methods at this point, we have actually explored the most essential parts already. Let’s take a look at more of Capybara’s API.

The methods in the Capybara API can be grouped in six categories: navigating, clicking links and buttons, interacting with forms, querying, finding, and scoping. The following sections list the most common methods. Make sure you consult Capybara’s own documentation for more comprehensive details.

Navigating

visit(path)

Navigates to the page at path, issuing a GET request.

Clicking Links and Buttons

click_link(locator)

Finds a link by ID or text and clicks it. This may cause Capybara to load a new page.

click_button(locator)

Finds a button ...

Get The Cucumber Book now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.