talira

Capybara

Acceptance test framework for web applications

open sourceMITself-hostablefree

Capybara tests a web application by acting like a person using it: visit a page, fill in a field by its label, click a button, then assert what the page shows. The same DSL runs on different drivers, Rack::Test (fast, no browser, no JavaScript) and Selenium are built in, and gems add others. Its finders and matchers wait for content to appear, which handles pages that update with JavaScript. It works with RSpec, Minitest, Cucumber and Test::Unit, and Rails system tests are built on it.

Problems it solves

  • test my Rails app the way a user clicks through it, in a real browser
  • write a test that signs up, fills in a form and checks the confirmation page
  • my browser tests are flaky because content loads with JavaScript after the page
  • run the same end-to-end tests without a browser when they don't need JavaScript
  • find buttons and fields by their visible label instead of CSS selectors
  • switch my feature tests between Chrome and a headless driver without rewriting them
  • integration tests for a Ruby web app that read like a user story
  • test a modal, a new window or a file upload in a full-page test

Features

  • user-level DSL: visit, fill_in, click_on, select, attach_file
  • Rack::Test and Selenium drivers built in
  • third-party drivers from other gems
  • matchers that wait for asynchronous content
  • scoping, windows, modals and named sessions
  • RSpec, Minitest, Cucumber and Test::Unit integration
  • the base of Rails system tests

Capabilities

Takes pluginsplan not known

Alternatives

The same job

These do what Capybara does.

  1. Cypress AI writes the code. Cypress proves it works.
  2. Playwright Fast and reliable end-to-end testing for modern web apps
  3. Puppeteer JavaScript API for Chrome and Firefox
  4. BrowserStack Everything you need for testing, with AI at every step
  5. Selenium Automate any browser, from any language.

Compare Capybara with the top 3