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, 2nd Edition 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.