This project automates end-to-end testing using Playwright, TypeScript, and Cucumber (BDD framework).
Ensure you have the following installed:
- Node.js (LTS recommended) → Download
- Playwright → Installed via dependencies
- Cucumber.js → Installed via dependencies
- Clone the repository:
git clone https://github.com/your-repo/PlaywrightTypeScriptUsingBDD.git cd PlaywrightTypeScriptUsingBDD
- Install dependencies:
npm install
- Install Playwright browsers:
npx playwright install
📂 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
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 |
npx cucumber-js
npx cucumber-js --tags "@positive"
npx cucumber-js --tags "@negative"
HEADLESS=false npx cucumber-js
"generate_multiplehtml_report": "node report.js",
If you encounter issues, try:
npx playwright test --debug
Playwright-TypeScript.mp4
This project is licensed under the MIT License.