aljazarifoundation / PlaywrightTypeScriptUsingBDD

this is the main repository testing for automation web using cucumber

Repository from Github https://github.comaljazarifoundation/PlaywrightTypeScriptUsingBDDRepository from Github https://github.comaljazarifoundation/PlaywrightTypeScriptUsingBDD

Playwright TypeScript BDD Automation

This project automates end-to-end testing using Playwright, TypeScript, and Cucumber (BDD framework).

πŸ“Œ Prerequisites

Ensure you have the following installed:

  • Node.js (LTS recommended) β†’ Download
  • Playwright β†’ Installed via dependencies
  • Cucumber.js β†’ Installed via dependencies

πŸš€ Installation

  1. Clone the repository:
    git clone https://github.com/your-repo/PlaywrightTypeScriptUsingBDD.git
    cd PlaywrightTypeScriptUsingBDD
  2. Install dependencies:
    npm install
  3. Install Playwright browsers:
    npx playwright install

πŸ“‚ Project Structure

πŸ“‚ PlaywrightTypeScriptUsingBDD
 ┣ πŸ“‚ features/                # Cucumber feature files (Scenarios & Gherkin syntax)
 ┣ πŸ“‚ steps/                   # Step definitions mapping Gherkin steps to Playwright actions
 ┣ πŸ“‚ support/                 # Hooks, utilities, and helper functions for tests
 ┣ πŸ“‚ reports/                 # Generated test reports (HTML & JSON)
 ┣ πŸ“œ package.json             # Project dependencies & npm scripts
 ┣ πŸ“œ package-lock.json        # Auto-generated dependency lock file
 ┣ πŸ“œ report.js                # Script for generating multiple-cucumber-html-reporter
 ┣ πŸ“œ tsconfig.json            # TypeScript configuration
 ┣ πŸ“œ cucumber.js              # Cucumber configuration file
 ┣ πŸ“œ playwright.config.ts     # Playwright test configuration (Browsers, timeouts, etc.)
 β”— πŸ“œ README.md                # Documentation and setup instructions

πŸ“ Writing Tests

Example Feature File (features/login.feature)

Feature: Login to Sauce Demo
  As a user
  I want to be able to log in with valid and invalid credentials
  So that I can access the inventory page or see an error message

  @positive
  Scenario Outline: Successful Login
    Given I navigate to the Sauce Demo login page
    When I enter username "<username>" and password "<password>"
    And I click the login button
    Then I should see the products page

    Examples:
      | username       | password      |
      | standard_user | secret_sauce |

  @negative
  Scenario Outline: Invalid Login
    Given I navigate to the Sauce Demo login page
    When I enter username "<username>" and password "<password>"
    And I click the login button
    Then I should see an error message

    Examples:
      | username | password   |
      | invalid  | wrong_pass |

▢️ Running Tests

Run All Scenarios

npx cucumber-js

Run Only Positive Scenarios

npx cucumber-js --tags "@positive"

Run Only Negative Scenarios

npx cucumber-js --tags "@negative"

Run Tests in Headed Mode (Non-Headless)

HEADLESS=false npx cucumber-js

πŸ“Š Generating Reports

Generate Multiple Cucumber HTML Report

"generate_multiplehtml_report": "node report.js",

πŸ›  Debugging

If you encounter issues, try:

npx playwright test --debug

πŸ“Ή Video

Playwright-TypeScript.mp4

πŸ“œ License

This project is licensed under the MIT License.

About

this is the main repository testing for automation web using cucumber


Languages

Language:TypeScript 72.7%Language:Gherkin 18.2%Language:JavaScript 9.1%