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
1.2 Navigate between two pages
1.3 Declare custom condition for page being loaded
1.4 Parametrize URI
WatirPump internally uses addressable gem to support URL parametrization.
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
2.2 Locate using a lambda expression
There are two ways of addressing elements with a lambda:
- using element type specific Watir methods see the spec
- 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
2.5 Action macros: clicker
2.6 Action macros: writer
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.