Skip to content

Rakshitha-Ramesh-1996/Playwright_testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Playwright Testing Project

A collection of Playwright end-to-end tests demonstrating the basics of automated testing. This project covers key concepts such as test execution, element locators, assertions, debugging, screenshots, and more.


Table of Contents


Prerequisites


Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/Playwright_testing.git
    cd Playwright_testing
  2. Install dependencies:

    npm install
  3. Install Playwright browsers (if not already installed):

    npx playwright install

Running the Tests

  • Run all tests:

    npx playwright test
  • Run a specific test file:

    npx playwright test tests/example.spec.ts
  • Run tests in headed mode (visible browser):

    npx playwright test --headed
  • Run tests in debug mode:

    npx playwright test --debug
  • Run tests in a specific browser (Chromium, Firefox, or WebKit):

    npx playwright test --project=chromium

Writing a Test

Example test file: tests/example.spec.ts

import { test, expect } from '@playwright/test';

test('basic navigation test', async ({ page }) => {
  await page.goto('https://playwright.dev');
  await expect(page).toHaveTitle(/Playwright/);
});

Run the test with:

npx playwright test tests/example.spec.ts

Debugging Tips

  • Use the Playwright Inspector:

    npx playwright test --debug
  • Pause execution in a test:

    await page.pause();
  • Use VS Code breakpoints for interactive debugging.


Screenshots & Videos

  • Capture a screenshot:

    await page.screenshot({ path: 'screenshot.png' });
  • Record a video (configure in your test or Playwright config):

    test.use({ video: 'on' });

Continuous Integration

Playwright is CI-friendly. For example, you can set up GitHub Actions with a workflow like this:

name: Playwright Tests

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '14'
      - run: npm install
      - run: npx playwright install
      - run: npx playwright test

Place this in .github/workflows/playwright.yml.


Contributing

Contributions are welcome! Please fork the repository and submit pull requests. For major changes, please open an issue first to discuss what you would like to change.


License

This project is licensed under the MIT License.


Happy Testing! 🚀


This README gives a clear guide on how to set up and work with your Playwright tests, making it easier for collaborators to get started. Let me know if you need any adjustments!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published