Installing Selenium and Browser Drivers
Getting a Selenium test running requires two separate installs: the Selenium client library for your programming language, and a driver executable matching the browser you want to automate. Beginners often install the library and stop there, then hit a confusing 'unable to find driver' or 'SessionNotCreatedException' the moment they try to launch a browser, because the two pieces are installed and versioned independently.
Cricket analogy: Needing both the library and the driver is like a bowler needing both a valid ball and the umpire's clearance to start an over — having just one without the other means play simply cannot begin.
Installing the Selenium Library
In Python, installing Selenium is a single command: pip install selenium. In a Java Maven project, you add the org.seleniumhq.selenium:selenium-java dependency to your pom.xml; in a JavaScript/Node project, npm install selenium-webdriver. As of Selenium 4.6, no separate driver download step is strictly required for the major browsers, because the library ships with Selenium Manager, which detects your installed browser and fetches a matching driver automatically the first time you run a test.
Cricket analogy: A single pip install command setting everything up is like a franchise's kit sponsor delivering the entire team's gear in one shipment rather than each player individually sourcing their own bat, pads, and gloves.
Getting the Right Browser Driver
Before Selenium 4.6, you had to manually download the correct driver binary for your OS and browser version from each vendor's site (ChromeDriver from Chrome for Testing, geckodriver from Mozilla's GitHub releases) and either place it on your system PATH or point to it explicitly with something like Service(executable_path='./chromedriver'). Selenium Manager removed most of that friction: it ships inside the Selenium library itself, checks your installed browser's version, downloads a matching driver into a local cache directory if one isn't already there, and wires it up transparently before your test even starts.
Cricket analogy: Selenium Manager auto-fetching the right driver version is like a groundskeeper automatically preparing the correct pitch length and bounce for whichever format — Test, ODI, or T20 — is scheduled that day, without the captain having to specify it.
pip install selenium
python -c "
from selenium import webdriver
driver = webdriver.Chrome() # Selenium Manager resolves the matching ChromeDriver automatically
print(driver.capabilities['browserVersion'])
driver.quit()
"Selenium Manager caches downloaded drivers under a local directory (~/.cache/selenium on Linux/macOS, %LOCALAPPDATA%\selenium on Windows), so subsequent test runs reuse the cached driver instead of re-downloading it every time.
Putting the Driver on PATH
If you do install a driver manually — common in CI environments where you want a pinned, reproducible driver version rather than whatever Selenium Manager resolves at runtime — the executable must either live in a directory listed in your system's PATH environment variable, or you pass its exact location to the Service object in your test code. A driver that exists on disk but isn't discoverable through either mechanism produces the same 'unable to locate executable' error as if it were never installed at all.
Cricket analogy: A driver that's downloaded but not on PATH is like a substitute fielder standing in the dugout instead of registered on the official team sheet — physically present, but the umpire's system doesn't recognize them as eligible to take the field.
On macOS, a manually downloaded driver binary is often blocked by Gatekeeper with an 'unidentified developer' warning the first time it runs. You typically need to clear this via System Settings > Privacy & Security, or run xattr -d com.apple.quarantine ./chromedriver, before Selenium can execute it.
- Installing Selenium requires both the client library (pip/npm/Maven) and a browser driver — they are separate pieces.
- Since Selenium 4.6, Selenium Manager automatically detects your browser and downloads a matching driver.
- Selenium Manager caches drivers locally so repeat runs don't re-download them.
- Manual driver installs remain common in CI for pinning a reproducible driver version.
- A driver must be on PATH or explicitly referenced via a Service object to be discoverable.
- macOS Gatekeeper can block a manually downloaded driver until quarantine is cleared.
Practice what you learned
1. What two separate things must be installed to run a Selenium test?
2. What does Selenium Manager do, introduced in Selenium 4.6?
3. Why might a CI pipeline still manually pin a specific driver version instead of relying on Selenium Manager?
4. What happens if a driver executable is on disk but not on the system PATH or referenced by a Service object?
5. What macOS-specific issue can block a manually downloaded driver from running?
Was this page helpful?
You May Also Like
What Is Selenium?
An introduction to Selenium, the open-source framework for automating web browsers, and why it's the backbone of web UI test automation.
Selenium WebDriver Architecture
How Selenium WebDriver's client-server architecture routes commands from your test script to the browser using the W3C protocol.
Your First Selenium Script
A hands-on walkthrough of writing, running, and understanding a first Selenium WebDriver script in Python.