sodcalculator

10 Tech How-To

Selenium Manager: Set Up Browser Drivers Automatically

Guide 10-39556 · Updated · Step by step

Selenium Manager lets Selenium find, download, and cache a compatible browser driver when your test starts, so you usually do not need to install or point to a driver executable yourself. Install a current Selenium binding, create a WebDriver instance in your language, and let Manager handle driver setup; the browser itself must still be installed.

What You’ll Need

  • A supported language runtime and its Selenium binding, such as Selenium for Python, Java, JavaScript, C#, or Ruby.
  • A locally installed browser that your tests can launch, such as Chrome, Firefox, Edge, or Safari where supported.
  • Internet access the first time a needed driver must be downloaded. A working proxy or approved network route may be necessary on managed networks.
  • Permission for Selenium to create and use its cache directory, and permission for your environment to launch the browser and driver.

Step-by-Step

  1. Install or update Selenium. Use the package manager for your language and project, and ensure the Selenium version is current enough to include Selenium Manager. For example, in a Python virtual environment run python -m pip install -U selenium. In other languages, update the Selenium dependency using the project’s usual package tool. Check your installed version if you are unsure; older Selenium releases may not include Manager.
  2. Install the browser you intend to test. Selenium Manager can resolve a driver, but it does not install the browser. Install the browser normally and confirm it opens under the same user account that runs your tests. On a remote machine or container, make sure the browser is present in that environment, not only on your development computer.
  3. Create a normal WebDriver instance. Import the appropriate Selenium WebDriver class and instantiate it without a driver path. For Python, use from selenium import webdriver followed by driver = webdriver.Chrome(). For Firefox, use webdriver.Firefox(). In Java, use a standard constructor such as new ChromeDriver() after importing the relevant Selenium classes. Use the equivalent default constructor in your binding.
  4. Run a small test. Navigate to a page you are allowed to access, verify the browser starts, and then close it. For example, in Python call driver.get("https://example.com"), inspect the page title, and finish with driver.quit(). Put cleanup in a finally block or your test framework’s teardown so browser processes are closed even if an assertion fails.
  5. Allow Manager to resolve the driver. On startup, Selenium checks what browser and driver are needed. If a suitable driver is already available, it can use that; otherwise, Manager may look up and download a compatible driver, then store it in its cache for later runs. The first launch can take longer than subsequent launches. You generally do not need to call Selenium Manager directly.
  6. Remove conflicting driver configuration. If your code still specifies a driver executable path, or an environment variable such as SE_CHROMEDRIVER or SE_GECKODRIVER points to an old executable, remove or correct it when you want automatic resolution. Also check your system PATH for an obsolete driver that could interfere with an older setup or custom configuration.
  7. Check the startup logs if needed. Selenium Manager writes diagnostic information when it resolves a driver. Increase Selenium’s logging detail using the logging facilities for your language, then review the messages for browser detection, cache use, network access, or a download failure. Avoid publishing logs that contain private local paths or proxy details.
  8. Use explicit configuration only when needed. For a pinned or unusual setup, Selenium’s browser-specific options and service classes let you provide a driver executable or other settings. Use the APIs documented for your installed binding, and ensure the chosen driver matches the browser. Return to the default constructor when you want Manager to take over again.

Common Mistakes

  • Expecting Selenium Manager to install the browser. It handles driver resolution, not browser installation. Install the browser separately and make sure it is available to the test process.
  • Keeping an old explicit driver path. Code that sets a service executable path bypasses automatic discovery. Remove the path if you intend to rely on Manager.
  • Using a stale Selenium package. If Manager appears unavailable, update the language binding in the same environment that runs the test. Updating a global installation does not update a project virtual environment or build environment.
  • Assuming the first launch is broken because it is slow. Driver lookup and download can add time on the initial run. Check logs and network access before changing versions or adding a manual driver.
  • Mixing local and remote execution. A driver resolved on your laptop does not automatically become available in a container, CI runner, or Selenium Grid node. Set up Selenium and the browser in the environment that actually launches the browser.
  • Sharing an unmanaged cache between users. Cache permissions or concurrent access can cause failures. Use a cache location writable by the test account, and avoid changing cache files while tests are running.

Tips

  • Keep Selenium dependencies locked or recorded in your project so teammates and CI use a predictable binding version.
  • Run a small browser-start test after changing Selenium, browser, operating system, proxy, or CI image settings.
  • For repeat runs, allow the cache to persist when practical. In temporary CI environments, expect a fresh lookup and download unless the environment provides an appropriate cache.
  • Behind a corporate proxy, configure network access according to your organization’s approved proxy settings. Do not put credentials in source code or publicly shared logs.
  • Use explicit driver management only when you need reproducible pinning, offline installation, or control over a nonstandard executable location. Document the browser and driver versions together.
  • Call quit() rather than only closing a tab; it ends the WebDriver session and normally shuts down its browser process.

Troubleshooting

If the browser does not start, first confirm the browser is installed and can open under the same account as the test. Then update Selenium in the active environment and try a minimal script with no custom driver path or browser options. Read the complete startup error and Selenium Manager logs rather than assuming every failure is a version mismatch.

If the error points to a network or download problem, check whether the machine can reach the required driver-distribution service and whether a proxy, firewall, or TLS inspection rule blocks it. Ask the network administrator about the approved configuration. If the machine must work offline, prepare a compatible driver through your organization’s established process and configure its path explicitly; automatic first-time downloads cannot succeed without access to the required files.

If the message indicates an incompatible driver, check which browser binary is being detected, whether multiple browser installations are present, and whether a driver path or environment variable is overriding Manager. Remove stale overrides, update the browser and Selenium as appropriate, and retry. If a cached resolution seems damaged, stop running tests and use Selenium’s documented cache controls for your installed release rather than deleting files while a session is active.

For permission errors, verify the test user can execute the browser and write to the Selenium cache location. In containers, check user permissions and include the browser and required runtime dependencies in the image. If local tests work but CI fails, compare the CI operating system, browser installation, network rules, and environment variables with the local setup.

Frequently Asked Questions

Do I need to download ChromeDriver or GeckoDriver manually?
Usually not. With a current Selenium binding and a supported local browser, Selenium Manager can resolve and download a suitable driver automatically.

Does Selenium Manager install Chrome or Firefox?
No. Install the browser separately. Manager is for locating or obtaining the driver Selenium uses to communicate with it.

Does it work without an internet connection?
It can use a suitable driver already available to the setup, but it cannot download a missing driver while offline. Prepare and configure a compatible driver if the machine has no network access.

Where does Selenium Manager keep downloaded drivers?
It uses a local cache, whose location and behavior can depend on the operating system and Selenium release. Check the Manager logs and documentation for your installed version.

Can I still choose a specific driver version?
Yes. You can configure a driver executable or use the version-specific options supported by your Selenium binding. Confirm that the driver is compatible with the browser you are launching.

Why does setup work locally but fail in CI?
CI may lack the browser, network access, cache permissions, or the same Selenium version as your computer. Check those items in the runner environment and inspect its startup logs.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →