Run npx playwright codegen https://your-app.example to record a browser flow. Playwright opens the site and its Inspector, turns your clicks and form entries into test code, and lets you add visibility, text, and value assertions while you work. Treat the generated script as a starting point: review locators, remove accidental actions, and shape the flow around a user-visible behavior that can run independently.
This guide covers the command-line recorder, VS Code, emulation, locator and assertion cleanup, UI Mode, traces, failure recovery, and a screenshot-only alternative when you do not need an interactive test.
Set up a Playwright project
Use a project-local Playwright installation so the test runner and browser versions are reproducible on every machine.
- Create or enter your Node.js project.
- Install the test package with
npm install -D @playwright/test. - Install the supported browsers with
npx playwright install. - Keep the generated configuration and test files under version control, and pin dependency versions in your lockfile.
If you already have a Playwright project, start at the recording command. Codegen can open a supplied URL or start without one, allowing you to navigate to the page yourself.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware match#1 Best Overall
- 【1080P HD Clarity with Wide-Angle Lens】Experience exceptional clarity with our 1080p Full HD Webcam. Its wide-angle lens provides sharp, vibrant images and smooth video at 30 frames per second, making it ideal for gaming, video calls, online teaching, live streaming, and content creation. Capture every detail with vivid colors and crisp visuals
- 【Noise-Reducing Built-In Microphone】Our webcam is equipped with an advanced noise-canceling microphone that ensures your voice is transmitted clearly even in noisy environments. This feature makes it perfect for webinars, conferences, live streaming, and professional video calls—your voice remains crisp and clear regardless of background noise or distractions
- 【Automatic Light Correction Technology】This cutting-edge technology dynamically adjusts video brightness and color to suit any lighting condition, ensuring optimal visual quality so you always look your best during video sessions—whether in extremely low light, dim rooms, or overly bright settings. It enhances clarity and detail in every environment
- 【Secure Privacy Cover Protection】The included privacy shield allows you to easily slide the cover over the lens when the webcam is not in use, offering immediate privacy and peace of mind during periods of non-use. Safeguard your personal space and prevent unauthorized access with this simple yet effective solution, ensuring your security at all times
- 【Seamless Plug-and-Play Setup】Designed for user convenience, the webcam is compatible with USB 2.0, 3.0, and 3.1 interfaces, plus OTG. It requires no additional drivers and comes with a 5ft USB power cable. Simply plug it into your device and start capturing high-quality video right away! Easy to use on multiple devices, ensuring hassle-free setup and instant functionality
Record a test with Playwright codegen
Start the recorder
npx playwright codegen https://your-app.example
A browser window and the Playwright Inspector appear. Perform the flow exactly as a user would: navigate, click, fill fields, choose options, and submit. The Inspector writes actions as you perform them. When the flow is complete, stop recording and choose Copy in the Inspector to paste the generated test into your editor.
Playwright examines the page while you interact with it and prioritizes role, text, and test-id locators. That usually produces more meaningful selectors than a long CSS path, but it does not know the business intent of your test. A generated click on a menu may be incidental; a deliberate assertion about the resulting page is usually the behavior you need to preserve.
Add assertions during recording
Use the Inspector assertion controls while recording. Select an element and add a visibility, text, or value assertion. Assertions turn a sequence of actions into a check with an observable outcome. For example, after submitting a form, assert that a confirmation message is visible instead of ending the test after the click.
Pick and refine locators
Stop recording and use Pick Locator in the Inspector. Hover over an element to preview the locator, click it, then copy or edit the result. Prefer a locator that describes what the user recognizes:
getByRolefor buttons, links, headings, checkboxes, and other accessible roles.getByTextwhen visible copy is the stable identity of an element.getByTestIdfor an intentional test contract exposed by the application.locatorwith a narrowly scoped CSS selector only when the semantic options are insufficient.
Check whether the locator remains unique after the page changes. If a generated selector depends on an auto-generated class, a changing index, or a layout detail, replace it before committing the test.
A complete recorded test after cleanup
The following TypeScript test is runnable in a Playwright Test project and illustrates the shape to aim for after copying codegen output. It uses a public example page so the assertion is deterministic.
Rank #2
- 1080P Webcam with Cover for Video Calls - EMEET computer webcam provides design and Optimization for professional video streaming. Realistic 1920 x 1080p video, 5-layer anti-glare lens, providing smooth video. C960 computer camera delivers 1920x1080 video with fixed focus (11.8–118.1 inches), so as to provide a clearer image. C960 USB webcam has a cover and can be removed automatically to meet your needs for privacy. For optimal image performance, use the webcam in a well-lit environment.
- Built-in 2 Omnidirectional Mics - EMEET webcam with microphone for desktop features 2 built-in omnidirectional microphones, picking up your voice to create clear audio for communication. When installing the webcam, select EMEET C960 as the default microphone input device in your computer and video applications and select C960 as the default device in Zoom/Teams and ensure microphone permissions are enabled for proper use. Please note that C960 does not include built-in speakers.
- Automatic Light Adjustment - Automatic exposure adjustment is applied in EMEET HD webcam 1080p so that the streaming webcam can deliver stable image performance. EMEET C960 camera for computer also features color adjustment and exposure optimization to help you look your best. For optimal video quality, it is recommended to use the webcam in normal or well-lit environments and select suitable video settings in your application. Proper lighting helps achieve a clearer and more balanced image.
- Plug-and-Play & Upgraded USB Connectivity - New C960 webcam features both USB Type-A & A-to-C adapter connections for wider compatibility. For stable performance, connect the webcam directly to the computer's main USB port and ensure the device is recognized correctly. If a hub or docking station is used, please ensure it provides sufficient power and stable data transmission, as limited ports may affect performance. 90° wide-angle lens captures more participants without frequent adjustments.
- High Compatibility & Multi Application - C960 webcam for laptop is compatible with Windows 10/11, macOS 10.14+, and Android TV 7.0+. Not supported: Windows Hello, TVs, tablets, or game consoles. It works with Zoom, Teams, Facetime, Google Meet, YouTube and more. Please select C960 webcam as the default camera and microphone device in your application and ensure camera/microphone permissions are enabled, especially on macOS. (Tips: Incompatible with Windows Hello)
import { test, expect } from '@playwright/test';
test('shows the example page heading', async ({ page }) => {
await page.goto('https://example.com');
await expect(
page.getByRole('heading', { name: 'Example Domain' })
).toBeVisible();
});
For your application, replace the URL and interactions with the recorded flow, then retain assertions that explain why the test exists. Keep one user goal per test where practical. Tests should be isolated: each test must establish its own data or use a controlled fixture rather than depending on the order in which another test ran.
Record from VS Code
Install the Playwright extension for VS Code, open the Testing sidebar, and choose Record new. The extension creates a test-1.spec.ts file and opens a browser for your interactions. This is the same recording concept as the CLI, but the editor keeps the generated file and test controls beside the browser.
| Approach | Best for | Notable control |
|---|---|---|
| CLI codegen | Repeatable recording from a terminal or script | Inspector, locator picker, and command-line emulation flags |
| VS Code Record new | Developers who want recording and the test file in one editor | Testing sidebar creates the spec file automatically |
| UI Mode | Exploring, running, watching, and debugging existing tests | Testing sidebar with time-travel-style inspection |
Choose the CLI when you need explicit device, viewport, locale, or timezone flags. Choose VS Code when the convenience of a graphical workflow outweighs terminal repeatability.
Record under the environment your test must cover
A flow recorded on a desktop light theme can fail to represent the behavior of a mobile, localized, or dark-mode user. Codegen accepts environment settings so the generated interactions match the intended test conditions.
npx playwright codegen
--viewport-size="1280,720"
--device="iPhone 13"
--color-scheme=dark
--timezone="America/New_York"
--geolocation="40.7128,-74.0060"
--lang=en-US
https://your-app.example
- Viewport: exercise responsive breakpoints at a known width and height.
- Device: combine a device preset’s mobile characteristics with its browser context.
- Color scheme: expose light- or dark-theme branches.
- Timezone and geolocation: reproduce date, regional, or location-dependent behavior.
- Language: record the labels and formatting shown to the target locale.
For authenticated journeys, preserve the authenticated browser state using Playwright’s documented storage-state workflow rather than recording a login step in every test. Keep any saved state out of source control when it contains real credentials or session tokens, and regenerate it when the session expires.
Turn generated actions into a durable test
Remove accidental interactions
Codegen records what happened, not what mattered. Delete clicks used only to dismiss a transient tooltip, exploratory navigation, or a second interaction that was needed while discovering the flow. Leave the shortest sequence that demonstrates the user goal.
Recommended Free Tools
Rank #3
- 【Crystal-Clear 1080P HD Video】This 1080p webcam for PC delivers sharp, true Full HD video at 30 frames per second, bringing your digital world to life with vibrant clarity. Enjoy smooth, real-time streaming with enhanced high dynamic range (HDR) that keeps your face clearly visible even in low light or backlit conditions.
- 【Built-In Noise-Canceling Microphone】This computer camera with microphone features dual noise-reducing digital mics and an advanced audio processor, capturing rich stereo sound while filtering background noise. It ensures clear conversations during video calls, even in busy environments.
- 【Privacy Shutter for Added Security】This secure USB webcam includes a built-in privacy cover, letting you physically block the lens with a simple slide. Protect your visibility and keep the lens dust-free—no drivers needed, just plug into USB 2.0 and start using it immediately.
- 【Flexible Mount & Auto Light Correction】Designed for your computer or laptop, this webcam comes with an adjustable clip for monitors or standalone use. It offers automatic light correction and fixed focus for sharp, well-balanced images in any lighting.
- 【Wide Device & Platform Compatibility】This versatile webcam for laptop and desktop use is compatible with Windows, Mac, Linux, and Android systems. Supports Skype, Zoom, Twitch, YouTube, and more—featuring a 360° rotating head for easy adjustment. Simply plug and play.
Assert outcomes, not implementation details
Verify text, visibility, URL changes, enabled state, or form values that a user can observe. Avoid asserting a private CSS class or an internal network response unless that is specifically the contract under test. A useful assertion should fail when the user-visible behavior is broken.
Make repeated data explicit
Replace one-off values with clear constants or fixtures when the value is part of the scenario. Generate unique records where the application requires uniqueness, and clean up or isolate data so another run starts from a known state.
Keep tests independent
Do not rely on a previous test leaving a logged-in page, an open cart, or a database row behind. Each test should be runnable alone and in a different order. Shared setup belongs in fixtures or a controlled setup project, not in hidden assumptions between test files.
Explore and debug with UI Mode and traces
Use UI Mode for local investigation
npx playwright test --ui
UI Mode presents the test list and a timeline for exploring, running, watching, and debugging tests. Select a step to inspect the action and the page state around it, then rerun the relevant test while refining the locator or assertion.
Capture a trace on a local run
npx playwright test --trace on
Open the resulting report with:
npx playwright show-report
Trace Viewer provides a timeline, DOM snapshots, network requests, and action details for each recorded step. Use it when a failure is timing-sensitive or the final page does not explain what happened.
Capture traces efficiently in CI
For continuous integration, configure retries and trace: 'on-first-retry'. A trace is then collected when a test first retries instead of adding trace overhead to every successful run. Keep the trace and HTML report as CI artifacts so a failure can be investigated after the worker is gone.
Rank #4
- Compatible with Nintendo Switch 2’s new GameChat mode
- Auto-Light Balance: RightLight boosts brightness by up to 50%, reducing shadows so you look your best—compared to previous-generation Logitech webcams (1)
- Privacy with a Slide: The integrated webcam cover makes it easy to get total, reliable privacy when you're not on a video call
- Built-In Mic: The built-in microphone lets others hear you clearly during video calls
- Easy Plug-And-Play: The Brio 101 works with most video calling platforms, including Microsoft Teams, Zoom and Google Meet—no hassle; it just works
Or skip the browser setup
If your deliverable is a clean screenshot or PDF of a page—not an interactive test that clicks through the page—ScreenshotNeo can capture it with one HTTP request. It is not a replacement for Playwright assertions, but it avoids maintaining a browser script for visual artifacts and documentation images. Cookie and consent banners are accepted and removed before capture, along with more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in X-Page-Verdict and X-Billed headers.
See the ScreenshotNeo API documentation for all options, including full-page and element capture, device and retina settings, custom CSS or JavaScript, waits, request blocking, cookies, headers, geolocation, PDF output, caching, signed links, asynchronous jobs, bulk capture, and usage reporting.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({
access_key: 'YOUR_API_KEY',
url: 'https://stripe.com'
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const data = Buffer.from(await res.arrayBuffer());
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', data));
ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots, and every feature is available on every plan. Create a free ScreenshotNeo account.
Troubleshoot recorded tests
The generated locator matches more than one element
Cause: repeated button text, duplicate labels, or a responsive duplicate in the DOM.
Fix: scope the locator to the relevant region, add an accessible name, or add a deliberate test id. Confirm uniqueness with the Inspector before rerunning.
The test fails intermittently after a click
Cause: the next assertion races a navigation, animation, or asynchronous request.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Fix: assert the expected destination or visible result rather than inserting an arbitrary sleep. Use a locator assertion that waits for the state you need, and inspect a trace to identify the actual delay.
Best Value
- 【Full HD 1080P Webcam】Powered by a 1080p FHD two-MP CMOS, the NexiGo N60 Webcam produces exceptionally sharp and clear videos at resolutions up to 1920 x 1080 with 30fps. The 3.6mm glass lens provides a crisp image at fixed distances and is optimized between 19.6 inches to 13 feet, making it ideal for almost any indoor use.
- 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 8, 10 & 11 / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.
- 【Built-in Noise-Cancelling Microphone】The built-in noise-canceling microphone reduces ambient noise to enhance the sound quality of your video. Great for Zoom / Facetime / Video Calling / OBS / Twitch / Facebook / YouTube / Conferencing / Gaming / Streaming / Recording / Online School.
- 【USB Webcam with Privacy Protection Cover】The privacy cover blocks the lens when the webcam is not in use. It's perfect to help provide security and peace of mind to anyone, from individuals to large companies. 【Note:】Please contact our support for firmware update if you have noticed any audio delays.
- 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 10 & 11, Pro / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.
Codegen records a login that should not be committed
Cause: recording began from a signed-out context.
Fix: create and protect an authenticated storage state, load it for the test project, and keep secrets and session files outside version control. Regenerate the state when credentials or sessions expire.
The flow works locally but fails in CI
Cause: different viewport, timezone, browser, data, or timing; CI may also expose a test-order dependency.
Fix: set the intended environment explicitly, run the test alone and in a clean worker, enable CI retries with trace: 'on-first-retry', and inspect the trace and network timeline.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesThe browser opens but the page is blank or never finishes
Cause: an unavailable environment, blocked resource, redirect loop, or application error.
Fix: verify the URL from the same CI network, inspect console and network details in the trace, and make the application fixture deterministic. Do not hide the failure with a longer timeout until the underlying load problem is understood.
Performance, reliability, and maintenance
- Recording cost: codegen is an interactive authoring step; it is not how your test suite should run in CI. Commit the cleaned test and execute it headlessly or with the project settings appropriate for CI.
- Runtime stability: stable semantic locators and user-visible assertions usually survive UI refactors better than positional selectors.
- Parallel execution: independent data and isolated authentication are prerequisites before enabling workers; otherwise parallel tests can interfere with one another.
- Debug artifacts: retain HTML reports and traces for failed retries, but control retention because DOM snapshots and network details can contain sensitive data.
- Maintenance: rerun codegen when a flow changes, then review the diff manually. Re-recording wholesale can reintroduce accidental clicks and brittle selectors.
Recording approaches at a glance
| Need | Recommended path | Why |
|---|---|---|
| Fast starter script | npx playwright codegen <url> |
Captures actions and opens the Inspector immediately |
| Assertions while interacting | Inspector assertion controls | Adds visibility, text, or value checks at the point they matter |
| Locator discovery | Inspector Pick Locator | Previews and copies a locator for the selected element |
| Editor-first workflow | VS Code Testing sidebar, Record new | Creates and opens a spec beside the browser |
| Failure diagnosis | UI Mode and Trace Viewer | Shows action history, DOM snapshots, network requests, and timing |
Frequently Asked Questions
Can Playwright codegen record API requests as test steps?
No. Codegen records browser interactions and assertions. If an API call is part of setup or teardown, add it explicitly with your test fixtures or API request code rather than expecting it to appear as a recorded click or fill.
Can I begin recording without knowing the final URL?
Yes. The URL argument is optional. Start codegen without a URL, then navigate in the opened browser to the application and begin the flow.
Free tools Windows power users keep installed
One-click scans. No signup required.
Should recorded tests be used as visual regression tests?
Not by themselves. A recorded test verifies interactions and assertions; visual regression requires an intentional screenshot comparison strategy with controlled rendering conditions.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

