๐จโ๐ผGherkin Template for Web Automation
Introduction
This documentation provides a comprehensive guide to using the Gherkin language template for web automation. Gherkin is a business-readable, domain-specific language that allows you to describe software's behaviour without detailing how that functionality is implemented. This makes it easier to communicate requirements and test scenarios between technical and non-technical stakeholders.
Gherkin Language Basics
Gherkin syntax uses a set of special keywords to define the structure of tests. The main keywords are:
Feature: Describes the feature under test.
Scenario: Defines a particular scenario to be tested.
Given: Sets up the initial context of the scenario.
When: Describes the action that triggers the scenario.
Then: Specifies the expected outcome of the scenario.
And: Used to combine multiple Given, When, or Then steps.
Template Overview
This template helps you to structure your web automation test cases using Gherkin. The template maps web automation actions and validations into Gherkin steps, ensuring clarity and consistency.
Key Components
PAGE_NAME: The name of the page or context.
WAIT_TYPE: The type of wait condition (e.g., visibility, presence).
SCROLL_TYPE: The type of scroll action (e.g., none, to element).
ELEMENT_NAME: The name or identifier of the web element.
ACTIONS: The action to be performed (e.g., click, send keys).
SEND_KEYS: The text or keys to be sent to an element.
VALIDATION: The type of validation (e.g., text, attribute).
VALIDATION_TYPE: The validation method or expected outcome.
Gherkin Template Structure
General Structure
Handling Multiple Given Steps with PAGE_NAME
In some scenarios, the PAGE_NAME needs to be persistent across multiple steps until a new PAGE_NAME is specified. The following example demonstrates how to handle multiple Given steps and ensure the PAGE_NAME persists:
Example with Persistent PAGE_NAME
In this example:
First Given Step:
This step sets the PAGE_NAME to "LoginPage".
Subsequent Steps:
These steps apply to the "LoginPage".
New Given Step:
This step updates the PAGE_NAME to "HomePage".
Remaining Steps:
These steps apply to the "HomePage".
Example
Hereโs how to use the Gherkin template to describe a web automation scenario for logging into Gmail and verifying the email field:
Web Automation Template Data
Converted to Gherkin
Additional Examples
Example: Adding an Item to the Cart
Web Automation Template Data
Converted to Gherkin
Conclusion
This documentation provides a structured approach to using Gherkin language for web automation, ensuring clear and maintainable test scenarios. By following this template, you can effectively describe and automate various web interactions in a business-readable format.
Last updated
Was this helpful?