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

Browser automation means controlling a real browser with code so it can repeat a task or verify an end-to-end user journey. A dependable first project is small: open a page, locate an element with a stable selector, perform one action, assert the visible result, and close the browser.

This quickstart uses JavaScript and Playwright for that workflow, then shows how Selenium and Puppeteer differ, how to prepare local and CI environments, and how to diagnose the failures beginners encounter most often.

Choose a framework before installing anything

No framework is universally best. Match the tool to your language, browser requirements, test runner, and existing team stack.

Framework Good default when Important setup detail
Playwright You want one cohesive test setup across Chromium, Firefox, and WebKit, with locator-based actions and web-first assertions. Install browser binaries that match the Playwright package version.
Selenium Your organization already uses WebDriver bindings, Grid, or a language with a mature Selenium ecosystem. Choose a language binding, browser, and driver; Selenium Manager is the default driver/browser management path in current bindings.
Puppeteer You want a direct JavaScript API for launching or connecting to a browser and controlling pages. Pin the package version and use its launch, page, navigation, interaction, inspection, and close workflow.

Playwright documents projects for Chromium, Firefox, WebKit, branded Chrome or Edge channels, and device emulation. Selenium targets major browsers through WebDriver implementations and can allocate browsers across machines with Grid. Puppeteer’s current getting-started page identifies version 25.12.0; check the package documentation when copying examples because versions change.

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.

What you need for a first run

  • A supported runtime such as Node.js for this JavaScript example.
  • The framework package and its matching browser binaries (Playwright), or a browser and driver path (Selenium).
  • Operating-system libraries when a headless browser requires them in Linux or CI.
  • A test page and a selector that is unlikely to change.

Keep your first script independent of your production application. A public page or a local fixture lets you separate framework problems from application bugs.

Build a first Playwright test in JavaScript

1. Create the project

  1. Make a directory and initialize npm: mkdir browser-quickstart && cd browser-quickstart && npm init -y.
  2. Install Playwright Test: npm install -D @playwright/test.
  3. Install the default browser binaries: npx playwright install.
  4. On a Linux machine missing shared libraries, install Chromium dependencies with npx playwright install-deps chromium (use the dependency command appropriate to your selected engine).

Playwright releases target specific browser versions. After upgrading the package, run the install command again so the binaries are compatible.

2. Write a small, observable test

Create tests/example.spec.js:

import { test, expect } from '@playwright/test';

test('search returns a result', async ({ page }) => {
  await page.goto('https://www.google.com', { waitUntil: 'domcontentloaded' });

  const search = page.getByRole('combobox', { name: /search/i });
  await search.fill('Playwright browser automation');
  await search.press('Enter');

  await expect(page).toHaveTitle(/Playwright/i);
});

The example uses a role and accessible name rather than a fragile CSS path. The assertion checks a user-visible outcome: the page title after submitting. On a site whose consent dialog appears first, handle that dialog with a locator before filling the search field, or use a test fixture that disables it.

3. Run and inspect it

  1. Run headless: npx playwright test.
  2. Watch the browser while debugging: npx playwright test --headed.
  3. Open the HTML report after a failure: npx playwright show-report.

Playwright actions wait for elements to become actionable, and web-first assertions wait for the expected state. Prefer those behaviors to arbitrary sleeps such as waitForTimeout(5000). A fixed delay may pass on your laptop and fail under a slower CI runner.

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.
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.

Use stable locators and assertions

Locator choices

  • Preferred: getByRole with an accessible name, getByLabel for form controls, and getByText when the visible wording is the contract.
  • Useful fallback: a dedicated data-testid attribute agreed with developers.
  • Last resort: long CSS or XPath chains tied to layout or generated class names.

If a locator matches multiple elements, narrow it with a name, filter, or container. Do not “fix” ambiguity by selecting the first match unless position is genuinely part of the requirement.

Assertions that explain the requirement

Assert the state a user or another system relies on: a heading is visible, a URL has changed, a confirmation message appears, a row contains expected text, or a download exists. A screenshot alone is useful evidence but is not a substitute for an assertion.

Playwright browser and project configuration

A configuration file can run the same test against multiple engines:

import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  projects: [
    { name: 'chromium', use: { ...devices['Desktop Chrome'] } },
    { name: 'firefox', use: { ...devices['Desktop Firefox'] } },
    { name: 'webkit', use: { ...devices['Desktop Safari'] } }
  ]
});

Run one project with npx playwright test --project=webkit. Use branded Chrome or Edge channels only when your compatibility requirement calls for them; otherwise the versioned Playwright browsers make runs more reproducible.

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.

Equivalent setup paths for Selenium and Puppeteer

Selenium

Selenium’s first-script path has three explicit pieces: a language binding, a browser, and a driver implementation. Install the binding for your language, install or provide the browser, and let current Selenium bindings use Selenium Manager for driver and browser management by default. A minimal Python flow is:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys

with webdriver.Chrome() as driver:
    driver.get("https://www.google.com")
    box = driver.find_element(By.NAME, "q")
    box.send_keys("Selenium browser automation", Keys.ENTER)
    assert "Selenium" in driver.title

When you need parallel allocation across machines, Selenium Grid is the scaling component; it is not required for a first local script. Selenium IDE is a record/playback extension, also optional.

Puppeteer

Puppeteer’s direct workflow is launch or connect, create a page, navigate, set a viewport, find an element, interact, inspect a result, and close:

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
await page.setViewport({ width: 1280, height: 800 });
await page.goto('https://www.google.com', { waitUntil: 'domcontentloaded' });
await page.locator('textarea[name="q"], input[name="q"]').fill('Puppeteer automation');
await page.keyboard.press('Enter');
await page.waitForNavigation({ waitUntil: 'domcontentloaded' }).catch(() => {});
console.log(await page.title());
await browser.close();

Confirm the Puppeteer version before using an example; the current getting-started documentation lists 25.12.0, while APIs can change between releases.

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

Make the script reliable in CI

  • Pin dependencies: commit the lockfile and upgrade framework and browser binaries together.
  • Install OS dependencies: use the Playwright dependency command or the equivalent packages in your CI image.
  • Control secrets: pass credentials through environment variables or a secret store, never source files committed to Git.
  • Capture evidence: enable traces, screenshots, or video only where they help diagnose failures; retain the HTML report for failed runs.
  • Isolate data: use a test account and reset or seed state so one run does not depend on another.
  • Set realistic timeouts: use framework timeouts and network-aware waits, not large global sleeps.
  • Check browser differences: run the engines your users require; do not assume Chromium behavior proves WebKit or Firefox behavior.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting common first-run failures

“Executable doesn’t exist” or browser launch failure

Cause: the browser binary was not installed, or it does not match the package. Run npx playwright install after installing or upgrading Playwright. In Linux CI, run npx playwright install-deps chromium (or the selected engine) and verify the base image supports the required libraries.

Driver or session errors in Selenium

Cause: a missing, incompatible, or inaccessible driver/browser. Confirm the binding version, browser version, and Selenium Manager output. If your organization manages drivers centrally, provide the approved driver path instead of mixing it with an unmanaged copy.

Locator found zero or multiple elements

Cause: the selector is tied to changing markup, the page is on a different state, or a consent dialog covers the control. Inspect the accessible role and name, add a stable test ID, and handle the dialog explicitly. Avoid silently choosing the first match.

Timeout waiting for an element or assertion

Cause: navigation has not reached the expected state, the application made a failed request, or the assertion describes the wrong outcome. Run headed, inspect the report or trace, and assert a specific visible state. Replace fixed sleeps with locator actions and web-first assertions.

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.

Passes locally but fails in CI

Compare runtime and package lockfiles, browser versions, OS dependencies, viewport, timezone, locale, network access, and test data. Reproduce with the same container or image locally, then add diagnostics before increasing timeouts.

Or skip the browser setup

If your goal is a clean image or PDF of a URL rather than an interaction test, ScreenshotNeo provides a single-call website screenshot API. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status.

See the full parameter reference in the ScreenshotNeo docs. A minimal cURL capture is:

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

For the same endpoint in Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

And 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}`);

ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. It supports full-page and element captures, device and retina settings, dark mode, PDF options, custom CSS or JavaScript, clicks, waits, request blocking, headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, usage reporting, and an OpenAPI specification. Every feature is on every plan: 1,000 shots per month free with no card, then $5 for 3,000, $15 for 15,000, $39 for 60,000, $99 for 250,000, or $249 for 1,000,000; yearly billing gives two months free. Create a free ScreenshotNeo account to start.

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

Frequently Asked Questions

Should I learn Selenium before Playwright?

No. Start with the framework that matches your project and language. Concepts such as locators, waits, assertions, isolation, and diagnostics transfer between tools.

Can these frameworks automate logged-in pages?

Yes, when you provide an authorized test account or saved session through the framework’s supported authentication facilities. Keep credentials out of source control and respect the site’s permission and terms.

Do I need browser automation for every screenshot task?

No. Use an automation framework when you must interact with a page and verify behavior. Use a screenshot API when you need repeatable rendering, image or PDF output, or batch capture without maintaining browser setup.

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.

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