# Gherkin Language and Scriptless Automation Framework

### Introduction to Gherkin Language

Gherkin is a business-readable, domain-specific language that facilitates the description of software behaviors without the need for detailing their implementation. It serves as a bridge between technical and non-technical stakeholders, ensuring everyone has a clear understanding of the requirements and functionalities of the system.

### Key Features of Gherkin

* **Readable by all**: Gherkin uses natural language constructs that are easy to read and understand.
* **Structured format**: It follows a specific syntax with keywords like `Feature`, `Scenario`, `Given`, `When`, `Then`, and `And`.
* **Supports BDD**: Gherkin is widely used in Behavior-Driven Development (BDD), where it helps in defining the behavior of the system in a structured manner.

### Basic Syntax

* **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.

#### Example

```gherkin
Feature: User Login
  This feature allows users to log in to the application.

  Scenario: Successful login with valid credentials
    Given the user is on the login page
    When the user enters a valid username and password
    And the user clicks the login button
    Then the user should be redirected to the dashboard
```

### Comparison with Cucumber Framework

#### What is Cucumber?

Cucumber is a testing framework that supports BDD by running automated acceptance tests written in Gherkin. It provides a way to write tests that anyone can understand, regardless of their technical knowledge.

#### Key Differences Between Gherkin and Cucumber

* **Gherkin**: A language for writing tests in a business-readable format.
* **Cucumber**: A framework that executes Gherkin-written tests by mapping them to code (step definitions).

#### Challenges with Cucumber

1. **Step Definitions**:
   * Cucumber requires mapping Gherkin steps to step definitions written in a programming language. This mapping can lead to errors if not managed correctly.
   * Mistakes in the mapper can result in Cucumber creating new step definitions, causing redundancy and increased maintenance.
   * As the number of test cases grows, the number of step definitions increases, leading to more code and maintenance overhead for engineers.
2. **Performance Issues**:
   * Loading both feature files and step definitions simultaneously can lead to performance issues, especially with long-running tests.

### Scriptless Automation Framework

In contrast to Cucumber, the Scriptless Automation Framework aims to simplify the automation process by eliminating the need for step definitions and reducing the maintenance burden.

#### Key Features of Scriptless Automation Framework

* **Template-Driven**: The framework provides a template where the business team can write user stories. This template guides the automation process without needing detailed coding.
* **Locator Provision**: Developers only need to provide locators for web elements, making it easier to maintain.
* **Directory-Based Organization**: Test cases are organized in specific directories as per the documentation, simplifying the structure.
* **No Coding Required**: Once the template is filled and locators are provided, no additional coding is necessary. This reduces maintenance and simplifies updates.

#### Benefits of Scriptless Automation Framework

1. **Reduced Maintenance**: By eliminating step definitions, the framework reduces the code that needs to be maintained.
2. **Simplified Process**: Business teams can directly write user stories in the template, making it easier for non-technical stakeholders to contribute.
3. **Scalability**: The framework scales better with the increasing number of test cases since there are no step definitions to manage.
4. **Consistency**: Ensures consistency in test case writing and execution, reducing the chances of errors.

#### Example Usage

**Template**

```
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 Gherkin**

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

  Scenario: Load Gmail and enter email
    Given the user is on PAGE_NAME: "gmail"
    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://gmail.com"
    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"
```

### Conclusion

The Gherkin language and Cucumber framework offer a powerful combination for behavior-driven development and automated testing. However, managing step definitions in Cucumber can become cumbersome as the test suite grows. The Scriptless Automation Framework addresses these challenges by providing a template-driven approach that simplifies the automation process, reduces maintenance, and makes it accessible to non-technical stakeholders. By using this framework, teams can achieve more efficient and maintainable test automation, allowing them to focus on delivering high-quality software.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.precisiontestautomation.in/scriptlessautomation/get-started/gherkin-language-and-scriptless-automation-framework.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
