Code Reference

Glossary

Playwright · Reference cheat sheet

Glossary

Playwright · Reference cheat sheet


📋 Overview

Alphabetical glossary of core Playwright terms for browser automation, locators, fixtures, and end-to-end testing.

🔧 Core concepts

TermDefinition
ActionAn interaction such as click, fill, or press performed on a locator.
AssertionA check that verifies page state, often auto-retrying with expect.
Auto-waitingPlaywright’s habit of waiting for elements to be actionable before acting.
BrowserA launched browser type instance such as Chromium, Firefox, or WebKit.
BrowserContextAn isolated browser session with its own cookies, storage, and cache.
CodegenThe recorder that generates Playwright scripts from manual interactions.
ExpectPlaywright’s assertion API that retries until timeout.
FixtureReusable test setup/teardown provided by the test runner (e.g. page).
FrameA nested browsing context inside a page, such as an iframe.
HeadlessRunning a browser without a visible UI window.
LocatorA lazy, strict query describing how to find element(s) on a page.
Network interceptionMocking or observing HTTP requests via route handlers.
PageA single tab/document you navigate and automate.
Page ObjectA class that encapsulates selectors and actions for a UI area.
ParallelismRunning tests concurrently across workers for speed.
Playwright TestThe built-in test runner (@playwright/test) with projects and reporters.
ProjectA named configuration slice (browser, device, or dependency set).
ReporterA plugin that formats and outputs test results.
ScreenshotA captured image of a page or element for debugging or visual checks.
Selector engineThe matching strategy behind locators (role, text, CSS, XPath, etc.).
Storage stateSaved cookies/localStorage used to reuse authenticated sessions.
TimeoutThe maximum wait before an action or assertion fails.
TraceA detailed recording of actions, DOM snapshots, and network for debugging.
VideoAn optional recording of the test browser session.
WorkerA parallel process that executes a subset of tests.

💡 Examples

Locator and assertion:

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

test("login", async ({ page }) => {
  await page.goto("/login");
  await page.getByLabel("Email").fill("a@b.com");
  await page.getByRole("button", { name: "Sign in" }).click();
  await expect(page.getByText("Dashboard")).toBeVisible();
});

Network mock:

await page.route("**/api/user", async (route) => {
  await route.fulfill({
    status: 200,
    body: JSON.stringify({ name: "Ada" }),
  });
});

Page object sketch:

class LoginPage {
  constructor(private page: Page) {}
  async login(email: string, password: string) {
    await this.page.getByLabel("Email").fill(email);
    await this.page.getByLabel("Password").fill(password);
    await this.page.getByRole("button", { name: "Sign in" }).click();
  }
}

⚠️ Pitfalls

  • Confusing locator (lazy, re-querying) with a one-shot ElementHandle.
  • Mixing page and context — auth/storage lives on the context.
  • Treating CSS selectors as first choice when role/text locators are more stable.
  • Equating a trace with a screenshot — traces capture the full timeline.
  • Assuming auto-waiting removes the need for good assertions and timeouts.

On this page