Playwright Automation

Prasanth Karuppaiya

profile
Playwright Automation
profile
FREE
180 mins

Playwright is a modern end-to-end (E2E) testing framework developed by Microsoft. It allows you to automate web browsers like Chromium, Firefox, and WebKit with a single API. It’s widely used for UI testing, cross-browser testing, and headless testing.

You can write Playwright tests in multiple languages, but the most common and powerful combinations are:

  • TypeScript/JavaScript (for full-stack or frontend developers)
  • Python (for automation testers, SDETs, and Python enthusiasts)

Topics to Cover

🔹 Common Topics (Both TypeScript & Python)

  1. Introduction to Playwright
  • What is Playwright? Why use it over Selenium or Cypress?
  • Supported browsers and platforms
  1. Installation and Setup
  • Installing Playwright
  • CLI tools and code generators
  1. Basic Test Structure
  • Writing your first test
  • Using locators (CSS, text, role-based, etc.)
  • Running tests in headless vs. headed mode
  1. Selectors and Locators
  • page.locator(), getByRole, getByText, etc.
  • Best practices for stable locators
  1. Assertions and Expect API
  • Using Playwright test assertions
  • Handling dynamic content
  1. Handling UI Interactions
  • Clicking, typing, hovering, checking checkboxes
  • Uploading files, selecting from dropdowns
  1. Handling Waits and Timeouts
  • Auto-waiting mechanism
  • waitForSelector, waitForLoadState, timeout
  1. Test Hooks & Structure
  • BeforeAll, AfterAll, BeforeEach, AfterEach
  • Grouping tests using describe
  1. Screenshots, Videos, and Traces
  • Capturing screenshots and videos
  • Using traces for debugging failed tests
  1. Cross-Browser and Mobile Testing
  • Running tests in Chromium, Firefox, WebKit
  • Emulating mobile devices

🟦 Playwright with TypeScript

  1. Setting Up with Node.js and TypeScript
  • npx playwright codegen
  • tsconfig.json and Playwright config
  1. Playwright Test Runner
  • Using .spec.ts files
  • Parallel testing, retries, projects
  1. Custom Helpers and Page Objects
  • Creating reusable functions
  • Implementing the Page Object Model (POM)
  1. CI/CD Integration
  • GitHub Actions, Jenkins, etc.

🐍 Playwright with Python

  1. Installing with pip
  • pip install playwright pytest
  • Using playwright codegen for Python
  1. Using Pytest with Playwright
  • Test structure with pytest
  • Fixtures for setup and teardown
  1. Async vs Sync API
  • Understanding Playwright's asyncio-based architecture
  • Writing async tests with async def
  1. Page Object Model (POM) in Python
  • Organizing tests using classes and methods