Selenium WebDriver in Eclipse | Java Setup Guide

Hello there! We are going to set up Selenium WebDriver in Eclipse, one of those crucial stepping stones when you are entering the world of browser automation. We are moving forward with our Selenium lessons. That means progress! First we need Java, an IDE and the Selenium Java library to agree on where everything lives.

The original lesson used Selenium 3.2, a manually added standalone-server JAR and Internet Explorer. Those screenshots are preserved below as history, not as the recommended installation today. For a new project, use the Selenium Java client through Maven and a current supported browser. This update checks the guidance against current documentation; it does not claim a fresh Windows/Eclipse installation or an end-to-end browser run.

South Park reaction meme from the original Selenium tutorial — Selenium WebDriver in Eclipse
South Park reaction meme from the original Selenium tutorial.

Selenium WebDriver in Eclipse: Before You Start

I hope you have Java installed already. If not, begin with our Java installation guide, then come back. Use a supported JDK that meets the requirements of both your Eclipse release and your chosen Selenium version. Installing a Java runtime alone is not the same as having a working development kit.

You also need Eclipse with Java development and Maven integration, a browser such as Chrome, and network access for dependency downloads. The version of Java that launches Eclipse and the JDK configured for a project can differ. Check both rather than assuming that a successful IDE launch proves the project is using the right compiler.

We gotta configure Selenium at once so that we know what WebDriver looks like in reality, right? Together we shall find out. The important distinction is that WebDriver is an API: your Java code calls its library, and a browser-specific driver carries out the instructions. Eclipse is the workspace in which you write and run that code.

Selenium WebDriver in Eclipse: Maven Setup

For a fresh setup, create a Maven project in Eclipse, or import an existing project that has a pom.xml. Eclipse’s Maven integration manages the project build path from that file. If the Maven project wizard is absent, check your Eclipse package and Maven integration before trying to repair imports by hand.

In the POM’s dependencies section, add org.seleniumhq.selenium:selenium-java and an explicit stable version from Selenium’s official installation guidance. Keep that version in source control so that another machine can resolve the same library. Do not paste a placeholder such as LATEST_VERSION and expect it to be a real release number.

The dependency coordinates are the group ID org.seleniumhq.selenium and artifact ID selenium-java. Use the current supported release shown in Selenium’s official library installation guide, which also documents alternatives to Maven. This is the one authoritative reference to use when the recommended version changes.

Save the POM, let dependency resolution complete, and use Eclipse’s Maven Update Project action if the build path has not refreshed. A Maven Dependencies node should contain the resolved libraries. Do not add a second set of manually downloaded Selenium JARs to the same project: mixed versions can make a small exercise surprisingly difficult to diagnose.

Historical Download Screens — Not the Current Install

The following three download pictures show the old Selenium 3 route. Keep them as a record of the original lesson, not as the current Java dependency instructions.

Previous Releases navigation on the old Selenium website
Previous Releases navigation on the old Selenium website. Historical screenshot; current menus and versions differ.
Release directory on the old Selenium website
Release directory on the old Selenium website. Historical screenshot; current menus and versions differ.
Selenium 3.2 standalone-server download example, not the current Java client — Selenium WebDriver in Eclipse
Selenium 3.2 standalone-server download example, not the current Java client. Historical screenshot; current menus and versions differ.

Your GameofThrones Project, Package and Class

All you gotta do now is give the project a structure. I named the original project GameofThrones for the heck of it, the package housestark and the class NedStark. You can keep the joke. A project name is not a Java package declaration, and neither one automatically chooses the class name for you.

Under the Java source folder, create the package, then create the class inside it. For the main-method example below, use the normal application source folder, such as src/main/java in a Maven project. Ask Eclipse to generate public static void main(String[] args) if you like, or enter it yourself. Chill! That is the beauty of Eclipse: it saves some typing, not the need to understand the result.

The following original screenshots illustrate those names and dialogs. They show a plain Java project, so do not mistake its source-folder layout for a required Maven layout. Follow the structure of the project you actually created.

Eclipse menu for creating a Java project
Eclipse menu for creating a Java project. Historical screenshot; current menus and versions differ.
GameofThrones project in the old wizard
GameofThrones project in the old wizard. Historical screenshot; current menus and versions differ.
Package creation from the Eclipse menu — Selenium WebDriver in Eclipse
Package creation from the Eclipse menu. Historical screenshot; current menus and versions differ.
housestark entered as the package name
housestark entered as the package name. Historical screenshot; current menus and versions differ.
Class creation from the Eclipse menu
Class creation from the Eclipse menu. Historical screenshot; current menus and versions differ.
NedStark class and main-method choices — Selenium WebDriver in Eclipse
NedStark class and main-method choices. Historical screenshot; current menus and versions differ.
Generated package declaration and Java main method
Generated package declaration and Java main method. Historical screenshot; current menus and versions differ.

Selenium WebDriver in Eclipse: First Script

How are we now? All good? If the imports resolve, put this example in NedStark.java under housestark. It uses Chrome consistently; the old lesson accidentally described both Internet Explorer and Firefox for one program. That confusion is gone. Run the class as a Java application, not the POM as if it were a Java source file.

package housestark;

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

public class NedStark {
    public static void main(String[] args) {
        WebDriver driver = new ChromeDriver();
        try {
            driver.get("https://www.selenium.dev/");
            System.out.println(driver.getTitle());
        } finally {
            driver.quit();
        }
    }
}

The program asks Chrome to open Selenium’s public site, prints the page title and ends the WebDriver session. It is a setup demonstration, not a complete test: printing a title is not an assertion that a business requirement passed. We will add purposeful checks when we have something worth testing.

Current Selenium bindings can invoke Selenium Manager to discover and obtain a suitable driver when none has been supplied. The first run may need network access, and a corporate proxy or download policy can affect it. Do not disable security software or fetch an executable from an unknown mirror to get past a failed download. Investigate the actual error and the approved network configuration instead.

The finally block matters. It asks Selenium to quit the entire session even if navigation or title retrieval fails after the driver has started. The original close() example only closed the current window; that is not the same cleanup promise. If driver creation itself fails, there is not yet a successful session for this block to close.

Manual JARs: What the Older Screenshots Mean

Now comes the tricky part. Not the loo, of course. That was the easiest! The old download screens above refer to Selenium 3’s standalone server. You do not need that server merely to run one local Java browser session. Selenium Server belongs to remote/Grid use; the Java client library belongs in this project.

If you deliberately choose a manual Java project rather than Maven, obtain the supported Java client distribution and include its required dependencies. A single random JAR is not a substitute for the whole dependency set. Use one consistent installation route. The old standalone filenames in these pictures are not instructions to download release 3.2.0 today.

Check your watch! Now is the right time to understand Build Path, not to chase an obsolete filename. Right-click the Java project and open Build Path, then Configure Build Path. The Libraries tab and Add External JARs action shown here explain the old workflow. Exact dialog placement and classpath/module-path choices depend on your current Eclipse project.

Configure Build Path in the older Eclipse interface
Configure Build Path in the older Eclipse interface. Historical screenshot; current menus and versions differ.
Libraries tab with the Add External JARs button — Selenium WebDriver in Eclipse
Libraries tab with the Add External JARs button. Historical screenshot; current menus and versions differ.
Old standalone JAR selection, not the current client distribution
Old standalone JAR selection, not the current client distribution. Historical screenshot; current menus and versions differ.
Old standalone server on the Eclipse build path
Old standalone server on the Eclipse build path. Historical screenshot; current menus and versions differ.
Referenced Libraries after the old setup — Selenium WebDriver in Eclipse
Referenced Libraries after the old setup. Historical screenshot; current menus and versions differ.

There will be plenty of referenced classes once the dependencies are present. Importing a class in Java tells the compiler which name you mean; it does not download that class. If the package is unresolved, fix the dependency or build path first. Adding another import line cannot create a missing library. :-O There is our promised surprised look!

Common Setup Problems and the Old IE Example

If org.openqa.selenium cannot be resolved, check that Maven completed successfully and that the source file belongs to the intended project. An unsupported Java version calls for correcting the project JDK and compiler configuration. For a session that cannot start, read the driver/browser error before assuming that Eclipse itself is broken.

The original Internet Explorer illustration is retained for readers recognising an older installation. It is not the browser choice for this new exercise, and its historical 32-bit recommendation should not be applied blindly to modern browsers or operating systems.

Historical Internet Explorer driver download, not recommended for this new setup
Historical Internet Explorer driver download, not recommended for this new setup. Historical screenshot; current menus and versions differ.

Ta-da! You have a clearer route to Selenium WebDriver in Eclipse: configure the JDK, add the Java client, create the package and class, then verify a small browser session. Do not confuse the server, client library and browser driver. They solve different problems, even if their names keep wandering into the same conversation.

For the next step, our Selenium introduction explains how WebDriver fits into a wider test setup. Take a vacation or something after that if you must — I know you have been knackered. Just keep the project and its POM together when you come back.

Scottshak

I’m an automation architect and the dude behind these guides. Away from the keyboard, I write poetry, books and screenplays, and love making films.

You may also like...

2 Responses

  1. August 11, 2017

    […] There are browser specific drivers entailed here that sends or retrieves commands from a browser. An example of which we saw in the “Installing Selenium Webdriver chapter“. […]

  2. October 30, 2026

    […] Chrome installed. This example uses Java 21 and Selenium Java 4.51.0. For setup help, follow our Selenium WebDriver in Eclipse guide before returning […]

Leave a Reply