Search⌘ K
AI Features

The Capybara API: Querying

Explore how to use Capybara's query methods like have_selector and assert_selector to check HTML elements, attributes, text, and navigation in Rails integration tests. Understand options such as count, text matching, visibility, and scoping with within to write precise tests. Learn how to use save_and_open_page for debugging test failures.

Capybara has a few methods designed to query the simulated browser page to check for various selector patterns in the page. This is one case where the syntax differs slightly between Minitest and RSpec.

Capybara testing

Here the method ...