How To Write Your First Playbook

Repository

At that moment we have separate repository for playbooks for SS: https://github.com/subutai-io/playbooks/

This repository contains sources required for executing Serenity tests.

Selenium and Serenity

We are using Serenity BDD library in our automated acceptance tests. You can find more details about Serenity here.

Serenity uses well-known Selenium as library for automated web tests. In our current state all tests are web-based, so all of them use Selenium.

Repository Structure

  1. The root level of the repository contains a Maven POM-file and scripts required for running tests in different cases:
image

image

  1. The directory src/test/resources contains files, options, and the browser profile required for tests and stories itself:
image

image

  1. The directory src/test/java contains sources of the test steps, web-pages and additional classes:
image

image

Story Files

Story files use human-readable text to describe what is going on during tests and the expected results.

Story files contain one or more scenarios. Each scenario should be a simple task with well defined steps and results.

An example of such a scenario can be found here:

image

image

Story files use Given/When/Then patterns to implement steps.

In addition to Given/When/Then there is one other action you may need during test development. {And} pattern, just use action from previous line, to simplify reading.

Here is the detailed Serenity BDD guide: http://www.thucydides.info/docs/serenity/. You can use first parts of it to get familiar with BDD.

Given/When/Then

Given/When/Then is commonly used system for describing cases: * Given - describes a state of the system that should be used as base for future steps.

  • When - describes an action that a user should perform to get required results.
  • Then - describes a state of the system that user should observe to validate results after previous action.

Each Given/When/Then line should have its own JBehave implementation written in Java with its required classes and methods.

The current implementation provides us the following source files for describing steps:

image

image

And it contains ordinary Java code with a special notation to bind it to a Story file line:

image

image

Steps described in test/java/od/steps/serenity/SubutaiSteps.java file implement behavior on web-pages using Selenium methods, like type, click, containsText etc:

image

image

Web-pages

All objects used to interact with web-pages should be described using special files:

image

image

It's common to use XPath locators to reference web-elements:

image

image

After referencing a web-page element you can start using it with required methods.