Latest post from this blog

Test Scenarios vs. Test Cases: Understanding the Basics

What Are Test Scenarios Test scenarios represent high-level ideas or conditions that need to be validated to ensure the application works as expected. They provide a broader perspective and are typically used during the test planning phase. Purpose: To capture the "what to test" without going into granular details. Example of a Test Scenario: Verify that a user can successfully log in to the application using valid credentials. Verify the behavior of the login page when invalid credentials are entered. Verify the application behavior when the login button is clicked without entering any credentials. What Are Test Cases Test cases are detailed documents that define the specific steps to execute a test. They cover inputs, execution steps, expected results, and actual outcomes. Purpose: To guide the tester step-by-step on "how to test." Example of a Test Case (for the first scenario): Test Case ID TC_01_Login_Valid_Credentials Test Scenario Verify user login with val...

Understanding the Scenario Outline in Gherkin Language

Introduction 
In Gherkin language, scenario outline is the keyword which is used to run the same scenario multiple times.

It is also defined as "Scenario outlines are used when the same test is performed multiple times with a different combination of values."

The keyword scenario outline can also be used by the name Scenario Template. In other words, the keyword Scenario Template is a synonym of scenario outline.

Scenario outline is exactly similar to the scenario structure, but the only difference is the provision of multiple inputs. In order to use scenario outlines, we do not need any smart idea, we just need to copy the same steps and re-execute the code.

Key Features of Scenario Outline
  • Parameterization: Variables are defined in angle brackets (< >) and replaced with values from the Examples table during execution.
  • Reusability: Instead of writing separate scenarios for each data set, a single scenario outline can handle all cases.
  • Clarity: The Examples table makes it easy to understand the different input combinations.
Structure of a Scenario Outline
A Scenario Outline consists of:
  • Scenario Outline: The generic scenario definition.
  • Steps: Regular Gherkin steps with placeholders (e.g., <username>, <password>).
  • Examples Table: A table listing the values for placeholders.
Example:
Feature: Login Functionality

  Scenario Outline: Verify login with.                  different  credentials
    Given The user is on the login page
    When The user enters "<username>"            and ".   <password>"
    Then The user should see the "<result>"        message

  Examples:
    | username | password | result |
    | admin | admin123 | Login Successful |
    | user | user123 | Login Successful |
    | invalidUser | invalidPass | Login Failed |

Difference between Scenario and Scenario Outline

Scenario:
  1. Definition: Represents a single concrete example of a functionality to be tested.
  2. Purpose: Used for testing a specific situation with fixed input data.
  3. Data Handling: Input data is written directly in the steps.
  4. Reusability: Not reusable for multiple data sets. Separate scenarios are needed for each set of data.
  5. Keyword: Defined using the Scenario keyword.
  6. Examples Table: Does not use an Examples table.
Example 
Scenario: Login with valid credentials
  Given the user is on the login page
  When the user enters "testuser" and "password123"
  Then the user should be redirected to the homepage

Scenario Outline:
  1. Definition: Represents a template that can run the same scenario multiple times with different sets of input data.
  2. Purpose: Used for testing the same functionality with multiple data sets.
  3. Data Handling: Input data is provided through an Examples table.
  4. Reusability: Highly reusable as it iterates through all the rows in the Examples table.
  5. Keyword: Defined using the Scenario Outline keyword.
  6. Examples Table: Uses an Examples table to provide multiple sets of data.
Example 
Scenario Outline: Login with multiple credentials
  Given the user is on the login page
  When the user enters "<username>" and ". <password>"
  Then the user should be redirected to           the  homepage

Examples:
  | username | password |
  | testuser1 | password123 |
  | testuser2 | pass456 |


Comments

Popular posts from this blog

Common Exception in Selenium

Test Scenarios vs. Test Cases: Understanding the Basics

Handling Shadow DOM in Selenium WebDriver

Handling HTTPS Websites and SSL Certificate Errors in Selenium

Normalize-space Function In Xpath