Home

Awesome

Page Object pattern with WatirPump: how to create and run tests

The goal of this repo is to familiarize web developers with features of WatirPump - a new PageObject library for Watir. Each section of this tutorial covers another feature of WatirPump, gradually increasing the complexity. Each one consists of a brief description and an example test (rspec).

The examples use static HTML pages that can be found in docs directory. They are being served through GitHub Pages under this link. For the sake of local rspec execution a sinatra server is being spin up to serve these pages faster and without the necessity of being online.

Please refer to WatirPump's README for more comprehensive documentation on the API.

1. Pages

1.1 Define a page and open it

see the spec

1.2 Navigate between two pages

see the spec

1.3 Declare custom condition for page being loaded

see the spec

1.4 Parametrize URI

WatirPump internally uses addressable gem to support URL parametrization.

see the spec

1.5 Inheritance

Parts that are common to several pages can be extracted to a shared base page and inherited.

Example specs to be added in the future.

2. Elements

2.1 Locate using Watir methods

see the spec

2.2 Locate using a lambda expression

There are two ways of addressing elements with a lambda:

  1. using element type specific Watir methods see the spec
  2. using element type agnostic element method see the spec

2.3 Collection of elements

Works similarly as single elements. Use watir methods that return collections (e.g. links, buttons, etc.) to find out.

Example specs to be added in the future.

2.4 Action macros: reader

see the spec

2.5 Action macros: clicker

see the spec

2.6 Action macros: writer

see the spec

2.7 query class macro

Use it as a shorthand for instance method creation. Parameters are accepted and no validation of returned value is performed.

Example specs to be added in the future.

3. Forms

3.1 Fill in the form

see the spec

3.2 Fill in and submit the form

see the spec

3.3 Read values from the page

see the spec

4. Components

4.1 Define a component class and locate it on a page

see the spec

4.2 Nesting

see the spec

4.3 Collection of components

see the spec