Generated by GPT-5-mini| Capybara (software) | |
|---|---|
| Name | Capybara |
| Developer | Jon Leighton; contributors |
| Released | 2007 |
| Programming language | Ruby (programming language) |
| Operating system | Unix-like; Microsoft Windows; macOS |
| Genre | Testing framework; acceptance testing |
| License | MIT License |
Capybara (software) is an open-source acceptance testing library for Ruby (programming language) that simulates how users interact with web applications through a unified API. It drives browser automation and headless browsing using multiple drivers and integrates with test suites to express high-level scenarios for RSpec (software) and Minitest. Capybara bridges test code and browser engines to enable integration and system testing for Ruby on Rails, Sinatra (web framework), and other Rack (webserver interface) applications.
Capybara provides a domain-specific language to describe user interactions such as visiting pages, filling forms, clicking links, and asserting content presence within the context of browser engines like Selenium (software), WebKit (browser engine), and Chromium (web browser). It abstracts differences among drivers so tests written for RSpec (software), Cucumber (software), or Test::Unit can run against headless PhantomJS, Firefox, Chrome (web browser), or embedded drivers. Major projects and organizations in the Ruby on Rails ecosystem adopt Capybara to validate behavior across continuous integration services such as Travis CI, GitHub Actions, and CircleCI.
Capybara's architecture separates a high-level session API from concrete drivers and underlying browser automation layers. Core features include asynchronous waiting, scoping selectors, XPath and CSS selector support, query matchers, and form helpers compatible with frameworks like ActionView and libraries like FormHelper. It implements intelligent waiting to coordinate with asynchronous JavaScript powered by jQuery, Turbolinks, or Stimulus (JavaScript) and supports features such as file upload, window and frame handling, and JavaScript event triggering. Drivers conform to an adapter interface to interact with automation backends like Selenium WebDriver, Capybara Webkit, Appium (software), and headless strategies for Headless Chrome.
The API exposes high-level methods such as visit, click_link, click_button, fill_in, select, attach_file, and within, allowing expressive scenarios in RSpec (software), Cucumber (software), or Minitest. Matchers integrate with assertion libraries such as RSpec Expectations and tools like Shoulda (testing framework) to verify page content, element visibility, and form state. Sessions can be managed per-thread or per-test to isolate state for parallel execution on platforms like Capybara::Session backed by drivers. Selector strategies permit CSS and XPath selectors and named selectors for components used in projects like Bootstrap (front-end framework), Foundation (framework), or Tailwind CSS when testing markup produced by Rails (web application framework) views and ERB templates.
Capybara integrates with automation stacks and adapters including Selenium (software), Appium (software), Capybara Webkit, and Rack::Test. It interoperates with CI/CD platforms such as Jenkins, Travis CI, and GitHub Actions and pairs with browser vendors and engines like Mozilla Firefox, Google Chrome, Chromium (web browser), and headless engines like PhantomJS. Database and state management integration patterns often reference Database Cleaner or ActiveRecord transactions used in Ruby on Rails test suites. Browser driver adapters enable running tests in cloud-based services like Sauce Labs or BrowserStack for cross-browser compatibility matrices.
Best practices encourage using Capybara for end-to-end and system tests while keeping unit tests with frameworks like RSpec (software) and Minitest for model and controller logic. Use feature specs and system specs for behavior-driven workflows influenced by Cucumber (software) and the Behavior-driven development community, and prefer headless drivers for CI speeds while reserving real browser runs for compatibility checks. Patterns include explicit scoping with within, avoiding fragile selectors by referencing semantic identifiers or ARIA attributes, stubbing external services with tools like VCR (software) and WebMock, and isolating state with transactional fixtures or strategies from Database Cleaner. For parallelization, coordinate Capybara sessions with tools such as ParallelTests or container orchestration platforms like Docker.
Capybara originated in the Ruby community in the late 2000s and evolved alongside Ruby on Rails and browser automation advances. Early contributors and maintainers, including Jon Leighton, guided architecture decisions to support diverse drivers and testing idioms from projects like Cucumber (software), RSpec (software), and Minitest. Over time, support expanded to modern WebDriver protocols standardized by Selenium (software) and integrations with mobile automation through Appium (software). Development is driven by contributions across public repositories and discussions on issue trackers and mailing lists associated with major Ruby projects.
Capybara is distributed under the MIT License, promoting permissive usage across open-source and commercial projects. The community around Capybara includes maintainers, contributors, and users from organizations using Ruby on Rails, test tooling authors, and continuous integration providers. Development activity and contributions occur through public version control hosting and collaboration platforms such as GitHub, and discussions happen in community channels frequented by developers involved with RSpec (software), Cucumber (software), and other testing ecosystems.
Category:Software testing tools