Selenium Environment Setup
Selenium needs three pieces working together: a programming language, an IDE, and browser drivers. This topic walks through each piece using Java with Eclipse as the common beginner setup.
Diagram: Setup Building Blocks
[Java JDK] ---> runs your code
|
v
[Eclipse IDE] ---> where you write code
|
v
[Selenium JAR files] ---> gives you Selenium commands
|
v
[Browser Driver] ---> connects code to browser
|
v
[Chrome/Firefox Browser] ---> where tests run
Step 1: Install Java
Download the Java Development Kit from the official Oracle site. Install it and set the JAVA_HOME environment variable so your system finds Java commands. Verify the installation by typing java -version in a terminal.
Step 2: Install An IDE
Eclipse and IntelliJ are the two popular choices for Java-based Selenium projects. Download Eclipse IDE for Java Developers from the official website. Extract the files and launch the application. Create a new Java project inside Eclipse to hold your test scripts.
Step 3: Add Selenium Library
Download the Selenium Java client from the official Selenium website. Extract the ZIP file and add every JAR file to your Eclipse project build path. Right-click your project, choose Build Path, then Configure Build Path, and add the external JARs.
Step 4: Set Up A Browser Driver
Each browser needs a matching driver executable. Chrome needs chromedriver, and Firefox needs geckodriver. Download the driver version that matches your installed browser version. Place the driver file in a known folder and note its full path.
Modern Approach: Selenium Manager
Selenium versions from 4.6 onward include Selenium Manager, a built-in tool that downloads the correct driver automatically. Newer projects skip manual driver downloads entirely because of this feature.
Step 5: Write A Test Setup Check
Create a small script that opens a browser and prints the page title. A successful run confirms every piece connects correctly.
WebDriver driver = new ChromeDriver();
driver.get("https://www.example.com");
System.out.println(driver.getTitle());
driver.quit();
Common Setup Mistakes
- Using a driver version that does not match the installed browser version causes immediate failures.
- Forgetting to add Selenium JAR files to the build path stops the code from compiling.
- Skipping the driver.quit() line leaves browser processes running in the background.
