Test Automation with Cucumber - Capybara - Selenium in Ruby

For a company which uses agile development methodology, test automation is very critical. However meaning of test automation in agile is little bit different from the automation activities in waterfall or V-model development methodology. In agile a user story should be automated before the feature is developed and when it is ready then automated test cases can be run to test user stories.

For agile test automation, using only selenium is not enough or is not the best approach because of the written test cases. There should be another tool used for writing test cases which automation script can understand and perform what test cases/user stories explain. Cucumber is the tool what I want to explain. With Cucumber we can write test cases and with language called Gherkin which is very easy and understandable for everyone. So we just need to learn the keywords like "Given, When, Then, Examples, Scenario, Scenario Outline, ..." they are not too many, for more information about Gherkin you can visit this page and this page

Capybara is another test automation framework which is developed by Jonas Nicklas, it is like selenium but the number of functions is fewer than the functions in Selenium. And I can say that it is more powerful than Selenium, depends on my little experience. Maybe worst part of the Cucumber is that you need to write your test cases in Ruby, no support for other languages. You can more information about Capybara from this page

Using Cucumber with Capybara or Selenium, you need to first create your testcase.feature file and create your script file which reflects the feature file. As a first sight, this may mean that you are trying two times instead of just writing your test scripts file. However, Cucumber is very effective and it suggest you to add scripts, then you just need to write inside of the functions, as you can see in the following command: 
cucumber test/features/ --dry -run

Another good part of the Cucumber/Capbybara you can select your webdriver. You can select :webkit, :chrome, :selenium (as firefox) and :poltergiest. If you want to run headless-testing, which means that there is no browser opens and closes but test is running and and it gives you the result, then you need change default driver instead of selenium as following from test/feature/support/env.rb:

     #Capybara.default_driver = :selenium 
     Capybara.default_driver = :poltergeist       

You can download my repository which goes to Amazon.com and login with correct user and password and check the error message for non-correct password. Don't forget to add your credentials.


Popular posts from this blog

Testing WEB Sevices and Automating SOAP Services

Performance Testing on CI: Locust is running on Jenkins

Change Default Timeout and Wait Time of Capybara

Performance Testing on CI: Integration of Locust and Jenkins

Create an Alias for Interactive Console Work: Selenium and Capybara