Skip
AgentSandbox.host

Browser testing at scale with Playwright and Selenium: setup in Python and Node.js, Docker images, Selenium Grid, parallel runs, sharding and flaky tests.

Latest

  1. How to fix flaky browser tests in Playwright and Selenium

    Fix flaky browser tests by first proving they are flaky (run them many times), then separating environment trouble from test bugs, then removing the cause, usually timing, shared state or overloaded machines. Retries and traces find flaky tests; auto-waiting, isolation and fewer workers fix them.

  2. Playwright CLI: every command and the test options that matter

    The Playwright CLI is the npx playwright command. Its main commands are test, show-report, show-trace, codegen (record a test), install and install-deps (browsers and system packages) and merge-reports; npx playwright test takes options for filters, workers, shards, retries, traces and debugging.

  3. Playwright async in Python: when to use it and how

    Use Playwright's async API in Python when your code already runs on asyncio. Import async_playwright from playwright.async_api, await every call, and start it with asyncio.run. For pytest, install pytest-playwright-asyncio and mark tests with the session loop scope.

  4. Playwright with Python: install it and write your first test

    To start with Playwright in Python, install the pytest plugin with pip install pytest-playwright, download the browsers with playwright install, write a test function that takes the page fixture, and run pytest. Tests run headless in Chromium by default; --headed and --browser change that.

  5. Playwright testing with Node.js: install, first test, config

    To start Playwright testing in Node.js, run npm init playwright@latest, which adds @playwright/test, a playwright.config.ts and an example test, then run npx playwright test. Tests use the page fixture, role-based locators and retrying assertions; npx playwright show-report opens the results.

  6. Playwright vs Selenium: a sourced comparison table

    Playwright and Selenium are both Apache-2.0 browser automation projects. Playwright gives one API over pinned Chromium, Firefox and WebKit builds with auto-waiting and its own runner; Selenium implements W3C WebDriver in six languages and scales out with Selenium Grid.

  7. Run browser tests in parallel: workers on one machine, shards across many

    On one machine, run browser tests in parallel with Playwright Test's worker processes (by default half the logical CPU cores) or pytest-xdist. Across machines, split the suite with --shard=x/y, one shard per machine or sandbox, and set fullyParallel so shards get an even share.

  8. Run Playwright tests in Docker with the official image

    Run Playwright tests in Docker from the official image tagged with your exact Playwright version, such as mcr.microsoft.com/playwright:v1.65.1-noble, with --init and --ipc=host, then npm ci and npx playwright test inside it. The image has the browsers but not your Playwright package.

  9. Selenium Grid: what it is and how to run it in Docker

    Selenium Grid runs WebDriver tests on remote browsers by routing each session from one address to Nodes that host the browsers. In Docker, start selenium/standalone-chrome for one container, or a selenium/hub with selenium/node-* containers for a real Grid, each with 2 GB of shared memory.

  10. Testcontainers for browser tests: Selenium and Playwright in throwaway containers

    Testcontainers starts a browser in a throwaway Docker container from your test code and removes it afterwards. Its Selenium modules for Java, Python and Node.js hand you a WebDriver on a fresh browser; for Playwright, a generic container running the official browser server does the same.