Hey! These docs are for version 1, which is no longer officially supported. Click here for the latest version, 2-web!

# Waiting for elements with Capybara

Capybara is a powerful Ruby library for automating control of browsers.

Capybara has a [robust internal wait system](🔗) that can be used to efficiently wait for certain page elements to appear before continuing. You should never need to write a flaky `sleep` call with Capybara.

## With RSpec tests

This will efficiently wait for the `#new-project` element to exist.

## Without RSpec

You can use Capybara's generic `has_css?`/`has_content?`/`has_xpath?` methods to make sure that the page state is correct before continuing on. You probably will want to raise an exception to stop execution if the query for the element returns false.

## More info

  • <https://github.com/teamcapybara/capybara#querying>

  • <https://github.com/teamcapybara/capybara#asynchronous-javascript-ajax-and-friends>