October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

How to Use Desired Capabilities in Selenium 4

Selenium 4 uses browser-specific Options classes to configure WebDriver sessions. Learn the current Python remote pattern, W3C capability names, page-load trade-offs, and common fixes.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In Selenium 4, set capabilities with the browser’s Options class and pass that object to the driver. The old DesiredCapabilities-centered approach belongs to Selenium 3-era examples; for new local or remote sessions, use ChromeOptions, FirefoxOptions, or the matching browser options class. Selenium’s documentation states: “As of Selenium 4, you must use the browser options classes.” (Selenium Browser Options)

What capabilities do in Selenium

Capabilities describe the browser and configuration requested when a WebDriver session starts. For a local session, the browser-specific Options object carries those settings to the driver. For a remote session, the server uses the request to find a browser configuration it can provide. A requested feature that the remote end cannot provide can cause session creation to fail.

As an Amazon Associate I earn from qualifying purchases.

In Selenium 4, options are the supported way to configure a session. Selenium 3 examples often built a DesiredCapabilities object and supplied it separately; when updating that code, move the settings to the matching Options object instead of carrying the old pattern forward. See Selenium’s Selenium 4 upgrade guide.

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.

Set capabilities for a remote session in Python

This example requests Firefox with a particular browser version and operating-system platform. Replace the endpoint and requested values with ones your Grid actually supports; the example has not been run against a real Grid.

  1. Install Selenium in the Python environment used for the test: python -m pip install selenium.

  2. Set the requested values on Firefox’s Options object.

  3. Pass that object to webdriver.Remote along with the Grid’s command-executor URL.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options()
options.set_capability("platformName", "windows")
options.browser_version = "142"

driver = webdriver.Remote(
    command_executor="http://grid.example:4444/wd/hub",
    options=options,
)

try:
    driver.get("https://example.com")
    print(driver.title)
finally:
    driver.quit()

grid.example:4444/wd/hub is an example endpoint, not a public Selenium service. The browser version and platform also need to match configurations available on your Grid. Selenium’s Python API documents the Options-based remote pattern here: Python Desired Capabilities API, Selenium 4.49.0.

Set a capability locally

The same principle applies to a local driver: create the browser’s Options instance, set the desired values, and pass it to that browser’s driver constructor. For example, use webdriver.Chrome(options=options) with a ChromeOptions instance. Do not pass a standalone legacy DesiredCapabilities object as the Selenium 4 setup pattern.

Use current W3C capability names

Selenium 4 follows the W3C WebDriver standard. Common standard capability names include:

Capability What it requests or configures
browserName The browser type, such as Firefox or Chrome.
browserVersion The requested browser version.
platformName The operating-system platform.
acceptInsecureCerts Whether the session should accept insecure certificates.
pageLoadStrategy When navigation is considered complete for WebDriver.
proxy Proxy configuration.
timeouts Session timeout settings.
unhandledPromptBehavior How the session handles unexpected user prompts.

Use browserVersion and platformName, not the older version and platform names. The Selenium upgrade guide explains these W3C naming changes and capability migration: Upgrade to Selenium 4.

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

Configure browser-specific and provider-specific options

Use the browser Options class for standard values and browser-specific settings supported by that class. Remote Grid and cloud providers may also accept extension capabilities, but those are not interchangeable across vendors. Selenium’s migration example places a provider’s build and name fields inside a vendor namespace such as cloud:options; check your provider’s current documentation for the exact prefix, nesting, and supported values.

A non-standard field in the wrong namespace or structure can make the remote server reject session creation. Do not assume that a setting accepted by one cloud provider will work unchanged on another.

Choose a page-load strategy deliberately

The page-load strategy changes when WebDriver returns from navigation; it does not guarantee that a JavaScript-heavy application has finished its later, dynamic work. Selenium documents these three strategies:

Strategy When navigation returns Trade-off
normal After the document reaches ready state complete and resources have downloaded. Waits for more of the page’s initial resource loading, which can take longer.
eager When the document reaches ready state interactive. The DOM is ready, but resources such as images may still be loading.
none WebDriver does not block on page loading. Returns control sooner, but the page may not yet be ready for the next test action.

normal is the default. eager or none can be useful when waiting on nonessential assets dominates navigation, but these settings apply to the whole session. Keep explicit waits for the specific element or application state your test needs; navigation returning is not a substitute for waiting on dynamic content. See Selenium Browser Options.

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

Troubleshoot capability and session errors

For remote capability matching, the WebDriver model distinguishes required features from alternatives: alwaysMatch expresses requirements that must be satisfied, while firstMatch lists alternatives considered in order. See MDN’s WebDriver capabilities reference.

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

Or skip the browser setup

If the task is to capture a website screenshot rather than run browser interactions or assertions, ScreenshotNeo is a screenshot API and MCP server for developers. It is not a Selenium replacement for automating a test. One GET request returns an image or PDF, without setting up a WebDriver session:

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)

See the ScreenshotNeo API documentation for request options. Before capture, it accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

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

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

Frequently Asked Questions

What does alwaysMatch mean in a WebDriver capabilities request?

It contains required features; if the remote end cannot provide them, session creation fails.

Can I use Selenium page-load strategy to know when a single-page app has finished loading?

No. It controls when navigation returns, not when the application’s later dynamic work is complete.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.