Automated testing with Cucumber and Watir-Webdriver

   DevOps and Tools

At Modus Create, we heavily rely on test automation tools to run regression tests and make our client’s products better. We use a mixture of open source tools such as cucumber, selenium webdriver, watirwebdriver, jmeter and protractor.

For the last couple of years we have been using cucumber and watir-webdriver to build robust test automation suites. We believe that contributing to the open source community is vitally important, so we made the test harness public to benefit the community.

https://github.com/ModusCreateOrg/cucumber-watir

Implementing this test suite is very easy. To get started, clone the repo and follow steps in the readme file to install all the dependencies. On Linux or Mac OS X, this is a pretty simple matter. On Windows, it can be more challenging, so we have assembled a set of precompiled and preassembled binaries that can make this easier. Then run the rake all command to run all tests.

We also have a detailed post on how to integrate this in jenkins.

To add new tests, follow along with this screencast:

Automation Testing with Cucumber & Watir-Webdriver from Modus Create on Vimeo.

Steps to add a new feature file

Create a new file under the feature folder named search.feature and copy the following code:

Feature: Search
  In order to make sure that the search feature is working
  As a user I will search for a search term and expect to see valid results

@desktop
Scenario: search for modus create
  Given I am on the duckduckgo home page
  Then I must see the page title "DuckDuckGo"
  Given I fill in the text field "q" with "Modus Create"
  And I click the "S" button
  Then I must see the page title "Modus Create at DuckDuckGo"

Add the URL to the urls.rb file just before the else statement:

when /the duckduckgo home page/i
       base_url="http://duckduckgo.com"

Run the new test:

cucumber features/search.feature

The big benefit of starting with this cucumber test suite is that you don’t have to create all of the features and step definitions from scratch; the set of built-in features and step definitions are inspired by real-world tests from projects that we have completed over the course of several years. By adapting these steps you can reduce the effort needed when testing user-interface heavy projects.

We would love to help you build a full suite of regression tests using this test harness. We also have other useful tools located at labs.moduscreate.com. Give this a whirl and let us know what you think!


Like What You See?

Got any questions?