Playwright flashcards
Drive Chromium, Firefox and WebKit with auto-waiting locators, fixtures, network control and traces.
What is Playwright, in one plain sentence?
Playwright is a free tool that opens a web and uses a website by itself, clicking and typing like a person, to check that the site works.
Tap to turn over. Swipe right if you know it, left to see it again.
What you will learn
Start from zero
- What Playwright is and why it exists4 cards
- Key words for web tests4 cards
- Tools and your first lines4 cards
Core basics
- Install and write your first test4 cards
- Locators3 cards
- Actions and auto-waiting2 cards
- Assertions2 cards
- Config, UI mode, codegen and reports4 cards
Next steps
- Fixtures, page objects and sign-in4 cards
- Network, mocking and API tests4 cards
- Projects, devices and the web server3 cards
- Tricky elements: rows, files and dialogs3 cards
- Traces and test steps2 cards
- Visual and accessibility checks2 cards
Go deeper
- Custom fixtures and test isolation2 cards
- Parallelism, sharding and CI6 cards
- Assertions for complex UIs3 cards
- Time, tabs and frames3 cards
- Debugging, component tests and AI tooling3 cards
Final test and certificate
10 questions drawn fresh from the whole topic, about 15 minutes. Sign in, score 80% or more and get a free certificate with your name and a public check link anyone can open, such as an employer or a teacher. Not signed in? Try a practice test from the cards.
Take the final testAbout these cards
- Reviewed 26 October 2026
- CoversPlaywright 1.64 (@playwright/test)Node.js 24 LTSChromium, Firefox and WebKit builds bundled with 1.64
Checked against
Playwright at a glance
Playwright is a free tool that uses a website like a person, clicking and typing, to check it works.
Like a shop tester with a checklist who tries every step and writes a report with photos when something is wrong.
Words you will meet
- Browser
- The app that shows websites, like Chrome or Safari
- Element
- One piece of a page, like a button or a box
- Locator
- A description of how to find an element
- Test
- A small program that does steps and says pass or fail
- Assertion
- The check inside a test, like 'the total is Rs 240'
- Headless
- The browser runs with no window on screen
- Trace
- A step by step recording of a test run
- Terminal
- The window where you type commands
The steps
- 1. Start from zero (12 cards): What Playwright is, the words tests use, and your first two-line check.
- 2. Core basics (15 cards): Install, locate by role, act, assert with retries, and read the report.
- 3. Next steps (18 cards): Fixtures, contexts, auth state, network routing, API calls, projects and traces.
- 4. Go deeper (17 cards): Worker fixtures, parallelism, sharding, clocks, aria snapshots, popups and AI agents.
All 12 cards in Start from zero
- What is Playwright, in one plain sentence?
- Playwright is a free tool that opens a web browser and uses a website by itself, clicking and typing like a person, to check that the site works.
- Before tools like this, how did teams check a website?
- People clicked through every page by hand before each release: slow, boring and easy to miss things. Older robot tools often clicked before the page was ready and failed for no real reason.
- Where does this touch your daily life?
- When a shop's checkout still works the morning after an update, a robot test like this likely tried it first. You do the same by hand when you fill a form twice to see if it works.
- What everyday job is Playwright like?
- A shop tester with a written checklist: open the shop, add tea to the cart, check the total says Rs 240. If anything is off, he writes a report with photos of what he saw.
- What are a browser, a page, an element and the DOM?
- A browser is the app that shows websites; Playwright drives three kinds: Chromium (inside Chrome and Edge), Firefox and WebKit (inside Safari). An element is one piece of a page, like a button, and the DOM is the browser's live map of all of them.
- What are a 'test', an 'assertion' and a 'fixture'?
- A test is a small program that does steps and says pass or fail. An assertion is the check, like 'expect the total to be Rs 240'; Playwright's assertions keep retrying until a timeout (5 seconds by default) before failing.
- What are a 'locator', a 'role', a 'label' and a 'test id'?
- A locator describes how to find an element, like 'the button named Add to cart'. Role is what an element is for (button, link, checkbox), label is the visible name beside a box, and a test id is a hidden name tag added just for tests.
- What do 'headless', 'CI', 'trace' and 'report' mean?
- Headless means the browser runs with no window on screen. CI is a computer that runs your tests on every code change, a trace is a step by step recording with snapshots, and the report is a web page summary of results.
- What are the terminal, Node.js, npm, npx and a config file?
- The terminal is the window where you type commands. Node.js runs JavaScript on your computer,
npminstalls packages (ready-made code),npxruns a package's command, and a config file likeplaywright.config.tsholds settings. - What do you need before starting?
- A computer with Node.js installed, a text editor and a website to test, even your own small page. Knowing a little HTML and JavaScript makes the code cards easy.
- Your first tiny win: what do these two lines do?
awaitmeans wait for this step to finish.page.gotoopens the page in the browser, and the assertion passes if the tab title says Example Domain.- What will you be able to do after this topic?
- Install Playwright, write tests that click, type and check like a real user, run them in several browsers, and read the report to find why a test failed.
Playwright cheatsheet
Commands
npm init playwright@latestSet up a projectnpx playwright test --uiInteractive runnernpx playwright test cart --project=webkitOne file pattern, one browsernpx playwright test -g "coupon" --debugStep through with Inspectornpx playwright test --last-failedRerun only failuresnpx playwright test --only-changed=origin/mainTests touched by this branchnpx playwright codegen localhost:5173Record a draftnpx playwright show-trace trace.zipOpen a trace
Locators
page.getByRole("button", { name: "Pay" })Role plus accessible namepage.getByLabel("Email")Form field by labelpage.getByText("Order placed")Visible textpage.getByTestId("cart-total")data-testidfallbackrows.filter({ hasText: "INV-2041" })Narrow a listlocator("iframe").contentFrame()Inside an iframelocator.first() / .nth(2)Only when order matters
Assertions
await expect(loc).toBeVisible()Shown on screenawait expect(loc).toHaveText(/Paid/)Text, retriedawait expect(loc).toHaveCount(3)Number of matchesawait expect(page).toHaveURL(/orders/)Current URLawait expect(loc).toMatchAriaSnapshot(yaml)Accessibility treeawait expect(page).toHaveScreenshot()Visual compareexpect.soft(...) / expect.poll(fn)Keep going / retry a function
Network and browser control
page.route("**/api/pay", r => r.fulfill({ json }))Mock a responsepage.waitForResponse(fn)Start before the clickrequest.post("/api/test/orders", { data })Seed via APIcontext.storageState({ path })Save sign-inpage.clock.install({ time })Fake time, before gotopage.once("dialog", d => d.accept())Acceptconfirm()page.waitForEvent("download")Catch a download
Config
use: { baseURL }page.goto("/cart")worksretries: process.env.CI ? 2 : 0Retries on CI onlyuse: { trace: "on-first-retry" }Evidence for failuresprojects: [{ dependencies: ["setup"] }]Auth setup firstwebServer: { command, url, reuseExistingServer }Start the appfullyParallel: trueParallel inside filesforbidOnly: !!process.env.CIFail CI ontest.only