Search⌘ K
AI Features

The Capybara API: Interacting

Explore how to use the Capybara API to simulate user interactions in Rails integration tests. Understand methods for filling in forms, selecting options, and clicking buttons. Learn to locate elements by ID, name, label text, or alt text, and manage exact and substring matching to create reliable and readable tests.

Simulating user interaction with Capybara

After the test hits the project_path URL, we start to use Capybara methods to interact with the page elements. Specifically, we use the following:

  1. The fill_in method to place text in a text field
  2. The select method to choose an option from a select menu
  3. The click_on method to click on a button and submit a form
...