Test Automation with Cucumber & Capybara
which support for multiple backends, supports Selenium and works in multiple browsers.
The advantage of using Capybara over selenium is being on higher level than selenium , it can be used for other types of automation beside browser automation without changing the user facing simple and intuitive DSL.
Let’s take for example a simple scenario of typing strings to an input textbox:
The difference is clear in terms of simplicity and user friendliness which sets apart capaybara from selenium webdriver.Below is complete example for the reference starting from setting up the folder structure.
I. Base Folder
features – folder to host all your feature files
step_definitions – folder to host all your step definition Ruby files
support – folder to host your configuration files (env.rb)
Gemfile – defines the top-level gems to be used in your project
- describes the features that a user will be able to use in the program
- describes the actions that user will do for each step.
- hosts all configuration files
- a format for describing gem dependencies required to execute Ruby codes
Using terminal go to your root project folder and type: cucumber or bundle exec cucumber
After the run, you should be able to see the results like this:
1 scenario (1 passed)
5 steps (5 passed)