Complete Test with Verification

Web test drivers, such as Watir and Selenium WebDriver, drive browsers. However, to use them effectively for testing, we need to put them in a test framework that defines test structures and provides assertions (performing checks in test scripts after driving the application to a certain point).

In the context of web testing, typical checks are as follows:

  • Verify that specific texts are present

  • Verify the page title

  • Verify a link is present

  • Verify a web control is present or hidden

Basics of RSpec

RSpec is a popular test framework in Ruby. We can perform a standard gem installation to get it on our system.

Executing an RSpec file

By convention, the RSpec file names end with _spec.rb. We can run an RSpec test script by typing rspec, followed by the script name with an extension of .rb.

Get hands-on with 1200+ tech skills courses.