Skip to content
L
LearnCoachAssist
Topics
AI
AI Agents (500 Questions)
AI Math (500 Questions)
AI Math Beginner
AI Search Results
Claude Code Prompts
Art & Design
Art History
Color Theory
Graphic Design Principles
Knitting And Crochet
Photography Exposure Triangle And Composition
Business
Accounting Basics
Customer Research
Economics
Excel Formulas For Financial Analysts
Go To Market Strategy
Browse all topics →
Packs
Featured Packs
Python Programming Essentials
Prompt Engineering
Prompting Claude Code
AI Agents and Autonomous Systems
SQL and Database Fundamentals
JavaScript Fundamentals
Algorithms and Data Structures
Git and Version Control
Browse all packs →
Learn
Learning Paths
AI Deck Generator
How it works
Quiz
Blog
Cheat Sheets
Pricing
Resources
Pricing
Compare
FAQ
About
Contact
Effective Studying Guide
Free Anki Decks
Log in
Start Free
Topics
AI
AI Agents (500 Questions)
AI Math (500 Questions)
AI Math Beginner
AI Search Results
Claude Code Prompts
Art & Design
Art History
Color Theory
Graphic Design Principles
Knitting And Crochet
Photography Exposure Triangle And Composition
Business
Accounting Basics
Customer Research
Economics
Excel Formulas For Financial Analysts
Go To Market Strategy
Browse all topics →
Packs
Python Programming Essentials
Prompt Engineering
Prompting Claude Code
AI Agents and Autonomous Systems
SQL and Database Fundamentals
JavaScript Fundamentals
Algorithms and Data Structures
Git and Version Control
Browse all packs →
Learn
Learning Paths
AI Deck Generator
How it works
Quiz
Blog
Cheat Sheets
Pricing
Resources
Pricing
Compare
FAQ
About
Contact
Effective Studying Guide
Free Anki Decks
Start Free
Log in
← Quit
Anki Playwright Agents Practice Exam
Question
1
of
50
60:00
Question 1
Anki Playwright Agents
What is a Locator?
await expect(locator).toBeVisible(); await locator.click();
A live selector handle that re-resolves automatically and supports auto-wait + strictness; prefer locators over element handles.
Create projects like { name:'ams', use:{ baseURL:'http://127.0.0.1:3437' } } and { name:'connect', use:{ baseURL:'http://127.0.0.1:3445' } }.
“Only write under `
/e2e/` and do not modify app code unless I explicitly approve.”
Question 2
Anki Playwright Agents
How do I test a keyboard shortcut?
Update assertions/testids first, then update screenshots with review. Record the reason (ticket/PR) so future diffs are explainable.
await page.keyboard.press('Control+K') (use 'Meta+K' on macOS if applicable).
Add `test.describe.configure({ timeout: 120000 })` for slower flows.
npm i -D @playwright/test
npx playwright install
npx playwright test
Question 3
Anki Playwright Agents
How do I test file downloads?
const download = await page.waitForEvent('download'); await download.saveAs('tmp/file.csv');
npx playwright test --workers=1
A recorded timeline (screenshots, DOM snapshots, network, console, actions) you can inspect to debug failing/flaky tests.
const card = page.getByTestId('report-card'); await card.getByRole('button', { name: 'Download' }).click();
Question 4
Anki Playwright Agents
How to handle intentional UI changes?
Update assertions/testids first, then update screenshots with review. Record the reason (ticket/PR) so future diffs are explainable.
await page.getByLabel('Email').fill('user@example.com')
npx playwright test --last-failed
Install browsers (npx playwright install --with-deps), set CI=1, run npx playwright test, upload playwright-report/ and test-results/ artifacts.
Question 5
Anki Playwright Agents
What’s a common pitfall with running two Vite apps?
await page.waitForLoadState('domcontentloaded') (usually unnecessary—use expect() on UI instead).
Ask it to: (1) add/modify tests, (2) run npx playwright test, (3) fix failures, (4) re-run until green, and (5) summarize what changed.
Both may default to the same port (e.g., 8080); run one with `npm run dev -- --port 3437` to avoid conflicts.
npx playwright test --max-failures=1
Question 6
Anki Playwright Agents
What is test.use() for?
Run existing suite, identify stable selectors, confirm the user flow steps, and agree on what must be asserted (URL, text, data).
It sets per-file/describe options like storageState, viewport, permissions, etc.
npx playwright test --list
Never update snapshots unless the user explicitly wants to accept visual changes; attach diff + reasoning when proposing updates.
Question 7
Anki Playwright Agents
How do I attach extra debug info to the report?
expect(page).toHaveScreenshot({ mask: [page.locator("[data-testid=clock]")] }) to ignore volatile regions.
Require placeholders for credentials and env-var injection (e.g., USERNAME/PASSWORD) with no hardcoded values.
Use testInfo.attach('name', { body: Buffer.from('...'), contentType: 'text/plain' }).
It often uses brittle selectors and weak assertions; refactor to getByRole/testids and add meaningful expect() checks.
Question 8
Anki Playwright Agents
How do I instruct an agent to avoid secrets?
Use context.waitForEvent('page') and keep references to each page object.
In config: use: { video: 'retain-on-failure' } (or 'on' for always).
Prefer storageState; don’t depend on long-lived cookies that may expire unpredictably.
Require placeholders for credentials and env-var injection (e.g., USERNAME/PASSWORD) with no hardcoded values.
Question 9
Anki Playwright Agents
How do I keep terminal output concise?
Use a simpler reporter like `--reporter=line` (or configure reporter in playwright.config.ts).
npx playwright test --workers=1
Set reporter to include junit in config (e.g., reporter: [['junit', { outputFile: 'results.xml' }]]).
Most locator actions expect exactly one match; if multiple elements match, Playwright throws to prevent ambiguous tests.
Question 10
Anki Playwright Agents
How do I guide an AI agent to create Playwright tests I can run later?
Usually under a Playwright-managed cache; override with PLAYWRIGHT_BROWSERS_PATH=0 to install into node_modules/.cache.
Specify: repo path, testDir, baseURL(s), how to start servers, login method, required assertions, and “only write under e2e/”.
“List the minimum elements needing data-testid and why; wait for approval before editing app code.”
page.on('requestfailed', req => console.log('FAILED', req.url(), req.failure()?.errorText))
Question 11
Anki Playwright Agents
How do I grant permissions like clipboard/geolocation?
Set permissions in context/use config: permissions: ['clipboard-read', 'clipboard-write'].
use: { extraHTTPHeaders: { 'X-Test-Run': 'e2e' } }
await expect(page.getByTestId('row')).toHaveCount(10)
npx playwright test --project=chromium
Question 12
Anki Playwright Agents
How do I assert an element count?
npx playwright test --workers=1
await expect(page.getByTestId('row')).toHaveCount(10)
await expect(page.getByRole('checkbox', { name: 'Active' })).toBeChecked()
Define the assertions: URL change, key text visible, API response OK, and a DB/data effect if applicable.
Question 13
Anki Playwright Agents
Anki import: how do I force Anki to treat content as HTML?
await page.getByLabel('Role').selectOption({ label: 'Admin' })
Use locators (not element handles), avoid storing DOM nodes, and re-locate before acting.
testInfo.attach('api-response.json', { body: Buffer.from(JSON.stringify(obj,null,2)), contentType: 'application/json' })
Add `#html:true` at the top; then `
` renders line breaks and `
` works.
Question 14
Anki Playwright Agents
How do I disable video/trace locally for speed?
page.route('**/*', route => route.request().url().includes('google') ? route.abort() : route.continue())
In config set use.video/use.trace to 'off' (or conditionally based on CI env).
use.baseURL, webServer (start app), projects (chromium/firefox/webkit), retries/workers, reporter (html + junit), trace/video/screenshot policies.
expect(page).toHaveScreenshot({ mask: [page.getByTestId('clock')] })
Question 15
Anki Playwright Agents
Where do Playwright tests live?
Start `portal-laravel` + the UI (`portal-2-vue` or `portal-vue`), then set baseURL to the chosen UI.
Common: ./tests or ./e2e (you choose). Configure testDir in playwright.config.ts so agents know where to add new tests.
A named browser/device configuration (e.g., chromium, firefox, webkit, mobile) that runs the same tests under different settings.
“Only write under `
/e2e/` and do not modify app code unless I explicitly approve.”
Question 16
Anki Playwright Agents
How do I create a minimal smoke suite?
A scripted login that saves storageState; keep it fast and avoid UI details when possible.
await expect(page.getByTestId('toast')).toHaveText(/Saved/)
Tag key tests with @smoke and run `--grep @smoke` as the fast gate.
Run npx playwright test --update-snapshots (only when change is intended) and review diffs in PR.
Question 17
Anki Playwright Agents
What’s the difference between actionTimeout and navigationTimeout?
actionTimeout limits individual actions (click/fill); navigationTimeout limits navigations (goto/click causing nav).
Say “only write under
” and “don’t edit app code unless necessary”; also name exact file paths you want created/modified.
Use test.beforeAll/test.afterAll with careful isolation (avoid shared mutable state across workers).
npx playwright test --shard=1/3 (and 2/3, 3/3)
Question 18
Anki Playwright Agents
How do I set Playwright baseURL when ports vary?
Pass BASE_URL via env and read it in config, so you can switch ports without editing tests.
await expect(page).toHaveTitle(/AMS/i)
When UI text is unstable (i18n), roles are missing, or multiple similar elements exist. Keep ids stable and semantic (e.g., save-button).
const popup = await page.waitForEvent('popup'); then interact with popup.
Question 19
Anki Playwright Agents
How do I work with virtualized lists?
Scroll until the row exists, then assert on visible items; avoid assuming all rows are in DOM.
Fetch JSON (page.request or API client) and expect(data).toMatchSnapshot() so diffs show exact field changes.
page.route('**/api/**', route => route.fulfill({ status: 200, json: {...} }))
When UI text is unstable (i18n), roles are missing, or multiple similar elements exist. Keep ids stable and semantic (e.g., save-button).
Question 20
Anki Playwright Agents
How do I assert the URL query params?
"Do not change app code or update snapshots unless I explicitly ask. Prefer stable locators. If blocked, propose minimal data-testid additions and wait for approval."
await expect(page).toHaveTitle(/AMS/i)
await test.step('create customer', async () => { ... })
await expect(page).toHaveURL(/\\?page=2/)
Question 21
Anki Playwright Agents
What’s the difference between headless and headed?
Use test.afterEach(async ({ page }) => { ... })
Headless runs without a visible browser window; headed shows the browser UI for debugging.
"Add a Playwright test for [flow]. Use getByRole/Label first, add data-testid only if needed, assert key outcomes, keep it deterministic, and run it."
Use webServer in playwright.config.ts to run commands and wait for a URL to respond.
Question 22
Anki Playwright Agents
How do I share code between tests?
await expect(locator).toBeVisible(); await locator.click();
Create helper functions (e.g., in tests/helpers/), or Page Object Models for complex screens; keep them thin and assertion-focused.
await page.getByRole('checkbox', { name: 'Active' }).setChecked(true)
Create separate storage states (admin.json, user.json) and use test.use({ storageState: ... }) in different describe blocks/projects.
Question 23
Anki Playwright Agents
How do I capture screenshots on failure automatically?
In config: use: { screenshot: 'only-on-failure' }
Check out previous commit in a git worktree, run the same tests, and compare HTML reports and screenshot diffs between runs.
It can read the error, inspect selectors, adjust waits/assertions, and rerun until the test is stable.
A scripted login that saves storageState; keep it fast and avoid UI details when possible.
Question 24
Anki Playwright Agents
Anki import: what file format does Anki accept?
In config: use: { trace: 'on' }
Plain text (e.g., .txt/.tsv) with fields separated by comma/semicolon/tab/etc. Make sure it’s saved as UTF-8.
It often uses brittle selectors and weak assertions; refactor to getByRole/testids and add meaningful expect() checks.
It tells Playwright where to look for spec files (e.g., e2e/ or tests/e2e/).
Question 25
Anki Playwright Agents
How do I handle “remember me” and cookies?
PWDEBUG=1 npx playwright test -g "name" --headed
or npx playwright test --debug (inspector)
Usually under the test project (e.g., e2e/.auth/storageState.json) and referenced in config; don’t commit real-user secrets.
Set `outputDir` in playwright.config.ts (e.g., 'test-results').
Prefer storageState; don’t depend on long-lived cookies that may expire unpredictably.
Question 26
Anki Playwright Agents
How do I make an agent “run tests automatically”?
await expect(page.getByRole('checkbox', { name: 'Active' })).toBeChecked()
Ask it to: (1) add/modify tests, (2) run npx playwright test, (3) fix failures, (4) re-run until green, and (5) summarize what changed.
Common: ./tests or ./e2e (you choose). Configure testDir in playwright.config.ts so agents know where to add new tests.
await expect(page).toHaveURL(/\\/dashboard$/)
Question 27
Anki Playwright Agents
How do I run setup steps before each test?
“Do not run `--update-snapshots` unless I explicitly request it; include diffs + rationale.”
Use the built-in request fixture: const res = await request.post('/api/test/seed', { data: {...} });
Use test.beforeEach(async ({ page }) => { ... })
Create separate storage states (admin.json, user.json) and use test.use({ storageState: ... }) in different describe blocks/projects.
Question 28
Anki Playwright Agents
Parallel tests without chaos?
page.getByRole('button', { name: 'Save' })
page.once('dialog', d => d.accept()); then trigger the action.
Scroll until the row exists, then assert on visible items; avoid assuming all rows are in DOM.
Isolate state per test (unique users/data), avoid shared mutable globals, and keep tests idempotent so workers can run safely.
Question 29
Anki Playwright Agents
How can one E2E suite cover both AMS and Connect?
Create separate Playwright projects (AMS, Connect) with different baseURL/webServer settings, and run all with one command.
Run existing suite, identify stable selectors, confirm the user flow steps, and agree on what must be asserted (URL, text, data).
await locator.fill(''); await locator.type('new value');
const popup = await page.waitForEvent('popup'); then interact with popup.
Question 30
Anki Playwright Agents
What is “strict mode” for locators?
Click to open it, then choose an option by role (listbox/option) or by stable data-testid.
Read `performance.getEntriesByType('navigation')` via page.evaluate and assert rough budgets if needed.
Pick a dedicated folder like `/root/myapp/admin/e2e/` (or per-app `admin-2-vue/e2e/`) and document it in the config.
Most locator actions expect exactly one match; if multiple elements match, Playwright throws to prevent ambiguous tests.
Question 31
Anki Playwright Agents
How do I create separate sessions for different roles?
await page.getByRole('checkbox', { name: 'Active' }).setChecked(true)
In config set use.video/use.trace to 'off' (or conditionally based on CI env).
Generate `storageState.admin.json` and `storageState.user.json`, then apply via test.use() per describe/project.
Run with `--headed --debug` (or `PWDEBUG=1`) and inspect locators/steps in the inspector.
Question 32
Anki Playwright Agents
How do I run Playwright in Docker?
A JSON file containing cookies/localStorage that can preload authenticated sessions without re-logging-in each test.
Set `#deck:YourDeck::Subdeck` in the file headers before importing.
use: { extraHTTPHeaders: { 'X-Test-Run': 'e2e' } }
Use the official Playwright container image or install system deps via `npx playwright install --with-deps`.
Question 33
Anki Playwright Agents
Mask dynamic areas in screenshots?
expect(page).toHaveScreenshot({ mask: [page.locator("[data-testid=clock]")] }) to ignore volatile regions.
Use storageState created manually once, or a test-only auth bypass in non-prod environments.
Usually under a Playwright-managed cache; override with PLAYWRIGHT_BROWSERS_PATH=0 to install into node_modules/.cache.
Run npx playwright test --update-snapshots (only when change is intended) and review diffs in PR.
Question 34
Anki Playwright Agents
How do I reduce flakiness from animations?
Disable animations via CSS injection (page.addStyleTag) or prefers-reduced-motion; avoid asserting pixel-perfect layout unless needed.
Require placeholders for credentials and env-var injection (e.g., USERNAME/PASSWORD) with no hardcoded values.
Scroll until the row exists, then assert on visible items; avoid assuming all rows are in DOM.
A live selector handle that re-resolves automatically and supports auto-wait + strictness; prefer locators over element handles.
Question 35
Anki Playwright Agents
Why prefer getByRole()?
Access metadata like project name, retry count, outputDir, and attach artifacts.
Use process.env in playwright.config.ts and tests; set vars in shell or CI (e.g., BASE_URL, USERNAME, PASSWORD).
await page.getByRole('button', { name: 'More' }).hover();
It uses accessibility roles/names, making tests more resilient to DOM refactors and closer to user behavior.
Question 36
Anki Playwright Agents
How do I test drag-and-drop?
Run a one-time “login” test/script and call await context.storageState({ path: 'storageState.json' }).
page.getByTestId('save-button')
Use storageState created manually once, or a test-only auth bypass in non-prod environments.
Use locator.dragTo(targetLocator) (or dispatch drag events if the app requires it).
Question 37
Anki Playwright Agents
How do I set extra HTTP headers for all requests?
It can read the error, inspect selectors, adjust waits/assertions, and rerun until the test is stable.
Use locator.first() (but prefer a more specific selector when possible).
use: { ignoreHTTPSErrors: true } (only for dev/testing).
use: { extraHTTPHeaders: { 'X-Test-Run': 'e2e' } }
Question 38
Anki Playwright Agents
How do I select the first matching element?
Create storageState.json in globalSetup and set test.use({ storageState }) for all tests.
Use locator.first() (but prefer a more specific selector when possible).
New files/paths, commands used, how to start servers, how login is handled (storageState path), and what the assertions verify.
await expect(page.getByTestId('row')).toHaveCount(10)
Question 39
Anki Playwright Agents
How do I verify Playwright is installed correctly?
npx playwright --version
npx playwright install --dry-run
Point baseURL at portal-2-vue or portal-vue depending on which UI you are testing.
Use Playwright auto-wait + expect(locator).toBeVisible/toHaveText/toHaveURL. Avoid page.waitForTimeout except as last resort.
A live selector handle that re-resolves automatically and supports auto-wait + strictness; prefer locators over element handles.
Question 40
Anki Playwright Agents
How do I make selectors stable in Vue/Laravel apps?
Add semantic roles/labels where possible; add data-testid as a last resort on interactive elements and key containers.
Pick a small set of high-value pages/components, fix viewport/theme, disable animations, and snapshot them regularly.
In config: use: { screenshot: 'only-on-failure' }
npx playwright test --timeout=60000
Question 41
Anki Playwright Agents
How do I run teardown after each test?
Use test.afterEach(async ({ page }) => { ... })
A recorded timeline (screenshots, DOM snapshots, network, console, actions) you can inspect to debug failing/flaky tests.
Add `test.describe.configure({ timeout: 120000 })` for slower flows.
Create separate Playwright projects (AMS, Connect) with different baseURL/webServer settings, and run all with one command.
Question 42
Anki Playwright Agents
How do I wait for navigation after clicking?
Use PWDEBUG=1 (inspector) or launch with slowMo in custom scripts; in tests prefer --debug/PWDEBUG=1.
PWDEBUG=1 npx playwright test -g "name" --headed
or npx playwright test --debug (inspector)
Use await Promise.all([page.waitForURL('**/dashboard'), page.getByRole('button', { name: 'Login' }).click()])
page.getByTestId('save-button')
Question 43
Anki Playwright Agents
How do I do per-role logins (admin vs user)?
Ask it to: (1) add/modify tests, (2) run npx playwright test, (3) fix failures, (4) re-run until green, and (5) summarize what changed.
Create separate storage states (admin.json, user.json) and use test.use({ storageState: ... }) in different describe blocks/projects.
npx playwright install chromium
Use test.beforeEach(async ({ page }) => { ... })
Question 44
Anki Playwright Agents
How do I force a click when an overlay blocks it?
Add tags in the title like test('login @smoke', async ({ page }) => { ... }) and run with --grep @smoke.
Use consistent browser/device/viewport and load fonts deterministically (or disable font-smoothing variations if needed).
Try to fix the UI state; as last resort use locator.click({ force: true }) and document why.
npx playwright install chromium
Question 45
Anki Playwright Agents
Why shouldn’t I keep raw codegen output?
Read USERNAME/PASSWORD from env vars and avoid committing storageState created from real accounts.
page.route('**/api/**', route => route.fulfill({ status: 200, json: {...} }))
Use const download = await page.waitForEvent('download'); then download.path() or saveAs().
It often uses brittle selectors and weak assertions; refactor to getByRole/testids and add meaningful expect() checks.
Question 46
Anki Playwright Agents
How do I authenticate once and reuse it?
“List the minimum elements needing data-testid and why; wait for approval before editing app code.”
Create storageState.json in globalSetup and set test.use({ storageState }) for all tests.
Read `performance.getEntriesByType('navigation')` via page.evaluate and assert rough budgets if needed.
page.once('dialog', d => d.accept()); then trigger the action.
Question 47
Anki Playwright Agents
How do I skip or focus tests?
test.skip(...), test.describe.skip(...), test.only(...) (avoid committing .only).
Run fewer projects (chromium only), shard tests, and keep heavy flows behind tags (e.g., @slow).
npx playwright test e2e/auth.spec.ts
“Extract repeated flows into helpers (login, create entity) but keep assertions in the test.”
Question 48
Anki Playwright Agents
What if my app uses SSO/2FA?
Use test.describe('Analytics', () => { ... }) and keep specs feature-scoped.
Prefer storageState created manually once, or authenticate via backend/API (test user) instead of automating brittle multi-factor UI flows.
A named browser/device configuration (e.g., chromium, firefox, webkit, mobile) that runs the same tests under different settings.
It sets per-file/describe options like storageState, viewport, permissions, etc.
Question 49
Anki Playwright Agents
How do I create a storageState file?
Try to fix the UI state; as last resort use locator.click({ force: true }) and document why.
const res = await page.waitForResponse(r => r.url().includes('/api/reports') && r.ok());
It sets per-file/describe options like storageState, viewport, permissions, etc.
Run a one-time “login” test/script and call await context.storageState({ path: 'storageState.json' }).
Question 50
Anki Playwright Agents
Agent safety rule for snapshots?
Tag tests (e.g., @smoke, @critical) and run npx playwright test --grep @smoke in CI gates.
await page.waitForRequest(r => r.url().includes('/api/login'))
Never update snapshots unless the user explicitly wants to accept visual changes; attach diff + reasoning when proposing updates.
await expect(locator).toContainText(/Saved/)
Question navigator
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
← Previous
Next →
✅ Submit Exam