Capybara

Learning Capybara

Capybara

 

Capybara is a web-based automation framework useful to create functional tests that simulate how users would interact with your application. Today, there are many alternatives for web-based automation tools, such as Selenium, Watir, Capybara, etc. All of these tools have the same purpose, but there are slight differences that make each of them more or less suitable.

The main characteristic that developers are aiming for is the ability to have tests that are modular, easy to write, and easy to maintain. This is especially true in Agile/TDD environments where writing tests is second nature. These tests are expected to give good and fast feedback on code quality. As time goes by, the number of tests grows and it can be a real nightmare to maintain the tests, especially when the tests are not modular and simple enough.

Capybara is an awesome Ruby gem that drives a browser over your code so you can exercise your entire application. It has a variety of methods like visit(url) to visit a page, or click_link(“Sign in”) to click a link. It also has an amazing feature which is to retry a command when it’s driving a real browser like Selenium or PhantomJS to handle asynchronous issues. So, if you say click_link(“Sign in”) but there’s no link with the text “Sign in” then Capybara will try to find it over and over until it finds it or it reaches Capybara’s default_wait_time.

This is great when we’re working on a test and it’s not passing yet because our code isn’t done. We want it to try and fail if the link isn’t there. And if that link pops up via a jQuery plugin, we want Capybara to wait for it to show up, not fail fast.

Key benefits

No setup is necessary for Rails and Rack application. It works out of the box.

  • First of all, intuitive API which mimics the language an actual user would use.
  • Secondly, switch the backend your tests run against from fast headless mode to an actual browser with no changes to your tests.
  • Lastly, powerful synchronization features mean you never have to manually wait for asynchronous processes to complete.

Make your resume stand out and become a Certified Capybara Testing Professional. Try free practice tests here!

A great career is just a certification away. So, practice and validate your skills to become Certified Capybara Testing Professional

DSL
Capybara Anatomy

Get industry recognized certification – Contact us

keyboard_arrow_up