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

Configure a browser automation session in layers: install a compatible browser, choose the browser and headless or headed mode, decide whether state should persist, then set network access, credentials, and timeouts. In Playwright, those choices are split across browser launch, browser context, and test configuration options. In Selenium 4, use a browser-specific Options class and pass it to the WebDriver session. The examples below show both approaches, including how to keep login state deliberately and how to diagnose common failures.

What to configure in a browser session

A browser session is more than a browser name and a URL. Its settings determine which browser binary starts, whether a person can see it, what cookies and permissions it has, how it reaches the network, and how long it waits for pages and actions.

Make these decisions in order:

  1. Browser and installation: choose Chromium, Firefox, WebKit, or a branded channel such as Chrome or Edge, then install the matching browser and any operating-system dependencies.
  2. Execution mode: use headless mode for routine automation and CI; use headed mode when you need to observe behavior while debugging.
  3. State: start isolated for repeatable tests. Load saved authentication state or use a dedicated persistent profile only when you intentionally need login continuity.
  4. Network and identity: configure a proxy, bypass list, credentials, headers, locale, or permissions when the target environment requires them.
  5. Wait behavior: set navigation, action, and script timeouts for the application’s actual response times rather than relying on an unexamined default.

Playwright’s test configuration centralizes settings shared by tests; Selenium’s browser-specific options configure a WebDriver session. In either framework, browser-specific settings may not behave identically across engines, so verify them when changing browsers or versions.

Configure a Playwright session

Install the browser first

Install Playwright’s browser binaries before starting a session:

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.
npx playwright install

On Linux or a clean CI image, install Chromium and its system dependencies with:

npx playwright install --with-deps chromium

If the browser download must pass through a firewall, set HTTPS_PROXY for the install command. For example, in a POSIX shell:

HTTPS_PROXY=http://proxy.example:3128 npx playwright install chromium

Playwright supports Chromium, Firefox, WebKit, and branded Chrome and Edge channels. Its default headless route uses a separate Chromium headless shell unless you select a browser channel. Choose a channel when the branded browser itself is important to the test, not just because it is installed on a developer’s machine. Consult the current Playwright browser and configuration references when upgrading: channel names, defaults, and available settings can change.

Set shared test options

For a Playwright Test project, put settings shared across tests in playwright.config.ts. This example uses Chromium, headless mode, a saved login state, a proxy, and an explicit action timeout:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import { defineConfig } from '@playwright/test';

export default defineConfig({
  use: {
    baseURL: 'https://example.test',
    browserName: 'chromium',
    headless: true,
    storageState: 'state.json',
    proxy: {
      server: 'http://proxy.example:3128',
      bypass: 'localhost',
    },
    actionTimeout: 10_000,
  },
});

With baseURL set, tests can navigate to a relative path such as /account. The storageState setting loads the saved cookies and local storage for the context. proxy applies network routing, while actionTimeout limits how long an individual action waits. For visual diagnosis, temporarily set headless: false and run the same test where you can observe the browser.

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.

Other useful Playwright use settings include extraHTTPHeaders, httpCredentials, ignoreHTTPSErrors, offline emulation, and trace or recording options. Use certificate-error ignoring only in a controlled test environment; it changes what the browser accepts and can hide a certificate problem that matters in production.

Save login state instead of logging in for every test

To reuse an authenticated state, create it once through a deliberate login flow, save the browser context’s storage state to state.json, then point storageState at that file in the shared configuration. Keep the state file out of source control: it can contain authentication cookies that grant access to an account. Regenerate it when the session expires or the account’s authentication changes.

Use a fresh BrowserContext when tests must not share cookies, local storage, permissions, or cache. A saved state file is a convenient way to seed an otherwise isolated context; a persistent browser profile is the choice when the profile itself should be retained between runs. For persistent profiles, use a dedicated user-data directory, not a directory currently open in a person’s browser.

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.

Choose the right Playwright layer

Shared test behavior belongs in the test runner’s use configuration. Browser startup choices and user-data directories belong to launch options; settings such as locale, permissions, HTTP credentials, and storage state belong to a browser context. If you use Playwright’s browser API directly instead of Playwright Test, create the browser and context explicitly and pass the relevant options at those layers. Avoid putting all settings into a single global profile: that makes tests harder to isolate and stale state harder to spot.

Configure a Selenium 4 session

Use browser-specific Options

Selenium 4 requires browser options classes. Create the appropriate class—such as ChromeOptions or FirefoxOptions—then pass it to the matching driver. This Python example starts headless Chrome, uses the eager page-load strategy, routes through a proxy, and sets a page-load timeout:

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.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument('--headless=new')
options.page_load_strategy = 'eager'
options.proxy = {
    'proxyType': 'manual',
    'httpProxy': 'proxy.example:3128',
}

driver = webdriver.Chrome(options=options)
driver.set_page_load_timeout(30)

try:
    driver.get('https://example.test')
    print(driver.title)
finally:
    driver.quit()

The example uses Selenium’s Chrome options and driver, so it is not a browser-neutral configuration. For Firefox or another supported browser, use that browser’s Options class and driver. WebDriver capabilities describe what the session supports; vendors can also define extension capabilities. Keep browser-specific fields in the matching options object rather than assuming a Chrome setting transfers unchanged to another browser.

Understand the page-load and wait settings

Selenium’s page-load strategies are normal, eager, and none. They change when navigation returns; they do not establish that a JavaScript application has finished rendering or that a particular control is ready. Use an explicit wait for the page condition your next step actually needs. Also distinguish page-load, script, and implicit-wait timeouts: they govern different parts of session behavior. Set deliberate values rather than increasing every timeout when one selector or navigation is slow.

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.

The example sets a 30-second page-load limit. Treat that as a starting value for the target application, not a universal performance expectation. Selenium exposes script, page-load, and implicit-wait timeouts; choose each only if the corresponding operation needs a bound.

Configure state, proxies, and session options safely

Choose isolated or persistent state

For most test runs, isolated state is the safer default because one test’s cookies or permissions cannot silently affect another. Persist state only to avoid a repeatable setup step such as logging in. Protect saved state files and profile directories as credentials, and keep them outside public repositories and shared build artifacts. If an unexpected login or personalization appears, retry from a new context or profile before changing the test itself.

Test proxy routing separately

Configure the proxy at the browser session or context layer, and add bypass domains only for hosts that should connect directly. Verify the proxy and bypass behavior independently before debugging page selectors or application code; otherwise, a routing failure can look like a page timeout. Proxy authentication syntax and capabilities vary by browser and framework, so use the format supported by the specific options object rather than copying settings between Playwright and Selenium.

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

Set only the identity and permissions the test needs

Playwright can set headers, HTTP credentials, locale, permissions, and offline behavior through its documented context or test options. Use the smallest set that reproduces the real scenario. For example, setting a locale is more deterministic than relying on whichever locale happens to be configured on the CI machine. Likewise, use test credentials rather than a person’s active browser login.

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

Make sessions reliable and easier to debug

Use an intentional timeout policy

Set separate limits for page navigation and individual actions. A navigation may be slow while a button should respond quickly, or a page may return promptly while an application request never completes. In Playwright, actionTimeout bounds actions in the test configuration. In Selenium, set page-load and script timeouts as needed and wait explicitly for the next UI condition. Avoid treating a longer timeout as a fix for a broken proxy, stale session, or wrong selector.

Compare headed and headless behavior

Headless mode is useful for unattended runs; headed mode makes it easier to inspect a browser while diagnosing a failure. If a test fails only in CI, reproduce it with the same browser version, options, profile state, and network conditions before concluding that headless mode is the cause. Playwright also documents a distinct default headless Chromium path, so selecting a branded channel can matter when matching a particular browser environment.

Capture evidence from failures

When a CI-only failure is intermittent or difficult to reproduce, retain a Playwright trace, screenshot, or relevant driver logs. Evidence helps distinguish a navigation problem from a selector mismatch, authentication expiry, or environment difference. Do not leave verbose logging or captured credentials in public artifacts; traces and screenshots can expose page content and account data.

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

Troubleshooting common session failures

  • Browser executable or driver fails to start: install the browser binaries, confirm required Linux dependencies are present, and check that the framework and target browser versions are compatible. On a clean Linux runner, use the Playwright dependency-install command shown above.
  • Browser download fails behind a firewall: configure HTTPS_PROXY for Playwright’s browser installation command, then retry. This download proxy setting is separate from the proxy used by a running browser session.
  • Login disappears between runs: confirm the saved storage state is loaded from the expected path and has not expired. If persistence is intentional, use a dedicated user-data directory; do not rely on an unrelated browser profile.
  • Tests unexpectedly share login or site settings: create a fresh context or profile and rerun. Shared state can come from cookies, local storage, permissions, or cache.
  • Pages time out through a proxy: test routing and bypass domains on their own, then confirm the session’s proxy syntax and credentials are correct. Only after network access is verified should you adjust navigation timeouts.
  • Navigation returns but the page is not ready: a page-load strategy signals navigation behavior, not readiness of a particular app element. Wait for the actual selector or state required by the next step.
  • Certificate errors occur in a test environment: check the test certificate and the framework’s certificate-handling option. Only opt into ignoring HTTPS errors when that is an intentional, isolated test condition.
  • CI fails but a local run passes: compare browser installation, browser channel, headless mode, state files, proxy route, and timeout values. Run headed where feasible and examine a trace, screenshot, or driver log to narrow the difference.

When a browser session is more than you need

Playwright and Selenium are the right tools when you need to interact with a page: sign in, click controls, test a workflow, or inspect browser behavior. If the task is only to capture a website image or PDF, running a full browser automation stack can add setup and maintenance without helping the result. ScreenshotNeo is a website screenshot API and MCP server from Yorker Media for that narrower job; it is not a replacement for interactive browser tests. See ScreenshotNeo for the service overview.

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.

Or skip the browser setup

Make one GET request for a screenshot; the API can return PNG, JPEG, WebP, or PDF. The cURL example below saves a WebP image. See the ScreenshotNeo API documentation for request parameters and response details.

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

For code that needs the response body, Python and Node.js examples are also available:

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://example.test"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.test' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
await Bun.write('shot.webp', res);

ScreenshotNeo accepts cookie or 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 cost nothing, with verdict and billing information in response headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots each month with no card; paid plans start at $5 for 3,000. Sign up free for ScreenshotNeo.

Frequently Asked Questions

Does headless mode guarantee the same result as a visible browser?

No. Headless is an execution mode, not a promise that every browser environment will render or behave identically. When a failure appears only in CI, compare the installed browser and channel, session settings, state, and network conditions, and reproduce it in headed mode if possible.

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

Can I use a proxy to make a site accept my automation?

A proxy changes the route used for network traffic; it does not guarantee that a site will allow an automated session or that a CAPTCHA will disappear. Confirm that the proxy is configured for the browser session and that its routing works before investigating page behavior.

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.