ScreenshotNeo

BlogGuides

A Guide to Selenium and Open-Source Test Automation

Learn what Selenium does, how WebDriver, IDE, and Grid differ, and how to set up browser automation with reliable tests.

By the ScreenshotNeo team4 October 202610 min read

Selenium is an open-source project for automating web browsers. It is a family of tools and libraries, not a complete test framework or a single testing application. For coded browser tests, start with Selenium WebDriver and a language binding; use Selenium IDE to record and replay a flow; add Selenium Grid when you need to run WebDriver sessions remotely across browsers or machines.

A practical starting path is to install a Selenium language binding, make a browser available, and write a small WebDriver script using stable locators, explicit waits, and assertions. Selenium Manager handles driver and browser management by default for Selenium bindings, which can reduce manual setup. It does not decide what your tests should assert or replace your test runner.

What is Selenium?

Selenium is an umbrella project for browser automation. Its components address different jobs: WebDriver provides programmable browser control, IDE records and replays browser actions, and Grid routes WebDriver sessions to remote browser instances. The Selenium project describes its focus simply: “Selenium automates browsers. That’s it!” The project documents WebDriver as a W3C Recommendation. Selenium project documentation

Browser automation can support regression tests, smoke tests, bug reproduction, and exploratory testing. Selenium itself does not supply your application’s test design, assertions, test data strategy, or continuous integration system. Those remain choices for your team.

WebDriver, Selenium IDE, and Grid: what is the difference?

Component Best for How it works Trade-off
WebDriver Coded browser automation and regression suites Your code calls a language binding, which controls a browser through its driver implementation. Flexible and maintainable when designed well, but tests need careful locators, waits, assertions, and upkeep.
Selenium IDE Quick bug reproductions and automation-aided exploration A browser extension records actions and can replay them. Useful for a quick start, but recorded flows are not automatically durable regression tests.
Selenium Grid Remote sessions across browsers, versions, operating systems, or machines Routes WebDriver requests to browser instances, and can distribute test execution. Adds deployment, network, capacity, and security responsibilities.

The Selenium project recommends WebDriver for robust browser-based regression suites, IDE for quick reproduction or exploratory work, and Grid for distributing tests across environments. Selenium project overview

Is Selenium still used for test automation?

Yes. Selenium remains a browser automation project with language bindings, browser drivers, IDE, and Grid. Whether it suits a particular team depends on its languages, browsers, infrastructure, and test needs. The most useful distinction is between the browser control layer and the rest of a testing setup: WebDriver automates the browser, while a test framework, assertions, test data, and CI workflow are selected and designed separately.

How to install Selenium and run a first WebDriver script

The following Python example opens a page, checks its title, and closes the browser. It uses Selenium’s Python binding. Install a supported browser and Python first; Selenium Manager is used by bindings by default to manage drivers and browsers. Setup details can vary with the browser and environment. Selenium getting started

1. Install the binding

python -m pip install selenium

2. Save and run a small script

# save as selenium_smoke.py
from selenium import webdriver

options = webdriver.ChromeOptions()
# Uncomment to run Chrome without opening a visible window:
# options.add_argument("--headless=new")

driver = webdriver.Chrome(options=options)
try:
    driver.get("https://example.com")
    assert "Example Domain" in driver.title
    print(f"Title: {driver.title}")
finally:
    driver.quit()
python selenium_smoke.py

The script creates a browser session, navigates to a URL, checks a simple condition, and closes the session even if an assertion fails. For a real project, put assertions in your chosen test framework, isolate test data, and use meaningful checks of application behavior rather than relying only on page titles.

3. Choose a binding for your project

Selenium supports language bindings including Python, Java, JavaScript, Ruby, and C#. Pick the binding that fits your team’s existing codebase and test runner. The same principles apply across bindings: use stable locators, wait for the state you need, assert observable behavior, and always close the session.

Writing browser tests that are dependable

Use locators that describe the element reliably

Prefer application-provided IDs or stable attributes intended for testing. Text and CSS selectors can also work when the application keeps them stable. Avoid selectors that depend on incidental layout or generated class names. If a locator matches multiple elements, make it specific enough to identify the intended target.

Wait for a condition, not an arbitrary pause

Pages load asynchronously. A fixed sleep can be too short on a slow run and waste time on a fast one. Use an explicit wait for the relevant condition, such as an element becoming visible or clickable, then interact with it. Avoid mixing implicit and explicit waits without understanding the resulting timeout behavior. For dynamic pages, wait for the state the test actually needs rather than assuming navigation completion means the page is ready.

Make tests independent

Each test should establish its own preconditions and leave data in a known state. Tests that depend on execution order or share mutable accounts can fail intermittently and are difficult to parallelize safely. Use unique or resettable test data, and clean up where the application permits.

Assert outcomes that matter

A test should verify a user-visible or otherwise meaningful result, not only that a click did not raise an error. Assert the expected confirmation, state change, or navigation. When an assertion fails, report enough context to diagnose the issue, such as the target URL and the expected state.

How do I run Selenium tests across multiple browsers?

Start by running the same focused test against each browser you intend to support. You can select a browser through the relevant binding’s browser options and driver support. Keep browser-specific setup isolated, and avoid assuming that timing, rendering, or browser behavior is identical. Confirm that the browser versions and operating systems in your test matrix match the environments that matter to your users.

For a small suite, local runs may be enough. If you need remote execution or multiple environments, Selenium Grid can route WebDriver scripts to browser instances. Grid supports parallel execution and coverage across browsers, versions, and operating systems. Parallelism only helps when tests are independent and the Grid has capacity to serve the requested sessions. Selenium Grid documentation

Do I need Selenium Grid?

Usually, not to get started. First make a representative set of WebDriver tests reliable on a local browser. Consider Grid when local execution cannot meet your browser coverage, remote environment, or runtime needs.

  • Stay local while building the first tests or debugging browser interactions.
  • Use a standalone Grid to try Grid or run its components in one process on one machine.
  • Use Hub/Node or Distributed deployments when you need components or browser capacity across multiple machines.

The Grid quick start calls for Java 11 or higher, installed browsers, and the Selenium Server JAR. Standalone mode listens for RemoteWebDriver requests on localhost:4444 by default. Selenium Manager can configure drivers when enabled. Grid deployment exposes a network service: follow the project security guidance and restrict access. An exposed Grid can let third parties reach internal web applications and files or run custom binaries. Grid quick start and security guidance

Start a local standalone Grid

After installing Java 11 or higher, downloading the Selenium Server JAR, and ensuring a browser is installed, start standalone mode:

java -jar selenium-server-<version>.jar standalone

Use the Selenium Downloads page to obtain the server JAR and check the current version. Keep the Grid bound to a trusted environment and firewall or otherwise restrict access according to your deployment. Do not expose it publicly without appropriate access controls.

Capture a screenshot of a Selenium browser session

WebDriver can save a screenshot from the browser session it controls. This is useful for debugging failures or keeping a visual artifact. The screenshot reflects the current browser state; the code below saves the current viewport as a PNG.

from selenium import webdriver

with webdriver.Chrome() as driver:
    driver.get("https://example.com")
    driver.save_screenshot("page.png")

For failure diagnostics, capture before quitting the driver and use a distinct filename per test or run. A browser screenshot is not automatically a full-page capture, and a screenshot does not explain why a test failed; pair it with logs, assertions, and relevant page state.

Or skip the browser setup

If your task is to capture a website image or PDF rather than test interactive behavior, a screenshot API can avoid managing a browser session yourself. ScreenshotNeo takes a URL in one GET request and returns PNG, JPEG, WebP, or PDF. It is a website screenshot API and MCP server for developers, made by Yorker Media.

For the full API options, see the ScreenshotNeo documentation.

cURL

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

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)

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 removes cookie and consent banners, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for 1,000 free screenshots a month, with no card required.

Performance, reliability, and cost considerations

Performance

  • Keep the first browser suite small and focused; add broader coverage based on the risks and browsers you support.
  • Use condition-based waits to avoid both needless sleeps and premature interactions.
  • Parallelize only independent tests, and size Grid capacity to the number of simultaneous browser sessions you need.
  • Use remote Grid when its environment coverage or parallel execution is worth the additional deployment and operations work.

Reliability

  • Pin and review dependency versions as part of normal project maintenance; verify supported browser and binding combinations when upgrading.
  • Make browser cleanup unconditional, as in the finally block or context manager above.
  • Separate product failures from environment failures by collecting useful logs and capturing browser state on failure.
  • Protect Grid network access. Treat it as infrastructure capable of reaching the environments available to its browser sessions.

Cost

Selenium is open source, but browser automation still consumes developer time and compute. Local runs use your machines; Grid adds the cost of operating and securing its server and browser nodes. The appropriate setup is the smallest one that meets your test coverage and runtime needs. If the objective is a website screenshot rather than a browser test, ScreenshotNeo offers 1,000 free shots each month and paid plans from $5 for 3,000; all features are available on every plan, and yearly billing gives two months free.

Troubleshooting common Selenium problems

Symptom Likely cause What to do
Browser or driver cannot be found Browser is missing, unsupported, or driver setup cannot complete. Install the browser, update the Selenium binding, check network and environment constraints for Selenium Manager, and consult the official setup guidance. Confirm that the browser is available to the process running the script.
Session creation fails Browser and driver compatibility, browser startup, or environment configuration issue. Read the full driver error, verify the installed browser and binding versions, and try a minimal script before debugging the full suite.
Element cannot be found Wrong locator, page not ready, element in a frame, or content not yet rendered. Check the current URL and DOM, wait for the element condition, and switch into the correct frame when applicable. Revisit selectors tied to unstable markup.
Element is not clickable or interactable Element is hidden, covered, disabled, off-screen, or the page is still changing. Wait for visibility or clickability, verify the intended element and page state, and handle overlays or scrolling based on the actual UI.
Tests fail intermittently Timing assumptions, shared test data, order dependence, or environmental variation. Replace fixed sleeps with explicit conditions, isolate data, remove order dependencies, and record enough state to identify the failure.
Remote session cannot connect Grid is not running at the configured address, the port is unreachable, or a node cannot provide the requested browser. Check Grid status and network reachability, confirm the RemoteWebDriver URL and requested capabilities, and verify node browser availability.
Grid works locally but is unsafe or unreachable from a worker Network binding or access controls do not match the intended deployment. Keep Grid on a trusted network, restrict inbound access, and follow the deployment security guidance. Do not expose an unprotected Grid to the internet.

Which Selenium component should you choose?

  1. Choose WebDriver if you need coded, repeatable browser tests that fit your team’s language and test runner.
  2. Choose Selenium IDE to quickly record a reproduction or explore a flow; promote important behavior into maintained tests where appropriate.
  3. Add Grid when local runs are insufficient for remote execution or browser and environment coverage, and you can operate it securely.
  4. Before scaling, make tests independent, use stable locators and explicit waits, and collect failure evidence.

Which Selenium version should I install?

The research snapshot lists Selenium 4.49.0 as stable for Java, Python, JavaScript, Ruby, C#, and Selenium Server, released September 9, 2026. Releases and browser compatibility can change; check the official Selenium Downloads page before installing and select the current release appropriate to your binding.

FAQ

Does Selenium include a test runner?

Selenium provides browser automation tools and libraries. Select a test framework and runner that fit your language and project.

Can Selenium IDE replace WebDriver?

IDE is useful for quick recording and replay. For robust, maintainable coded regression suites, the Selenium project points users to WebDriver.

Does Selenium Manager mean I do not need a browser?

No. Selenium Manager can manage drivers and browsers for bindings, but you still need a language binding and a browser available in your environment.

Can I use Selenium Grid for one machine?

Yes. Standalone mode runs Grid components in one process on one machine. It is also a starting point for learning remote WebDriver sessions.

Is a browser screenshot the same as a website screenshot service?

A WebDriver screenshot comes from a browser session your code controls. A screenshot API accepts a URL and returns an image or PDF without requiring you to write and manage that browser session.