Back to articles
Playwright Has a Free API — Here's How to Test Web Apps End-to-End

Playwright Has a Free API — Here's How to Test Web Apps End-to-End

via Dev.to WebdevAlex Spinov

Playwright is Microsoft's browser automation framework for end-to-end testing. It supports Chromium, Firefox, and WebKit with auto-waits, parallel execution, and powerful selectors. Installation npm init playwright@latest Writing Tests import { test , expect } from " @playwright/test " ; test ( " homepage has title " , async ({ page }) => { await page . goto ( " https://playwright.dev " ); await expect ( page ). toHaveTitle ( /Playwright/ ); }); test ( " search works " , async ({ page }) => { await page . goto ( " https://playwright.dev " ); await page . getByRole ( " link " , { name : " Get started " }). click (); await expect ( page ). toHaveURL ( /intro/ ); }); Locators — Finding Elements // By role (recommended) page . getByRole ( " button " , { name : " Submit " }); page . getByRole ( " heading " , { level : 1 }); page . getByRole ( " link " , { name : " Sign up " }); // By text page . getByText ( " Welcome back " ); page . getByLabel ( " Email address " ); page . getByPlaceholder

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
2 views

Related Articles