Hero Background

Next-Gen App & Browser Testing Cloud

Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Next-Gen App & Browser Testing Cloud

How to Install Selenium WebDriver?

To install Selenium WebDriver, install a JDK and set JAVA_HOME if you are working in Java, add the Selenium library through your language's package manager (Maven or Gradle for Java, pip for Python, npm for JavaScript), and let Selenium Manager handle the browser driver. From Selenium 4.6 onward, the matching ChromeDriver, GeckoDriver, or EdgeDriver is downloaded automatically, so a manual driver download is usually unnecessary. Write a short first test, run it, and the browser launches.

Here is the install at a glance, with the rest of this guide expanding each step:

  • Install a JDK (for Java) and set the JAVA_HOME environment variable.
  • Add the Selenium library via Maven or Gradle (Java), pip (Python), or npm (JavaScript).
  • Let Selenium Manager auto-resolve the browser driver (Selenium 4.6+).
  • Write and run a first test, then verify the browser opens.

For a deeper community discussion, explore this thread on how to download and install Selenium WebDriver.

Prerequisites: Install the JDK and Set JAVA_HOME

If you plan to write tests in Java, the Java Development Kit (JDK) is the only prerequisite that needs explicit setup. Selenium 4 requires JDK 11 or higher; for a new project, install a Long Term Support release such as JDK 17 or JDK 21 from Adoptium (Temurin) or Oracle.

  • Download and install the JDK: pick an LTS build (17 or 21) for your operating system and run the installer.
  • Set JAVA_HOME: point it at the JDK install directory so build tools and IDEs can find the compiler.
  • Add the JDK to PATH: include %JAVA_HOME%\bin (Windows) or $JAVA_HOME/bin (macOS/Linux) so java and javac run from any terminal.
  • Verify the install: open a fresh terminal and confirm the version output.
java -version
javac -version
echo $JAVA_HOME

Prerequisites differ per language. Python only needs a Python 3 runtime and Node.js only needs Node installed; neither requires a JDK. Those quick installs are covered further down.

Install Selenium via Maven or Gradle (Recommended for Java)

The cleanest way to add Selenium to a Java project is through a build tool. A dependency manager beats manually downloading JARs because it resolves every transitive dependency for you, keeps versions consistent across the team, and lets you upgrade Selenium by changing a single line. Use one of the snippets below depending on your build tool.

Maven: add the selenium-java dependency inside the <dependencies> block of your pom.xml.

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-java</artifactId>
  <version>4.21.0</version>
</dependency>

Gradle: add Selenium as a testImplementation dependency in your build.gradle.

dependencies {
    testImplementation 'org.seleniumhq.selenium:selenium-java:4.21.0'
}

Manual alternative: you can still download the Java client JARs from selenium.dev and add them to your project's build path. If you prefer that click-by-click route in Eclipse, follow the dedicated walkthrough on How Do I Install Selenium and Set Up the Environment for Testing?, then come back here for driver and first-test details.

Set Up Your IDE (Eclipse or IntelliJ IDEA)

You can run Selenium from any editor, but an IDE such as IntelliJ IDEA or Eclipse gives you autocompletion, inline error checking, and an integrated test runner. The smoothest path is to create a Maven or Gradle project so the IDE pulls Selenium in automatically.

  • Create a new project: choose "Maven" or "Gradle" in the New Project wizard rather than a plain Java project.
  • Add the dependency: paste the Maven or Gradle snippet from above into the build file.
  • Let the IDE sync: the IDE downloads Selenium and its dependencies and indexes them, so imports such as org.openqa.selenium resolve immediately.

The screenshot-heavy "create a project and add external JARs" walkthrough lives in the sibling guide linked above, so this page keeps the IDE step brief and focuses on the modern, dependency-managed flow.

Browser Drivers and Selenium Manager (No Manual Download Needed)

Historically, Selenium needed a separate browser driver binary (ChromeDriver, GeckoDriver, or EdgeDriver) downloaded by hand and placed on the system PATH. That step is now automated.

  • Built into Selenium 4.6+: Selenium Manager ships inside the Selenium binding and runs by default, no extra install required.
  • Automatic resolution: it detects the browser you have installed, downloads the matching driver version, and caches it under ~/.cache/selenium so subsequent runs are instant.
  • Matured by 4.11 to 4.14: the feature stabilized across these releases, which is why most modern tutorials no longer mention manual driver setup at all.
  • When to still set a driver manually: air-gapped or offline machines, corporate proxies that block the download, or when you must pin an exact driver version. For that fallback, see How Do I Troubleshoot and Debug Selenium Tests?.

The practical takeaway: for most installations you can skip the ChromeDriver download entirely and let Selenium Manager do the work. The first-test snippets below rely on exactly this behavior.

Write and Run Your First Selenium Test (Java)

With the dependency in place, a minimal Java test confirms everything works. Notice there is no System.setProperty call for the driver path; Selenium Manager resolves ChromeDriver on the first run.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class FirstSeleniumTest {
    public static void main(String[] args) {
        // Selenium Manager (4.6+) auto-resolves ChromeDriver - no setProperty needed
        WebDriver driver = new ChromeDriver();
        driver.get("https://www.lambdatest.com/");
        System.out.println("Page title is: " + driver.getTitle());
        driver.quit();
    }
}

Run it from the IDE with the green run arrow, or from the terminal with mvn test if you wired it into a test framework. A Chrome window opens, the page title prints to the console, and the browser closes. Once this passes, you are ready to move on to How Do I Write and Run Test Scripts in Selenium?.

Quick Install for Python and JavaScript

Selenium is not a Java-only tool. The same WebDriver standard backs official bindings for Python, JavaScript, C#, and Ruby, and Selenium Manager works across all of them.

Python: with Python 3 installed, a single command adds the binding.

pip install selenium

A six-line script then launches a browser with no driver setup:

from selenium import webdriver

driver = webdriver.Chrome()  # Selenium Manager fetches the driver automatically
driver.get("https://www.lambdatest.com/")
print("Page title is:", driver.title)
driver.quit()

JavaScript / Node.js: with Node installed, add the package to your project.

npm install selenium-webdriver

Because Selenium Manager is binding-agnostic, the Python and Node installs behave the same way as Java: the matching driver is fetched on the first run, so there is nothing extra to configure.

Verify the Installation and Troubleshoot Common Errors

The definitive verification is simple: if your first test launches the browser and prints the page title, Selenium is installed correctly. You can double-check the resolved version with mvn dependency:tree for Java or pip show selenium for Python. If something fails, the issues below cover most cases.

  • JAVA_HOME not set or wrong: build tools fail to find the compiler. Re-point JAVA_HOME at the JDK directory, open a new terminal, and re-run java -version.
  • Driver and browser version mismatch: the classic "this version of ChromeDriver only supports Chrome version N" error. On Selenium 4.6+ this is handled by Selenium Manager; if you still pin a driver manually, update it to match your browser.
  • SessionNotCreatedException: usually a browser/driver incompatibility or a browser that is not installed where Selenium expects. Confirm the browser is present and let Selenium Manager re-resolve the driver.
  • Driver download blocked offline or by proxy: Selenium Manager cannot reach the network to fetch the driver. Pre-cache the driver, configure the proxy, or supply a local driver path for air-gapped machines.
  • PATH problems: if java, python, or node are not recognized, the runtime is missing from PATH. Add the relevant bin directory and reopen the terminal.

Run Selenium in the Cloud Without Local Setup

A local install is perfect for learning and for running a handful of tests, but maintaining a JDK, the right browser versions, and drivers on every machine and CI agent quickly becomes tedious. You can skip that maintenance by pointing a RemoteWebDriver at a cloud Selenium grid such as TestMu AI (Formerly LambdaTest), which offers 3,000+ browser and OS combinations on demand. The install on your side stays minimal, the browsers and drivers live in the cloud, and your tests run in parallel against the exact environments you need.

Frequently Asked Questions

Do I still need to download ChromeDriver for Selenium?

Usually not. Selenium Manager is built into Selenium 4.6 and later and runs by default. It detects your installed browser, downloads the matching driver, and caches it automatically, so a manual ChromeDriver or GeckoDriver download is no longer required for most setups. You only need to set a driver by hand in offline or air-gapped environments, or when you must pin a specific driver version.

How do I install Selenium in Python?

Install Python 3, then run pip install selenium. That single command pulls the Selenium binding and its dependencies. From version 4.6 onward, Selenium Manager resolves the browser driver for you, so a six-line script using webdriver.Chrome() will launch a browser with no extra driver setup.

What is the difference between Selenium and Selenium WebDriver?

Selenium is the umbrella project that includes WebDriver, Selenium Grid, and the Selenium IDE recorder. Selenium WebDriver is the specific component (and now a W3C standard) that drives a real browser programmatically through language bindings such as Java, Python, JavaScript, and C#. When people say they are installing Selenium for automation, they almost always mean installing the WebDriver binding.

Which Java version is required for Selenium 4?

Selenium 4 requires JDK 11 or higher. For new projects, install a current Long Term Support release such as JDK 17 or JDK 21 from Adoptium (Temurin) or Oracle, set JAVA_HOME, and confirm with java -version. LTS builds get the longest support window and avoid the churn of non-LTS releases.

Should I use Maven or download the Selenium JAR files manually?

Use a build tool such as Maven or Gradle. Declaring the selenium-java dependency lets the build tool resolve every transitive dependency, keep versions consistent, and upgrade with a single line. Manually downloading client JARs and adding them to the build path still works, but it is error-prone and harder to maintain across a team.

How do I verify that Selenium installed correctly?

Run a minimal test that opens a browser, loads a page, prints the title, and quits. If the browser launches and the title prints, the binding and driver are working. You can also inspect the dependency with mvn dependency:tree for Java or pip show selenium for Python to confirm the installed version.

Related Questions

Test Your Website on 3000+ Browsers

Get 100 minutes of automation test minutes FREE!!

Test Now...

KaneAI - Testing Assistant

World’s first AI-Native E2E testing agent.

...

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests