01
시작하기
기본 테스트
Playwright 테스트는 { page } 같은 픽스처를 사용합니다.
playwright
import { test, expect } from "@playwright/test";
test("home", async ({ page }) => {
await page.goto("/");
await expect(page).toHaveTitle("Welcome");
});인터랙션
자주 쓰이는 상호작용 메서드입니다.
playwright
await page.fill("input", "hello");
await page.click("button");
await page.waitForSelector(".result");로케이터
견고하게 요소를 선택하는 Locator API입니다.
playwright
const button = page.getByRole("button", { name: "Submit" });
await button.click();
const item = page.getByText("Hello");
await expect(item).toBeVisible();02
주요 기능
멀티 브라우저
별도 설정 없이 크로스 브라우저 테스트가 가능합니다.
playwright
test.describe.configure({ mode: "serial" });
test("works in all", async ({ page, browserName }) => {
// runs in chromium, firefox, webkit
});스크린샷
비주얼 회귀 테스트에 활용합니다.
playwright
await page.screenshot({ path: "screenshot.png" });
await expect(page).toHaveScreenshot();Was this helpful?