Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Playwright’s Python library directly for browser automation scripts; use the official pytest-playwright plugin when building an end-to-end test suite. Both approaches can automate Chromium, Firefox, and WebKit. The core habits are the same: install the browser binaries for your Playwright version, find elements with robust locators, and rely on retrying actions and assertions instead of fixed sleeps.

What is Playwright for Python, and which workflow should you choose?

Playwright is a Python library for automating web applications. It offers synchronous and asynchronous APIs and supports Chromium, Firefox, and WebKit. Use it to navigate pages, interact with controls, inspect results, and exercise user-facing workflows. The Playwright Python installation guide recommends the official pytest plugin for end-to-end testing.

Workflow Best fit What you manage
Playwright library Standalone scripts, general browser automation, or cases where you want to manage contexts directly. Your script’s setup, browser and context lifecycle, checks, and cleanup.
pytest-playwright End-to-end tests organized and run with pytest. The plugin supplies fixtures, including a page fixture, and supports browser configuration; you write the test and assertions.

For a one-off task, the direct library keeps the control flow explicit. For a test suite, the plugin’s fixtures provide a consistent test structure and an isolated page and browser context per test, which helps stop browser state from leaking between tests.

How do I install Playwright for Python?

Install the Python package and the browser binaries as separate steps. Run the commands from the virtual environment where you intend to use Playwright.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

For a standalone script

python -m pip install playwright
playwright install

For a pytest suite

python -m pip install pytest-playwright
playwright install

The package contains the Python API; playwright install obtains the browser binaries needed to launch browsers. Playwright browser revisions are tied to library releases, so after upgrading the package, rerun the install command if the required browser binaries have changed. A mismatch can prevent a browser from launching. The browser documentation explains installation and browser configuration.

Python and operating-system support can change. Check the current installation requirements for the supported Python version and platform matrix rather than relying on an old setup guide. The official installation page also documents Poetry and uv installation paths.

How do I write a first Playwright script?

The synchronous API is a straightforward starting point for a regular Python script. This example opens a browser, navigates to a page, prints its title, and closes the browser:

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto('https://playwright.dev')
    print(page.title())
    browser.close()

The with block starts and stops Playwright; explicitly closing the browser releases its resources. For longer scripts, prefer browser.new_context() followed by context.new_page() when you need to control browser context state such as cookies and permissions. A context is an isolated browser session; separate contexts help keep state separate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

How do I use Playwright with pytest?

After installing pytest-playwright and the browsers, put a test in a file named test_*.py and run pytest from the project environment. The plugin supplies the page fixture. By default, tests are headless and use Chromium.

from playwright.sync_api import Page, expect

def test_get_started_link(page: Page):
    page.goto('https://playwright.dev/')
    page.get_by_role('link', name='Get started').click()
    expect(page.get_by_role('heading', name='Installation')).to_be_visible()

This checks an outcome visible to a user: following the link reaches a page with the expected heading. A test that only clicks a control can pass even if the application did not reach the intended state, so assert the result that matters. The writing tests guide covers test organization, fixtures, and configuration.

The plugin creates an isolated page and browser context for each test. This limits contamination from cookies, local storage, and other session state left by a different test. If a test depends on shared server-side data, isolation in the browser does not reset that data; arrange setup and cleanup for the application state as well.

Should I use the sync or async API?

Choose the API that fits the surrounding code. For a conventional script or the standard pytest test shown above, use sync. Use async when the application already uses asyncio or when you need to integrate browser operations into an asynchronous flow. Do not mix sync and async Playwright calls in one workflow.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
import asyncio
from playwright.async_api import async_playwright

async def main():
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page()
        await page.goto('https://playwright.dev')
        print(await page.title())
        await browser.close()

asyncio.run(main())

Every operation that returns asynchronously is awaited, including navigation, title lookup, and browser launch. The library guide documents both API styles. It also states that the Playwright API is not thread-safe: in a multithreaded program, create a separate Playwright instance per thread. The async guide warns that cancelling a task during a Playwright call is unsupported and has undefined behavior.

How do I select an element reliably?

Locators are Playwright’s central way to find elements. Prefer selectors that describe how a person identifies the control, such as its role and accessible name, label, text, or placeholder. Use a test ID when your team intentionally treats it as a stable testing contract.

# Accessible role and name
page.get_by_role('button', name='Save').click()

# Label for a form field
page.get_by_label('Email').fill('reader@example.com')

# A deliberate test ID contract
page.get_by_test_id('checkout-submit').click()

When a page has repeated elements, narrow the locator to the relevant region or filter it by meaningful content instead of selecting an arbitrary position. For example, locate a product card by its heading and then find the button inside that card. Positional CSS or XPath can be appropriate when the page offers no better contract, but they are brittle when markup order changes. The locator guide describes locator composition and filtering.

Actions such as click() wait for the locator to become actionable, and Playwright assertions retry until the expected state appears or the assertion times out. Prefer a web-first assertion such as expect(locator).to_be_visible() over reading state once and checking it immediately. Do not use time.sleep() as a general synchronization method: a fixed delay can be too short on a slow run and wastes time on a fast one. Wait for a meaningful page condition instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

How do I run tests in Firefox and WebKit?

Playwright supports Chromium, Firefox, and WebKit. Select the engines that reflect the rendering environments relevant to your product and users; a test suite does not need to run every scenario in every engine to be useful. The plugin supports browser configuration and multiple-browser runs. For example, the pytest plugin accepts browser selection on the command line:

pytest --browser chromium --browser firefox --browser webkit

Install the corresponding binaries with playwright install. A branded browser channel or a device-emulation configuration is a separate choice, not a guarantee that the branded browser is installed by default. Check the live browser guide for supported channels, configuration, and platform details; these can change with Playwright releases.

In continuous integration, run tests in the same supported environment and with the browsers your project targets. Keep package and browser versions aligned by installing the binaries appropriate to the Playwright version used by the job.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How do I debug a failing Playwright test?

Use Codegen to draft interactions

Run playwright codegen https://your-test-site.example to open a browser and the Playwright Inspector. Interact with the page and Codegen records actions while suggesting locators, with preference for role, text, and test IDs. Treat its output as a draft: review selectors, remove incidental steps, and add assertions for the application behavior you actually need to verify. Generated code is not a substitute for test design. See the Codegen guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Record and inspect a trace

To record traces for pytest runs, use:

pytest --tracing on

To retain traces only for failed tests, use:

pytest --tracing retain-on-failure

The Trace Viewer presents the action timeline, logs, source, network activity, and DOM snapshots, which helps distinguish a wrong locator from a navigation or application-state problem. The browser-hosted viewer loads traces locally in the browser rather than transmitting them externally, according to the Trace Viewer documentation. Trace files can still contain page content and test data; handle and share the artifacts according to your project’s data practices.

Can Playwright test an API?

Yes. APIRequestContext sends HTTP(S) requests without opening a page. That makes it useful for API tests, preparing server-side state before a browser test, or checking a server-side postcondition after a UI action. It does not replace browser coverage when the behavior being tested is a user interaction.

from playwright.sync_api import sync_playwright, expect

with sync_playwright() as p:
    request = p.request.new_context(
        base_url='https://playwright.dev',
        extra_http_headers={'Accept': 'application/json'},
    )
    response = request.get('/api')
    print(response.status)
    request.dispose()

Use your application’s actual API URL, authentication, request body, and expected response for a real test. Validate the response status and content that matter to the scenario; a successful request alone does not establish that the UI workflow works. The API testing guide shows API tests, setup before page navigation, and post-action checks.

What commonly goes wrong, and how do I fix it?

  • The browser will not launch after an upgrade: the installed binaries may not match the Python package. Run playwright install in the same environment as the upgraded package.
  • A locator times out: confirm the page reached the expected state and that the locator matches the intended accessible role, name, label, or test ID. If the UI is asynchronous, assert the real expected condition rather than adding a fixed sleep.
  • A test passes alone but fails in the suite: inspect state outside the isolated page, especially shared server-side data or external test dependencies. Give tests appropriate setup and cleanup.
  • A trace is missing for a passing test: with retain-on-failure, successful-run traces are removed. Use --tracing on when you need traces for all runs.
  • A branded browser or device setup is unavailable: verify the current browser configuration and installation requirements; do not assume every channel is installed with the default browser binaries.
  • Concurrent code behaves unpredictably: do not share one Playwright instance across threads. Use one instance per thread, and avoid cancelling an async task during a Playwright call.

When a screenshot is the deliverable rather than a browser test

Playwright is appropriate when you need to exercise and verify browser behavior. If the task is simply to request a website screenshot or PDF, a screenshot API may be a better fit than maintaining browser-launch code. ScreenshotNeo is a website screenshot API and MCP server for developers; its clean-shot handling removes known consent banners, newsletter popups, and chat widgets before capture, and only clean shots are billed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Or skip the browser setup

One GET request returns an image or PDF. This cURL example saves a WebP screenshot; see the ScreenshotNeo API documentation for request options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Cookie banners, popups, and chat widgets are removed before the shot. Bot checks, blank pages, and failed loads are never billed. An MCP server lets AI agents use screenshots through Claude, Cursor, or any MCP client. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free and get 1,000 screenshots a month with no card.

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.