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

Selenium WebDriver lets code control a real browser through a standard interface. Install a Selenium language binding, have a supported browser available, create a driver session, navigate, locate elements, interact with them, wait for the application state you need, assert the result, and call quit(). Current Selenium releases can usually obtain a matching driver automatically through Selenium Manager, so downloading ChromeDriver by hand is no longer always necessary.

This guide builds a reliable workflow from a first script to waits, browser options, remote execution, scaling, and troubleshooting.

What WebDriver is and how a session works

WebDriver is a language-neutral interface for driving browsers and is a W3C Recommendation. Your test uses a Selenium binding (such as Python or JavaScript), which sends commands to a browser-specific driver. The driver translates those commands for Chrome/Chromium, Firefox, Edge, Safari, or another supported browser.

A normal session follows this lifecycle:

  1. Create a driver and start a browser session.
  2. Open a URL and inspect the page.
  3. Locate elements with a locator such as an ID, CSS selector, or accessible role.
  4. Perform actions such as typing, clicking, selecting, or executing script.
  5. Wait for the application condition that proves the action completed.
  6. Assert the expected result and end the session with quit().

close() closes one browser window; quit() ends the WebDriver session and all its windows. Use quit() in cleanup so a failed test does not leave orphaned browser processes.

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.

Install Selenium and prepare a browser

Python

Install the binding in the environment used by your tests:

python -m pip install -U selenium

Install Chrome, Edge, or Firefox separately. Selenium Manager is shipped with Selenium beginning with version 4.6. When a binding cannot find a supplied driver, Manager can detect the browser, resolve a matching driver, download it, and cache it. Browser management for Chrome, Firefox, and Edge is documented as available from Selenium 4.11.0. Verify behavior for the exact Selenium release and operating system in your project.

When manual driver setup is appropriate

You can place a driver executable on PATH, provide its location with a Selenium Service object, or use an external manager when a required platform or feature is not covered by Selenium Manager. Keep the browser and driver versions compatible. Opera’s driver is officially unsupported with current Selenium functionality.

JavaScript

For Node.js, install the Selenium package:

npm install selenium-webdriver

The browser still must be installed. The JavaScript binding can use Selenium Manager through current Selenium releases when no driver path is supplied.

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.

Your first working Selenium script

Python example

This complete example opens a page, searches, verifies a result, and always quits:

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.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

URL = "https://www.google.com/"
driver = webdriver.Chrome()
try:
    driver.get(URL)
    search = WebDriverWait(driver, 10).until(
        EC.visibility_of_element_located((By.NAME, "q"))
    )
    search.send_keys("Selenium WebDriver")
    search.send_keys(Keys.ENTER)
    WebDriverWait(driver, 10).until(
        EC.title_contains("Selenium")
    )
    print(driver.title)
finally:
    driver.quit()

Replace the example URL and locators with those for your application. A locator that expresses the UI contract (a stable ID, name, or data-test attribute) is usually less brittle than a long XPath tied to layout.

Node.js example

const { Builder, By } = require('selenium-webdriver');

(async function run() {
  const driver = await new Builder().forBrowser('chrome').build();
  try {
    await driver.get('https://www.google.com/');
    const search = await driver.findElement(By.name('q'));
    await search.sendKeys('Selenium WebDriver');
    await search.submit();
    await driver.wait(async () => (await driver.getTitle()).includes('Selenium'), 10000);
    console.log(await driver.getTitle());
  } finally {
    await driver.quit();
  }
})();

Common element operations

  • find_element(By.ID, "login") or By.CSS_SELECTOR locates one element.
  • send_keys("text") enters text; click() activates a control.
  • get_attribute("value") reads an attribute; text reads visible text.
  • Use keyboard keys, select controls, frames, and JavaScript only when the page requires them; prefer normal user-like interactions first.

Wait for application state, not just page load

A navigation command waits according to the page-load strategy, but a loaded document is not necessarily a ready application. JavaScript may still render controls, fetch data, or replace a node after the load event. Acting too early creates race conditions and flaky tests.

Explicit waits

Describe the condition required for the next step:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(driver, 15)
button = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.save")))
button.click()
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".toast.success")))

Useful conditions include presence in the DOM, visibility, clickability, a changed title, a URL, text, an alert, or disappearance of a loading indicator. In JavaScript, driver.wait(condition, timeout) serves the same purpose.

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

Implicit waits and sleeps

An implicit wait changes how element searches poll globally. Mixing a long implicit wait with explicit waits can make timeout behavior difficult to predict, so many teams keep the implicit wait at its default and use explicit waits at the point of need. A fixed sleep is useful as a temporary diagnostic—if adding one makes a failure disappear, timing is involved—but replace it with a condition-based wait.

Page-load strategies

Strategy Returns after What you must add
normal The load event and dependent resources complete Explicit waits for application-specific readiness
eager DOMContentLoaded Waits for controls and data rendered after DOM construction
none The initial page download begins Careful waits for every required UI state

Faster strategies can reduce navigation time, but they never prove that your target element is usable.

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.

Locators and reliable interactions

Choose stable selectors

  • Prefer a unique ID, accessible name, or dedicated test attribute.
  • Use a short CSS selector when structure is stable.
  • Use XPath for relationships or text when CSS cannot express the requirement.
  • Avoid selectors based on generated class names, position, or deep layout ancestry.

Handle changing DOMs

Frameworks can replace an element after you locate it, producing a stale-element error. Locate the element immediately before use and wait for the replacement condition instead of caching a reference across a render. For overlays, wait for the overlay to disappear or the target to become clickable. For iframes, switch into the frame before locating its contents and switch back afterward.

Make cleanup unconditional

Use try/finally (Python) or try/finally with await driver.quit() (Node.js). Test runners should also capture a screenshot and page source on failure before quitting, when those artifacts help diagnosis.

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.

Run another browser or a remote session

Local browser selection

Choose the browser that represents your users and the operating systems you support. Selenium documents browser-specific guidance for Chrome, Edge, Firefox, Internet Explorer, and Safari. The driver-installation guidance lists Chrome/Chromium, Firefox, and Edge on Windows, macOS, and Linux; Internet Explorer on Windows; and Safari on macOS High Sierra or later. Check current browser and Selenium versions because support changes. Opera is not supported by current Selenium functionality.

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options()
options.add_argument("-headless")
driver = webdriver.Firefox(options=options)

Browser options carry capabilities such as headless mode, proxy settings, downloads, and page-load strategy. Do not assume a Chrome-only option works in Firefox or Safari.

Remote WebDriver

A local session starts the driver on the machine running your code. A remote session sends commands to a Selenium Server or Grid, where the browser runs. Supply browser options describing the requested session:

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

options = Options()
options.add_argument("--headless=new")
driver = webdriver.Remote(
    command_executor="http://grid-host:4444",
    options=options,
)

Grid is Selenium’s scaling path for parallel tests across browsers, versions, and operating systems. The remote host must be reachable, and its nodes must have the requested browser and driver.

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

WebDriver BiDi

WebDriver BiDi adds a bidirectional WebSocket channel so automation can receive browser events such as network requests, console messages, and JavaScript errors. Support depends on the browser, driver implementation, and Selenium version; verify the combination before building a test around a BiDi event.

Troubleshoot failures systematically

“Unable to obtain driver” or “driver not found”

  • Upgrade Selenium and confirm Selenium Manager is being invoked.
  • Check that the browser is installed and its version can be detected.
  • Put a manually downloaded, matching driver on PATH, or pass its path through a Service object.
  • On restricted platforms, verify Selenium Manager support rather than assuming automatic download will work.

Element not found, not interactable, or intercepted

  • Confirm the locator against the current DOM.
  • Wait for presence, visibility, or clickability as appropriate.
  • Dismiss or wait out modal overlays, switch to the correct iframe, and scroll only when necessary.
  • Check whether the page re-rendered and made your element reference stale.

Timeouts and flaky tests

Identify the exact state that was missing: a network response, spinner disappearance, text change, or enabled button. Add an explicit wait for that state. Temporarily add a sleep only to confirm a timing diagnosis, then remove it. Run the same test in another browser; if only one fails, investigate that browser or driver before rewriting working Selenium code.

Session crashes or blank pages

Record browser and Selenium versions, operating system, capabilities, driver logs, current URL, and page source. Reduce the test to one navigation and one action. In remote runs, verify Grid node health, network access, and requested capabilities.

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

Performance, reliability, and cost decisions

  • Use explicit waits with realistic, bounded timeouts rather than global long sleeps.
  • Reuse a session only when test isolation remains clear; otherwise create a fresh session per test.
  • Run headless browsers in CI when a visible display is unnecessary, but keep a headed reproduction path for visual debugging.
  • Parallelize through Grid only after tests are isolated and data collisions are controlled.
  • Cache dependencies in CI, but still verify browser-driver compatibility after browser updates.
  • Capture diagnostics on failure, not on every successful step, to limit storage and runtime overhead.

Selenium itself is software, but remote execution may add infrastructure, browser, and CI costs. The appropriate choice depends on whether you need local debugging, a controlled Grid, or a hosted browser service.

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

If your goal is a clean image or PDF rather than clicking through a workflow, ScreenshotNeo provides a single-call website screenshot API and MCP server. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status.

Use the API as documented at https://screenshotneo.com/docs/:

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

The same request 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 for Claude, Cursor, and other MCP clients, so an AI agent can call take_screenshot, get_page_info, or capture_pdf. Every plan includes its features; the free plan provides 1,000 screenshots per month with no card, and paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

FAQ

Do I need ChromeDriver separately?

Not necessarily. Selenium Manager in current Selenium releases can obtain a matching driver when one is not supplied. Manual installation remains an option for constrained environments or unsupported requirements.

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

Why does a page look loaded but my test still fail?

The load event does not guarantee that JavaScript-rendered controls or data are ready. Wait for the specific element or business state your next action requires.

Should I use Selenium for screenshots?

Use Selenium when you must perform browser interactions or verify a workflow. For a direct clean screenshot or PDF, a screenshot API can avoid maintaining browser and driver setup.

Frequently Asked Questions

Can Selenium automate more than one browser?

Yes. Select the appropriate browser binding and options, then run the same workflow locally or through Grid where the required browser is installed.

What is the difference between WebDriver and WebDriver BiDi?

WebDriver sends commands to control a browser. BiDi adds a bidirectional channel for receiving events such as network, console, and JavaScript-error notifications, subject to browser and implementation support.

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

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.