|
1 | | -# petstore_playwright |
| 1 | +# Read me for Swagger Petstore API project |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This project uses Playwright for API testing. Playwright enables fast and reliable browser automation across different browsers and devices. |
| 6 | + |
| 7 | +## Prerequisites |
| 8 | + |
| 9 | +Ensure you have the following installed before running the tests: |
| 10 | + |
| 11 | +- **Node.js** (v16 or later recommended) |
| 12 | +- **Visual Studio** |
| 13 | +- **npm or yarn** |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +Clone the repository and install playwright dependencies: |
| 18 | + |
| 19 | +- git clone [email protected]:auto-qa-hub/petstore_playwright.git |
| 20 | +- npm init playwright |
| 21 | + |
| 22 | +## Playwright Installation |
| 23 | + |
| 24 | +Ensure Playwright dependencies are installed: |
| 25 | + |
| 26 | +- npx playwright install |
| 27 | + |
| 28 | +## Running Tests |
| 29 | + |
| 30 | +To execute tests, use the following commands: |
| 31 | + |
| 32 | +### Run All Tests |
| 33 | + |
| 34 | +- npx playwright test |
| 35 | + |
| 36 | +### Run a Specific Test File |
| 37 | + |
| 38 | +- npx playwright test tests/example.spec.js |
| 39 | + |
| 40 | +### Run Tests in Headed Mode |
| 41 | + |
| 42 | +- npx playwright test --headed |
| 43 | + |
| 44 | +### Run Tests with UI Mode |
| 45 | + |
| 46 | +- npx playwright test --ui |
| 47 | + |
| 48 | +## Test Reporting |
| 49 | + |
| 50 | +Generate and view test reports: |
| 51 | + |
| 52 | +- npx playwright show-report |
| 53 | + |
| 54 | +## Writing Tests |
| 55 | + |
| 56 | +Playwright tests are located in the tests/ directory. Example structure: |
| 57 | + |
| 58 | +/tests |
| 59 | + ├── storeTests.spec.ts |
| 60 | + ├── userTests.spec.ts |
| 61 | + ├── petTests.spec.js |
| 62 | + |
| 63 | +Refer to the Playwright documentation - https://playwright.dev/docs/intro for writing and structuring tests. |
| 64 | + |
| 65 | +## CI/CD Integration |
| 66 | + |
| 67 | +To integrate Playwright with CI/CD pipelines, configure .github/workflows/playwright.yml or relevant CI scripts. Example: |
| 68 | + |
| 69 | +name: Playwright Tests |
| 70 | +on: [push, pull_request] |
| 71 | + |
| 72 | +jobs: |
| 73 | + test: |
| 74 | + runs-on: ubuntu-latest |
| 75 | + steps: |
| 76 | + - name: Checkout code |
| 77 | + uses: actions/checkout@v3 |
| 78 | + - name: Install dependencies |
| 79 | + run: npm install |
| 80 | + - name: Install Playwright Browsers |
| 81 | + run: npx playwright install --with-deps |
| 82 | + - name: Run tests |
| 83 | + run: npx playwright test |
| 84 | + |
| 85 | +## Troubleshooting |
| 86 | + |
| 87 | +- Ensure all dependencies are installed (npm install) |
| 88 | + |
| 89 | +- Verify Playwright browsers are installed (npx playwright install) |
| 90 | + |
| 91 | +- Run tests in debug mode: npx playwright test --debug |
0 commit comments