3

I am manual QA engineer with 22 years of experience.
Now I need to work on automating a Web App in Cucumber/Ruby using Capybara libraries using Selenium to drive the browser (Firefox). Rspec for the test interface.
Can anyone recommend a good book or course for Selenium working with Capybara? I have trouble as an older guy googling everything and I like more structure with a class or good book as opposed to searching through something like RubyDocs.
I'd like to have something with more structure.

1

I have not worked on Cucumber/Ruby (I work on Selenium-Java) so I will restrain myself from suggesting you any books regarding that but what I can tell you is start small. By starting small I mean read the basics of Ruby , Cucumber , etc. Write basic programs to get a grasp on the fundamental concepts. From there go 1 level up keep increasing the complexity.

Search online articles or videos regarding the stuff that you are stuck with or want to get a better understanding.

Last but not the least...Practice...Practice...Practice...All The Best.

0

The Cucumber Book will help you with understanding Cucumber, and all the steps are written in Ruby for the examples, which will help you quite a bit.

Inside, you will also find a little bit about Capybara.

Note, I have not used it as a way to learn the Ruby version of Cucumber, however it has helped me to develop my knowledge of other Cucumber based frameworks.

The link that I've given is the download link to the PDF version of the book.

I wish you the best in learning automation skills with Ruby, Capybara and Cucumber.

If you want to push yourself in the future, try to make the step definitions that you write as human readable as possible. Not only will this help you in the future, by giving you a better understanding of how ruby works, but will also mean that your code will speak for itself, which is always brilliant.

0

My personal top two hints, from recent experience, are:

  • Use good page object patterns
  • Use helpers to dry up tests

Ultimately this leads to specs that look like this (real example):

scenario 'happy thru all the stages', :happy do
  complete_primary_auto(p, auto)
  submit_form
  complete_primary_driver(p)
  submit_form
  fill_out_policy_3smf(p)
  submit_form
  expect(page).to have_css p.exits
end

With all the methods such as complete_primary_driver and locators such as exits being defined in helper and Page Object files.

I would also focus on rspec-capybara and question if the cucumber piece is critical. I have seen several organizations adopt Cucumber quite enthusiastically, often with a major promoter, with great justification, only to see it dropped with a year, frequently because users never get how to write good specs with good programming practices. Before you know it you are explaining DRY and other concepts. So I just focus on rspec-capybara feature specs that run in the browser. YMMV of course and you may not have a choice in the matter at this point.

Other hints I've learned:

  • Use a CI server such as Jenkins or CircleCI*
  • Use a service such as Sauce Labs or Browserstack*
  • Expect maddening intermittent failures and allow time for working on them

* = my preference

I would also recommend the following:

http://betterspecs.org/ Good practices on how to write tests. Highlights:

  • How to describe your methods
  • Use contexts
  • Keep your description short
  • Single expectation per test*
  • Test all possible cases
  • Use subject
  • Use let and let!
  • Mock and Stub
  • Create only the data you need
  • Use factories and not fixtures
  • Easy to read matcher
  • Shared Examples
  • Test what you see
  • Stub HTTP requests

* the one guidelines here that I definitely do NOT follow for feature tests is one expectation for tests. I intentionally go against this guideline for feature tests because of speed. Browser tests are quite slow and if I want to check for 10 elements correctly redisplaying user input on an error screen on a sad path it simply isn't practical to have 10 separate tests with each doing all the required setup and running through the UI. So my feature tests have multiple expects.

https://www.sitepoint.com/learn-the-first-best-practices-for-rails-and-rspec/ also has some good first timer hints on setup such as:

  • Installing RSpec
  • Shoulda-Matchers Configuration
  • Database Cleaner Configuration
  • Capybara Setup
  • Faker and Factory Girl Setup
  • Feature Spec

If the links go bad you can search for the section header, prefix search with rspec

In respect to your desire for more formal course style material I can recommend:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.