arrow-left Back to topicQuizDebugging TestsCheck yourself1.You want to pause the test at a specific line to inspect the browser state. What do you use?npx playwright test --debug (starts paused at the beginning)await page.pause() at the exact lineawait page.waitForTimeout(99999) to freeze the test2.What is the environment variable that launches Playwright with the Inspector attached from the very start of the run?DEBUG=playwrightPWDEBUG=1PLAYWRIGHT_INSPECT=trueNODE_DEBUG=playwright3.What is the key difference between UI mode (--ui) and running with --debug?--debug runs faster because it doesn't record a traceUI mode shows a full timeline of actions, DOM snapshots, and network in a GUI you can scrub through; --debug opens Inspector and lets you step through the test live action by actionUI mode only works for TypeScript tests; --debug works for any languageThey are essentially the same tool with different launch commands4.What does Playwright Inspector show that makes it useful for debugging locator issues?The source map of the compiled TypeScript fileA list of all elements on the page that match the current locator, highlighted in the live browserThe raw HTML source of the page at the time of failureThe CPU and memory usage of each test step5.With the VS Code Playwright extension, how do you add a breakpoint and step through a test?Add await page.pause() calls in the code, then run normallyRight-click the test name and choose 'Debug test'; VS Code debugger breakpoints in the .spec.ts file are then respectedSet PWDEBUG=1 in the VS Code terminal and run the testInstall the Chrome DevTools extension separately for VS Code breakpoints to work6.When is it best to use traces compared to running the test with --debug?Traces are better for local development; --debug is better for CI failuresTraces are better when the failure happens on CI and you can't reproduce it locally; --debug is better when you can run the test interactivelyThey are interchangeable — use whichever starts fasterTraces are only available in Playwright's paid enterprise plan7.You listen to page.on('console') in a test. What types of messages can you capture?Only console.error() messages from the browserAll browser console output — log, info, warn, error, and debug — each with a type you can filter onOnly network-related console messages like CORS errorsConsole messages from the Playwright test runner itself, not from the browser8.What is the fastest way to get a locator for an element you can see in the browser during a debug session?Inspect the element in Chrome DevTools and copy the CSS selectorUse the Pick locator button in Playwright Inspector or VS Code extension — click the element and get the recommended locator copied to clipboardRun npx playwright codegen and record a new test from scratchCheck the network tab for the element's data-testid attributeSubmit answersarrow-left PreviousTest generatorTrace viewerNext arrow-right