arrow-left Back to topicQuizTest generatorCheck yourself1.You want to record a test for the /orders page but it requires authentication. The login flow is complex (MFA, redirects). What's the most efficient approach?Record the full test including login every timeRecord login once with --save-storage=auth.json, then record the /orders flow with --load-storage=auth.json — start already authenticatedManually set up auth state in the test file before recording2.Which CLI command runs codegen and opens a browser at a specific URL?npx playwright record http://localhost:3000npx playwright codegen http://localhost:3000npx playwright open --record http://localhost:3000npx playwright test --codegen http://localhost:30003.In the Playwright Inspector during a codegen session, how do you switch to Pick Locator mode without adding new action code?Press Escape — this pauses recording and activates Pick Locator automaticallyClick Stop to pause recording, then click the Pick Locator button in the Inspector toolbarOpen a new codegen session with the --pick-locator flagRight-click the element in the browser and choose 'Copy Playwright locator'4.What does the generated test code from codegen look like after clicking a button and asserting a success message?Raw JavaScript with document.querySelector and no await keywordsA Playwright test with async/await, page.goto(), getByRole() clicks, and expect().toBeVisible() assertionsSelenium-style code using driver.findElement() and explicit waitsA JSON file describing actions that Playwright reads and executes5.How do you record a codegen session that emulates an iPhone 13 device?Drag the browser window to a mobile screen size during recordingnpx playwright codegen --device="iPhone 13" http://localhost:3000npx playwright codegen --mobile http://localhost:3000npx playwright codegen --viewport=390x844 --useragent=mobile http://localhost:30006.You use --save-storage=auth.json with codegen. What does this file contain and why should you add it to .gitignore?The recorded test code — .gitignore is needed to avoid committing auto-generated testsCookies, localStorage, and IndexedDB from the browser session — sensitive auth data that should never be committed to source controlBrowser configuration settings that are machine-specific and would conflict with other developersA Playwright config snapshot — only needed to avoid large file size in git history7.How do you save the generated code directly to a file instead of relying on the clipboard?npx playwright codegen --output=tests/orders.spec.ts http://localhost:3000npx playwright codegen http://localhost:3000 > tests/orders.spec.tsnpx playwright codegen --save tests/orders.spec.ts http://localhost:3000npx playwright codegen --file=tests/orders.spec.ts http://localhost:30008.What is the purpose of 'Record at cursor' in the VS Code Playwright extension?It creates a new test file and starts recording from scratchIt inserts new recorded actions at a specific line inside an existing test, starting the browser at that point in the test's executionIt replays the test up to the cursor line and then pausesIt records only the locator on the line where the cursor is placedSubmit answersarrow-left PreviousGenerating testsDebugging TestsNext arrow-right