|
1 | | -# PlaywrightCucumberJavaScript |
2 | | -Playwright Cucumber JavaScript |
| 1 | +# Playwright + Cucumber + JavaScript Test Automation Framework |
| 2 | + |
| 3 | +## Overview |
| 4 | +This framework is built using **Playwright**, **Cucumber**, and **JavaScript** to provide a robust and scalable solution for end-to-end test automation. It supports **parallel execution**, **retry mechanism**, **logging**, and **multi-environment test execution**. |
| 5 | + |
| 6 | +### Key Features |
| 7 | +- **Playwright**: Ensures fast and reliable browser automation. |
| 8 | +- **Cucumber**: Enables behavior-driven development (BDD) with readable test scenarios. |
| 9 | +- **JavaScript**: Provides a dynamic and widely adopted programming language for automation. |
| 10 | +- **Reporting**: Generates Cucumber reports with screenshots and videos attached for failed tests. |
| 11 | +- **Logging**: Uses Winston for structured logging. |
| 12 | +- **Environment Management**: Supports running tests in multiple environments. |
| 13 | +- **Retry Mechanism**: Retries failed tests automatically. |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## Tech Stack |
| 18 | +### 1. Playwright |
| 19 | +[Playwright](https://playwright.dev/) is a modern automation library that supports multiple browsers (Chromium, Firefox, WebKit) and provides robust testing capabilities. |
| 20 | + |
| 21 | +### 2. Cucumber |
| 22 | +[Cucumber](https://cucumber.io/) allows writing test scenarios in Gherkin syntax, making them easy to understand and maintain. |
| 23 | + |
| 24 | +### 3. JavaScript |
| 25 | +JavaScript is a widely used scripting language for web automation and is supported by modern test frameworks. |
| 26 | + |
| 27 | +--- |
| 28 | + |
| 29 | +## Dependencies |
| 30 | +This framework utilizes the following dependencies: |
| 31 | + |
| 32 | +```json |
| 33 | +"dependencies": { |
| 34 | + "@cucumber/cucumber": "^11.2.0", |
| 35 | + "@playwright/test": "^1.50.1", |
| 36 | + "cross-env": "^7.0.3", |
| 37 | + "dotenv": "^16.4.7", |
| 38 | + "fs-extra": "^11.3.0", |
| 39 | + "winston": "^3.17.0" |
| 40 | +} |
| 41 | +``` |
| 42 | + |
| 43 | +- **@cucumber/cucumber**: Cucumber framework for BDD testing. |
| 44 | +- **@playwright/test**: Playwright testing library. |
| 45 | +- **cross-env**: Enables setting environment variables across platforms. |
| 46 | +- **dotenv**: Loads environment variables from `.env` files. |
| 47 | +- **fs-extra**: Provides additional filesystem utilities. |
| 48 | +- **winston**: A powerful logging library for better debugging. |
| 49 | + |
| 50 | +--- |
| 51 | + |
| 52 | +## Project Structure |
| 53 | +* src -> Contains all the features & Typescript code |
| 54 | +* test-results -> Contains all the reports related file |
| 55 | +--- |
| 56 | + |
| 57 | +## Running Tests |
| 58 | +To execute the tests, use the following command: |
| 59 | + |
| 60 | +```sh |
| 61 | +npm test run |
| 62 | +``` |
| 63 | + |
| 64 | +This command will: |
| 65 | +- Run Playwright tests using Cucumber. |
| 66 | +- Capture screenshots and videos for failures. |
| 67 | +- Generate reports after execution. |
| 68 | + |
| 69 | +### Running Tests in Parallel |
| 70 | +The framework is designed to support parallel execution, improving test efficiency. |
| 71 | + |
| 72 | +### Retry Mechanism |
| 73 | +If a test fails, it will automatically retry based on the configured retry settings. |
| 74 | + |
| 75 | +### Running Tests in Different Environments |
| 76 | +You can configure multiple environments using `.env` files and switch between them using `cross-env`. |
| 77 | + |
| 78 | +--- |
| 79 | + |
| 80 | +## Reporting |
| 81 | +This framework utilizes the **default Cucumber report**, which includes: |
| 82 | +- Detailed step execution results. |
| 83 | +- Screenshots and videos attached for failures. |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +## Logging |
| 88 | +Logging is implemented using **Winston**, which provides structured logs to help debug test failures effectively. |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +## Final Thoughts |
| 93 | +This framework provides a strong foundation for **scalable and maintainable** test automation using modern tools and best practices. With **parallel execution, retry mechanisms, and multi-environment support**, it ensures reliability and efficiency in automated testing. |
| 94 | + |
| 95 | +Feel free to contribute, enhance, or modify this framework as needed! |
| 96 | + |
| 97 | +Happy Testing! 🚀 |
| 98 | + |
0 commit comments