ScriptlessAutomation
  • 👋Welcome to Scriptless Automation
  • Discover More About Automation
    • ⚙️Automation platform intro
    • 💡Advantages of Scriptless Automation
    • 🚀Release Notes
      • 📖Open Code
      • 📕License Code
  • Product tools
    • 📪Pre-request Tools
    • 🔧Project Dependencies
  • Automation Architecture
    • 🎨Flow diagram
  • Get Started
    • 🛠️Start with Automation
    • 📖Open Code Automation
      • 🌏Web Automation
      • ↔️API Automation
    • 🏢Maven Configuration
    • 🗜️Setting Up Maven Project in IntelliJ IDEA
    • 🎛️Scriptless Config
      • 🕸️BrowserConfiguration
        • chrome.properties
      • 👥CommunicationConfiguration
        • SlackConfiguration.properties
      • 📧MailConfiguration
        • gmailCredentials.properties
      • 🛂ReportConfiguration
        • extentReportConfiguration.properties
      • 🕵️TestManagementConfiguration
        • testRail.properties
        • zephyrscale.properties
        • testiny.properties
      • ⚙️testNgConfiguration.properties
    • 🍱TestData Configuration
    • 👨‍💼Gherkin Language and Scriptless Automation Framework
  • Automation Import Notes
    • 🎨Points to Remember
  • Automation Platforms
    • 👾ScriptlessApi Automation
      • 🖊️Introduction
      • 🗜️Api Automation Setup
      • 🔃Supported API Request Types
      • 🪧API Automation Template
      • 📚Example of API Requests
        • ⬇️GET
        • ↕️POST
        • ⤵️PUT
        • ❌DELETE
      • 🎯API Response Validation
      • 👨‍👦API Dependent TestCase
      • 📝Store API Variables
      • 📔API with JSON body
      • 🙋‍♂️Api Wait
      • 🗜️API Schema Validation
      • 🏗️API Tailor-Made coding
      • 👨‍🦯API Support Generator
      • ↘️Api Response Store Objects
      • ✍️API Test Report
      • 🚃Api Response Type Validation
    • 🌐ScriptlessWeb Automation
      • 🖊️Introduction
      • 🗜️Web Automation Setup
      • 🪧Web Automation Template
      • 🧮page_object_locators
      • 📜Web Automation Key Phrases
        • 📃PAGE_NAME
        • ⌛WAIT_TYPE
        • 📜SCROLL_TYPE
        • 👨‍💼ELEMENT_NAME
        • 🏎️ACTIONS
        • ⌨️SEND_KEYS
        • ✔️VALIDATION
        • ✅VALIDATION_TYPE
      • 👨‍👦Web Dependent Test Case
      • 🐒MOCK
      • 🛂AutomationAsserts
      • 🏗️Web Tailor-Made coding
      • 📝Store Web Variables
      • 🤼‍♀️Web & API integration
      • 🖇️Dynamic Strings
      • 🗣️ReadFile Annotation for Custom Code
      • 🖼️Page_Comparison
      • 👨‍💼Gherkin Template for Web Automation
    • 📱Mobile Automation
  • 🪶Automation features
    • 🌲Environment and System Variables
    • 🗝️KeyInitializers
      • Types of KeyInitializers
    • ✍️Reporting
      • Dashboard
      • Category
      • Tests
        • Screenshot Section
    • 👯Parallel Testing
    • 🏗️Tailor-Made Coding
  • ⏩Automation Demo
Powered by GitBook
On this page
  • Introduction
  • Gherkin Language Basics
  • Template Overview
  • Gherkin Template Structure
  • Additional Examples
  • Conclusion

Was this helpful?

  1. Automation Platforms
  2. ScriptlessWeb Automation

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

Feature: <Feature Name>
  <Description of the feature>

  Scenario: <Scenario Name>
    Given the user is on PAGE_NAME: "<PAGE_NAME>"
    When the user waits for WAIT_TYPE: "<WAIT_TYPE>" and scrolls using SCROLL_TYPE: "<SCROLL_TYPE>" on ELEMENT_NAME: "<ELEMENT_NAME>" to perform ACTIONS: "<ACTIONS>" with data SEND_KEYS: "<SEND_KEYS>"
    Then the user waits for WAIT_TYPE: "<WAIT_TYPE>" and scrolls using SCROLL_TYPE: "<SCROLL_TYPE>" on ELEMENT_NAME: "<ELEMENT_NAME>" to validate VALIDATION: "<VALIDATION>" with VALIDATION_TYPE: "<VALIDATION_TYPE>"
    Then the user waits for WAIT_TYPE: "<WAIT_TYPE>" and scrolls using SCROLL_TYPE: "<SCROLL_TYPE>" on ELEMENT_NAME: "<ELEMENT_NAME>" and verifies VALIDATION_TYPE: "<VALIDATION_TYPE>"
    Then the user scrolls using SCROLL_TYPE: "<SCROLL_TYPE>" on ELEMENT_NAME: "<ELEMENT_NAME>" and verifies VALIDATION_TYPE: "<VALIDATION_TYPE>"
    When the user scrolls using SCROLL_TYPE: "<SCROLL_TYPE>" on ELEMENT_NAME: "<ELEMENT_NAME>" to perform ACTIONS: "<ACTIONS>" with data SEND_KEYS: "<SEND_KEYS>"
    When the user waits for WAIT_TYPE: "<WAIT_TYPE>" on ELEMENT_NAME: "<ELEMENT_NAME>" to perform ACTIONS: "<ACTIONS>" with data SEND_KEYS: "<SEND_KEYS>"
    When the user interacts with ELEMENT_NAME: "<ELEMENT_NAME>" to perform ACTIONS: "<ACTIONS>" with data SEND_KEYS: "<SEND_KEYS>"
    Then the user verifies ELEMENT_NAME: "<ELEMENT_NAME>" for VALIDATION_TYPE: "<VALIDATION_TYPE>"
    Then the user scrolls using SCROLL_TYPE: "<SCROLL_TYPE>" on ELEMENT_NAME: "<ELEMENT_NAME>" to validate VALIDATION: "<VALIDATION>" with VALIDATION_TYPE: "<VALIDATION_TYPE>"
    Then the user interacts with ELEMENT_NAME: "<ELEMENT_NAME>" to validate VALIDATION: "<VALIDATION>" with VALIDATION_TYPE: "<VALIDATION_TYPE>"

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

Feature: Multi-Page Workflow
  This feature describes a workflow involving multiple pages.

  Scenario: Navigate through multiple pages
    Given the user is on PAGE_NAME: "LoginPage"
    When the user waits for WAIT_TYPE: "NONE" and scrolls using SCROLL_TYPE: "NONE" on ELEMENT_NAME: "NONE" to perform ACTIONS: "LOAD_URL" with data SEND_KEYS: "https://www.loginpage.com/"
    Then the user waits for WAIT_TYPE: "VISIBILITY" and scrolls using SCROLL_TYPE: "NONE" on ELEMENT_NAME: "username" to perform ACTIONS: "SEND_KEYS" with data SEND_KEYS: "testuser"
    Given the user is on PAGE_NAME: "HomePage"
    When the user waits for WAIT_TYPE: "VISIBILITY" and scrolls using SCROLL_TYPE: "NONE" on ELEMENT_NAME: "menuButton" to perform ACTIONS: "CLICK" with data SEND_KEYS: "NONE"
    Then the user waits for WAIT_TYPE: "PRESENCE" and scrolls using SCROLL_TYPE: "TO_ELEMENT" on ELEMENT_NAME: "dashboard" and verifies VALIDATION_TYPE: "IS_PRESENT"

In this example:

  1. First Given Step:

    Given the user is on PAGE_NAME: "LoginPage"
    • This step sets the PAGE_NAME to "LoginPage".

  2. Subsequent Steps:

    When the user waits for WAIT_TYPE: "NONE" and scrolls using SCROLL_TYPE: "NONE" on ELEMENT_NAME: "NONE" to perform ACTIONS: "LOAD_URL" with data SEND_KEYS: "https://www.loginpage.com/"
    Then the user waits for WAIT_TYPE: "VISIBILITY" and scrolls using SCROLL_TYPE: "NONE" on ELEMENT_NAME: "username" to perform ACTIONS: "SEND_KEYS" with data SEND_KEYS: "testuser"
    • These steps apply to the "LoginPage".

  3. New Given Step:

    Given the user is on PAGE_NAME: "HomePage"
    • This step updates the PAGE_NAME to "HomePage".

  4. Remaining Steps:

    When the user waits for WAIT_TYPE: "VISIBILITY" and scrolls using SCROLL_TYPE: "NONE" on ELEMENT_NAME: "menuButton" to perform ACTIONS: "CLICK" with data SEND_KEYS: "NONE"
    Then the user waits for WAIT_TYPE: "PRESENCE" and scrolls using SCROLL_TYPE: "TO_ELEMENT" on ELEMENT_NAME: "dashboard" and verifies VALIDATION_TYPE: "IS_PRESENT"
    • 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

PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
gmail,NONE,NONE,NONE,LOAD_URL,https://www.gmail.com/,NONE,NONE
gmail,VISIBILITY,NONE,email,SEND_KEYS,prabhatgaddam,NONE,NONE
gmail,VISIBILITY,NONE,email,NONE,NONE,NONE,ATTRIBUTE_VALUE_PRESENT

Converted to Gherkin

Feature: Gmail Login
  This feature allows users to log in to Gmail.

  Scenario: Load Gmail and enter email
    Given the user performs ACTIONS: "LOAD_URL" with data SEND_KEYS: "https://www.gmail.com/"
    Given the user is on PAGE_NAME: "gmail"
    Then the user waits for WAIT_TYPE: "VISIBILITY" and scrolls using SCROLL_TYPE: "NONE" on ELEMENT_NAME: "email" to perform ACTIONS: "SEND_KEYS" with data SEND_KEYS: "prabhatgaddam"
    Then the user waits for WAIT_TYPE: "VISIBILITY" and scrolls using SCROLL_TYPE: "NONE" on ELEMENT_NAME: "email" and verifies VALIDATION_TYPE: "ATTRIBUTE_VALUE_PRESENT"

Additional Examples

Example: Adding an Item to the Cart

Web Automation Template Data

PAGE_NAME,WAIT_TYPE,SCROLL_TYPE,ELEMENT_NAME,ACTIONS,SEND_KEYS,VALIDATION,VALIDATION_TYPE
shoppingPage,VISIBILITY,NONE,itemButton,CLICK,NONE,NONE,NONE
shoppingPage,VISIBILITY,NONE,cart,VALIDATE,NONE,text,Item added

Converted to Gherkin

Feature: Shopping Cart
  This feature allows users to add items to the shopping cart.

  Scenario: Add an item to the cart
    Given the user is on PAGE_NAME: "shoppingPage"
    When the user waits for WAIT_TYPE: "VISIBILITY" and scrolls using SCROLL_TYPE: "NONE" on ELEMENT_NAME: "itemButton" to perform ACTIONS: "CLICK" with data SEND_KEYS: "NONE"
    Then the user waits for WAIT_TYPE: "VISIBILITY" and scrolls using SCROLL_TYPE: "NONE" on ELEMENT_NAME: "cart" to validate VALIDATION: "text" with VALIDATION_TYPE: "Item added"

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.

PreviousPage_ComparisonNextMobile Automation

Last updated 11 months ago

Was this helpful?

🌐
👨‍💼