From 4df69bc640f947143fc152a7890fae3849f08cc5 Mon Sep 17 00:00:00 2001 From: ramakrishnajangatisetty Date: Mon, 21 Jul 2025 13:18:18 -0500 Subject: [PATCH] Updated README.md file with Debugging instructions from VS Code debugger and Playwright Debugger --- README.md | 91 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 6a3c859..da6bf07 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,61 @@ Supports cross-browser testing, rich reporting with **Allure**, Dockerized execu - βœ… GitHub Pages publishing for Allure reports --- +🐞 Debugging Playwright Tests in VS Code + You can debug your Playwright tests using VS Code's built-in debugger and the provided launch.json configuration. + + Example launch.json configuration: + + { + "type": "node", + "request": "launch", + "name": "Debug Playwright Test", + "program": "${workspaceFolder}/node_modules/@playwright/test/cli.js", + "args": [ + "test", + "--headed", + "--project=chromium" + ], + "env": { + "TAG": "@smoke", + "BROWSER": "chromium", + "WORKERS": "1", + "RETRIES": "1", + "TEST_ENV": "qa1" + }, + "console": "integratedTerminal", + "internalConsoleOptions": "openOnSessionStart" + } + How to Use + Open your project in VS Code. + Set breakpoints in your test or page files. + Go to the Run & Debug panel (left sidebar). + Select Debug Playwright Test from the dropdown. + Click the green play button (▢️) to start debugging. + The browser will open in headed mode, and you can step through your code, inspect variables, and use all VS Code debugging features. + + You can customize the environment variables and arguments as needed for your test run. + For more details, see VS Code Debugging Documentation. + +🐞 Debugging Tests with Playwright Debugger + You can debug your Playwright tests using the built-in Playwright Inspector or VS Code debugger. The project provides a convenient script for running tests in debug mode with environment variables pre-set. + + Using the Debug Script + To run tests in debug mode with your environment settings, use: + npmΒ runΒ test:env:debugΒ --Β [test-file-or-pattern]Β --debug + test:env:debug is the script defined under package.json file + This command sets the following variables: + TAG='@smoke' BROWSER='chromium' WORKERS=2 RETRIES=1 TEST_ENV='qa1' + The --debug flag opens the Playwright Inspector for interactive debugging. + Example + npmΒ runΒ test:env:debugΒ --Β tests/login.spec.tsΒ --debug + What Happens + The script runs Playwright tests with your specified environment. + The Playwright Inspector UI will open, allowing you to step through your tests, inspect selectors, and interact with the browser. + Tips + You can pass any test file or pattern after -- to target specific tests. + Use breakpoints in your test code or add await page.pause() to pause execution at a specific point. + Add this section to your README.md to help contributors debug tests using your custom script and Playwright’s debugging tools. Let me know if you want this inserted automatically! ## πŸ§ͺ Running Tests Locally @@ -85,33 +140,18 @@ docker run --rm -v $(pwd)/allure-report:/app/allure-report my-playwright-runner ## πŸ“‚ Project Structure -``` e2e-playwright-framework/ -β”œβ”€β”€ tests/ # Test specs -β”œβ”€β”€ pages/ # Page Object Models -β”œβ”€β”€ utils/ # Custom utilities -β”œβ”€β”€ storage/ # Session files -β”œβ”€β”€ allure-results/ # Allure raw data -β”œβ”€β”€ allure-report/ # Allure HTML reports -β”œβ”€β”€ playwright.config.ts # Playwright test config +β”œβ”€β”€ tests/ # Test specs +β”œβ”€β”€ pages/ # Page Object Models +β”œβ”€β”€ utils/ # Custom utilities +β”œβ”€β”€ storage/ # Session files +β”œβ”€β”€ allure-results/ # Allure raw data +β”œβ”€β”€ allure-report/ # Allure HTML reports +β”œβ”€β”€ playwright.config.ts # Playwright test config β”œβ”€β”€ DockerFile.playwright # Dockerfile for CI/CD -β”œβ”€β”€ .github/workflows/ # GitHub Actions workflows -``` -## 🌐 Overriding baseURL - -- By default, `baseURL` is loaded from your environment file (e.g., `env/.env.dev1`). -- To override for a specific run, set the `BASE_URL` variable: - -```sh -BASE_URL=https://another-url.com npm test -``` +β”œβ”€β”€ .github/workflows/ # GitHub Actions workflows -- Or use a different environment: -```sh -TEST_ENV=dev1 npm test -``` ---- ## βœ… GitHub Actions CI/CD @@ -125,7 +165,6 @@ This project uses **GitHub Actions** to automate test execution and reporting. ### πŸ“ Workflow Location -``` .github/workflows/playwright.yml ``` @@ -164,8 +203,6 @@ This project uses **GitHub Actions** to automate test execution and reporting. TEST_ENV=qa1 npx playwright test - - ## πŸ“„ License -MIT Β© 2025 Ramakrishna Jangatisetty \ No newline at end of file +MIT Β© 2025 Ramakrishna Jangatisetty