Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Overview

In this tutorial, we will perform some web/UI-based tests using Gwen interpreter along with gwen-web engine.

Gwen uses the Given, When, Then syntax from Gherkin (thus, its name) to implement an interpretation engine that allows users to easily write "automated tests" (i.e. automated scripts), whose steps will be executed implicitly by their corresponding code implementation. Thus, users can focus on writing (executable) specifications without having to do all the implementation hard-work.

Gwen also separates declarative from imperative style Gherkin specifications. Declarative is done in standard .feature files that may include steps defined in while imperative specifications (i.e. "meta-features") are managed in .meta files.

Gwen Web Automation (gwen-web) is an engine that extends Gwen and adds capabilities for easy web testing using Gwen uses Selenium under the hood, by providing a DSL that allows users to interact with the browser without having to write code.

From the many interesting features of Gwen we can highlight the auto-update capability and also the ability taking screenshots, which will be available for analysis after tests are run.

Requirements

  • gwen
  • gwen-web
  • cucumber-json-merge
    • npm install -g cucumber-json-merge

Description

We will use sample code from gwen-web repository, using some instructions available online.

...

Info
titleLearn more

Please see Testing in BDD with Gherkin based frameworks (e.g. Cucumber) for an overview of the possible workflows.

Using Jira and Xray as master

This section assumes using Xray as master, i.e. the place that you'll be using to edit the specifications (e.g. the scenarios that are part of .feature files).

...

The steps correspond to reusable blocks, defined as @StepDef scenarios within meta-feature files like the following one. This is the automation glue.


Code Block
languagejava
titlemeta/google/Google.meta
Feature: Google search meta

@StepDef
Scenario: I have Google in my browser
   Given I start a new browser
    When I navigate to "http://www.google.com"
    Then the page title should be "Google"

@StepDef
Scenario: I do a search for "<query>"
   Given the search field can be located by name "q"
    When I enter "$<query>" in the search field
    Then the page title should contain "$<query>"

@StepDef
Scenario: the first result should open a Gwen page
   Given the first match can be located by css selector ".r > a"
    When I click the first match
    Then the current URL should contain "gwen-interpreter"

...

If we wanted to correct the previous error, in this case, we would need to correct the meta-feature file containing the specification of the step “Then the first result page should open a Gwen page” and run the tests again.


Using Git or other VCS as master

You can edit your .feature and .meta files outside of Jira (eventually storing them in your VCS using Git, for example).

...

Afterward, you can export those features out of Jira based on some criteria, so they are properly tagged, run them and import back the results to correct entities in Xray.

References

...