To automate a browser with Playwright, install its package and matching browser binaries, choose Playwright Test for a test suite or a direct browser API for a standalone script, then automate with resilient locators and explicit assertions. Playwright waits for defined actionability conditions before interactions such as clicks; traces help explain failures. This guide uses the official Playwright documentation available on September 29, 2026. Commands and options can change, so check the documentation for the version installed in your project.
Choose Playwright Test or a direct browser API
Playwright supports TypeScript, Python, .NET, and Java. The right entry point depends on whether you are building a test suite or a one-off automation task.
Use Playwright Test for a managed test suite
Playwright Test is the integrated runner for organizing tests, assertions, browser projects, and tracing. Start with its setup if you need repeatable tests that run locally or in continuous integration (CI). Its configuration and test APIs are designed to work together, including the recommended trace policies described below.
Use a direct API for a standalone script
If the task is a script rather than a test suite, use the API for your chosen language to launch a browser, open a page, navigate, perform work, and close the browser. You manage that lifecycle yourself. The official Playwright library documentation shows the browser API approach.
#1 Best Overall
- ADJUSTABLE HEIGHT DESIGN: The mobile standing desk promotes a healthier workstyle by allowing quick transitions between sitting and standing. The gas spring lift smoothly adjusts the height from 28.3in to 44in, supporting better posture and reducing neck and back strain during long working hours. This portable desk improves daily comfort and productivity across different environments.
- SUPERIOR STABILITY AND DURABILITY: The rolling desk adjustable height model stands out with its sturdy H shaped steel base and reinforced structure, providing stability even at maximum extension. The waterproof and scratch resistant MDF desktop ensures long lasting use, while the retractable keyboard tray and hook create organized storage for accessories. This unique design differentiates the desk from standard folding table or rolling podium options on the market.
- ERGONOMIC AND FUNCTIONAL DESIGN: The portable standing desk offers a spacious 25.6 x 17.7in surface to accommodate a laptop, monitor, or books. A dedicated slot holds phones and tablets, while the 23.6 x 11.8in keyboard tray supports a full size keyboard and mouse. The thoughtful structure allows the small standing desk to serve as a side table, study cart, or computer desk with keyboard tray in living rooms, bedrooms, and offices.
- EASY MOBILITY WITH LOCKABLE WHEELS: The adjustable rolling desk includes four caster wheels that allow smooth movement between rooms. The lockable function secures the desk in place when needed, creating flexibility for use as a rolling laptop desk, classroom furniture, or teacher standing desk. The compact rolling table design makes the desk on wheels easy to move, while maintaining stability during presentations or study sessions.
- EASY OPERATION AND LOW MAINTENANCE: The sit stand desk is operated with a simple hand lever that activates the gas spring for smooth upward adjustment, while gentle pressure lowers the surface. The mobile desk workstation requires minimal maintenance, as the MDF board is waterproof, scratch resistant, and easy to clean with a damp cloth. This reliable raising desk minimizes user effort and ensures long term durability without complex upkeep.
For example, with Playwright’s JavaScript library, a minimal script follows this lifecycle:
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com');
console.log(await page.title());
} finally {
await browser.close();
}
})();
This example assumes the package and matching Chromium binary are installed. Use the test runner instead if you need integrated test assertions, reporting, projects, or assertion-aware traces.
Install Playwright and its browsers
A Playwright package version expects specific browser binaries. Install the browsers after installing Playwright, and repeat browser installation when you update the package so that the binaries match.
- For a new JavaScript or TypeScript test project, run
npm init playwright@latestand follow the setup prompts, or add the package in your existing project as directed by the official getting-started guide. - Install the supported browser binaries for the installed version with
npx playwright install. - To install just WebKit, use
npx playwright install webkit. To install Chromium and its system dependencies in a supported CI environment, the browser guide documentsnpx playwright install --with-deps chromium. - After upgrading Playwright, run the browser installation command again before diagnosing browser-launch failures.
Playwright supports Chromium, Firefox, and WebKit, and also documents branded Chrome and Edge channels. Choose engines based on the compatibility surface you need to cover; use Playwright-managed browser binaries unless you specifically need a branded browser channel. Check the browser installation guide for version-specific commands and options.
Recommended Free Tools
Write a maintainable browser test
A useful test expresses what a person can find and do on the page, performs the interaction, and checks the result that matters. In Playwright Test, for example:
import { test, expect } from '@playwright/test';
test('user can submit a search', async ({ page }) => {
await page.goto('https://example.com');
await page.getByRole('textbox', { name: 'Search' }).fill('browser automation');
await page.getByRole('button', { name: 'Search' }).click();
await expect(page.getByRole('heading', { name: /search results/i })).toBeVisible();
});
The page and locator APIs in the example are provided through the Playwright Test fixture. Replace the example URL, accessible names, and expected heading with the real application’s interface and intended behavior. The purpose is not merely to prove that a click happened; it is to assert an outcome meaningful to the user.
Rank #2
- 【32” x 19” Perfect for Small Spaces & Corner】 Specially designed with a compact 32" x 19" desktop, this small electric standing desk seamlessly fits into limited areas like apartments, bedrooms, and cozy home office corners without crowding your room. It is the ultimate space-saving, height-adjustable solution to pair with under-desk treadmills and walking pads for remote workers, freelancers, and students
- 【4 Memory Presets & DIY Wheel Ready】 This adjustable desk features a smart control panel with 4 programmable memory presets for effortless one-touch height adjustment (28.3" to 46.5"). Plus, built-in universal M8 screw holes on the desk feet allow you to easily install your own casters/wheels to DIY it into a mobile rolling desk.
- 【176 lbs Max Load & Rounded Safety Corners】 Constructed with heavy-duty steel rails and a solid desktop, this small stand up desk supports up to 176 lbs with exceptional stability while transitioning. The tabletop features smooth rounded corners to protect you, your family, or pets from accidental bumps in tight, compact spaces.
- 【Rigorously Tested for Long-Lasting Use】 Engineered for daily reliability, our motor and lifting system have been rigorously tested to withstand up to 50,000 lift cycles under full capacity. Enjoy a whisper-quiet, smooth sit-to-stand transition that keeps you focused and productive all day.
- 【Easy Assembly & Budget-Friendly Choice】 Comes with detailed instructions and all hardware included for a hassle-free, quick setup. Get premium electric sit-stand functionality at an unbeatable, budget-friendly price. Risk-free purchase with dedicated customer support ready to help.
Prefer user-facing locators
Playwright describes locators as “the central piece of Playwright’s auto-waiting and retry-ability.” A locator resolves the element when an action or assertion runs, rather than relying on an element handle captured earlier. This helps when a page re-renders.
Use the locator that best expresses the control or the contract your app exposes:
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →getByRole()for controls and landmarks by accessible role and name, such as a button named “Save.”getByLabel()for form fields identified by their labels.getByText()for meaningful visible text when text is the right way to identify the target.getByPlaceholder(),getByAltText(), orgetByTitle()when those attributes make the intended element clear.getByTestId()when the application defines a deliberate test contract with stable test IDs.
CSS and XPath selectors are available, but a long selector tied to a page’s DOM structure can break after a layout change even when the user-facing behavior is unchanged. If a locator matches multiple elements, narrow it with a meaningful parent locator or filtering rather than selecting an arbitrary match. See the locator guide for locator strategies and examples.
Let actionability waits do their job
Before locator.click(), Playwright checks that the locator resolves to exactly one element and that the element is visible, stable, able to receive events, and enabled. It waits for those conditions within the configured timeout. A timeout means the required conditions did not become true in time; it is a signal to inspect the page state, target, or timing, not a reason to add a blind sleep.
Auto-waiting addresses common readiness conditions, but it cannot decide what success means for your application. Follow important actions with an assertion about the result, using Playwright’s auto-retrying assertions where appropriate. For example, assert that a confirmation message appears or that a changed value is visible. Do not treat a click completing as proof that the workflow succeeded. Read more in the actionability guide and assertions documentation.
Use Codegen to draft interactions
Playwright Codegen can record browser interactions and produce starter code. Run it with a target URL:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #3
- [INTEL POWERED CONTENT] - Built with a 8th Generation Hexa-Core Intel i5 and 32GB of DDR4 RAM; Modern, Windows 11 ready, with 4K support, Executive multitasking, media streaming and smooth, multi-tab web browsing; Perfect as an all-purpose multimedia computer; built for content creators; Plenty of RAM and Mass storage for photo and video editing powered by Intel HD 630
- [LATEST WIRELESS TECH] - This Dell Desktop Computer easily connects to the internet through the Built In WiFi / Bluetooth
- [SOLID STATE STORAGE] - This Dell Computer setup comes with an ultra-fast 1TB Solid State Drive (SSD); Setup as the primary boot device; Boot and load programs with lightning speed ; Additional expansion available
- [BUY & OWN WITH CONFIDENCE] - From the world's largest Microsoft Authorized Refurbisher; Quality Guarantee and Free Tech Support; Award-winning Customer Service; | Support Sustainable Business
- [MODERN HI-SPEED PORTS] - USB 3.0 (x4) | USB 2.0 (x4) | DisplayPort (x1) | HDMI Port (x1) | Audio Combo Jack (x1) | Audio Out (x1) | RJ-45 Ethernet (x1) | Internal SATA (x3)
npx playwright codegen https://example.com
The URL is optional. The CLI can also select a browser, target language, and output file; check Codegen documentation for the options supported by your installed release. Generated locators favor role, text, and test IDs, and Codegen can produce assertions for visibility, text, or values.
Treat the output as a draft. Review whether each locator uniquely identifies the intended control, whether the generated steps represent the workflow you mean to test, and whether the assertions verify a meaningful result. Remove incidental clicks or navigation that are not part of the scenario. Recording a successful path does not establish that the test will cover relevant failure cases.
Debug failures with traces
A trace lets you inspect what happened during a run. Playwright Trace Viewer can show the action sequence, screenshots, DOM snapshots, logs, and source locations. For a Playwright Test suite, configure tracing in the runner when you need test-aware diagnostic information.
Trace a retry in CI
The official guide recommends capturing a trace on the first retry in CI. In the Playwright Test configuration:
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
trace: 'on-first-retry',
},
});
This keeps trace capture focused on a retry rather than recording every successful run. The guide also documents retain-on-failure for a workflow that does not use retries. Tracing every run can be performance-heavy and produce more artifacts, so set a retention policy that fits the diagnostic need and artifact budget.
Open and inspect a trace
Open a saved trace archive with:
npx playwright show-trace path/to/trace.zip
Use the timeline and snapshots to find the first action where the observed page diverged from the expected flow. Check the locator, the page state, console or network-related clues in the trace, and the assertion that failed. The Trace Viewer guide describes the viewer and its panels.
Rank #4
- Create Instant Active Standing - VIVO’s desk riser provides on-demand standing throughout the day for the freedom to get out of your chair and relieve muscle tension, reduce stress, and increase productivity. --Patented--
- Space Efficient 31.5" Surface - The top surface measures 31.5” x 15.7”, which maximizes space while still providing room for dual monitors. The 31.3" x 11.8" (10.5" in center) keyboard tray raises in sync with the top surface to create a comfortable workstation.
- Strong 33 lbs Lift Assist - Go from sitting to standing in one smooth motion using the innovative simple touch height locking mechanism (Adjustment Range: 4.5" to 20"). Lift design elevates straight upwards.
- Very Minimal Assembly - This riser is almost ready to go right out of the box! Place on your existing desk, attach the keyboard tray, and start organizing your workstation.
- We've Got You Covered - Sturdy, high-grade steel design is backed with a 3-Year Manufacturer Warranty and friendly tech support to help with any questions or concerns.
Distinguish runner traces from context tracing
The lower-level browserContext.tracing API captures browser operations and network activity, but it does not record test assertions. If your goal is a fuller failure trace that includes the Playwright Test context, configure tracing through Playwright Test instead. See the tracing documentation for the distinction and usage.
Choose browser coverage deliberately
Testing every browser is not automatically necessary for every job. Match the set of engines to the compatibility question the automation is meant to answer.
- Choose Chromium, Firefox, or WebKit when you need coverage across those browser engines.
- Use a branded Chrome or Edge channel when behavior in that specific installed browser channel is part of the requirement.
- Prefer Playwright-managed binaries for a consistent, version-aligned test environment when branded-channel behavior is not required.
In Playwright Test, projects can represent different browser configurations within a suite; the browser guide covers the available browser options. Do not assume a test that passes in one engine establishes identical behavior in another.
Troubleshooting common problems
- Browser launch fails after updating Playwright. The installed browser binaries may not match the package version. Run
npx playwright installagain; in CI, include the required system dependencies for the browser you use. - A click times out. The element may not be unique, visible, stable, enabled, or able to receive events before the timeout. Inspect the locator and current UI state, then use a more precise locator or wait for a real application condition. Avoid increasing the timeout without identifying what is delayed or blocked.
- A selector breaks after a page redesign. If it depends on DOM nesting or styling classes, replace it where possible with a role, label, text locator, or an intentional test ID.
- The test passes after a click but misses a broken workflow. Add an assertion for the user-visible result that proves the behavior under test; the click itself is not that proof.
- A generated script is flaky or hard to read. Review Codegen’s output for ambiguous targets, incidental steps, and missing outcome assertions. Keep the intentional workflow and make its locator and expected result explicit.
- The trace does not show the assertions you need. Check whether you used the lower-level context tracing API. Configure tracing through Playwright Test for a test-run trace that captures the fuller testing context.
- CI browser installation or startup fails. Confirm the package and browser versions, install the required browser binaries, and use the documented dependency installation command for the chosen engine and environment. Verify commands against the project’s Playwright version.
Or skip the browser setup
If the job is simply to capture a page as an image or PDF, a browser-automation script may be more setup than the task requires. ScreenshotNeo is a website screenshot API and MCP server from Yorker Media. One GET request returns a PNG, JPEG, WebP, or PDF; the API uses the parameter names other screenshot APIs use, which can make switching straightforward. See the ScreenshotNeo site and the API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
ScreenshotNeo accepts cookie and consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response identifies page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
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 glitchesFrequently Asked Questions
Can I use Playwright without its test runner?
Yes. Use a language-specific Playwright browser API and manage the browser, context, and page lifecycle yourself. Playwright Test is a separate, integrated runner for test suites.
Does a passing Playwright click prove the feature works?
No. It proves the action completed under Playwright’s checks; assert the user-visible outcome that matters to the scenario.
Can Codegen produce a finished test automatically?
It produces a useful draft from recorded interactions, but you should review locator uniqueness, test intent, and assertions before relying on it.
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.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →

