01
Primeiros Passos
Teste Básico
Os testes do Playwright usam fixtures como { page }.
playwright
import { test, expect } from "@playwright/test";
test("home", async ({ page }) => {
await page.goto("/");
await expect(page).toHaveTitle("Welcome");
});Interações
As interações mais comuns.
playwright
await page.fill("input", "hello");
await page.click("button");
await page.waitForSelector(".result");Locators
API de Locator para seleção resiliente de elementos.
playwright
const button = page.getByRole("button", { name: "Submit" });
await button.click();
const item = page.getByText("Hello");
await expect(item).toBeVisible();02
Recursos
Multi-Navegador
Testes em vários navegadores prontos para uso.
playwright
test.describe.configure({ mode: "serial" });
test("works in all", async ({ page, browserName }) => {
// runs in chromium, firefox, webkit
});Screenshot
Testes de regressão visual.
playwright
await page.screenshot({ path: "screenshot.png" });
await expect(page).toHaveScreenshot();Was this helpful?