How to Install and Configure Eclipse for Selenium Testing

How to Install and Configure Eclipse for Selenium Testing

✅ Step 1: Install Java Development Kit (JDK)

1. Download JDK

Go to the Oracle JDK download page or use OpenJDK.


Choose your operating system and download the latest JDK version.


2. Install JDK

Run the installer and follow the setup instructions.


After installation, set the JAVA_HOME environment variable (especially for Windows):


bash

Copy

Edit

JAVA_HOME = C:\Program Files\Java\jdk-XX

✅ Step 2: Install Eclipse IDE

1. Download Eclipse

Go to the Eclipse Downloads page.


Choose Eclipse IDE for Java Developers.


2. Install Eclipse

Run the installer and choose a directory to install Eclipse.


Launch Eclipse after installation.


✅ Step 3: Set Up a Java Project in Eclipse

1. Open Eclipse

Choose a workspace directory.


Go to File > New > Java Project.


2. Create a Project

Name your project (e.g., SeleniumTestProject).


Click Finish.


✅ Step 4: Add Selenium WebDriver to Eclipse

1. Download Selenium

Go to the Selenium official website.


Under “Selenium Client & WebDriver Language Bindings,” download the Java version.


2. Add Selenium JARs to Project

Unzip the Selenium zip file.


In Eclipse:


Right-click the project > Build Path > Configure Build Path.


Go to the Libraries tab > Add External JARs.


Select all .jar files inside the main folder and libs subfolder.


✅ Step 5: Create a Test Class

Example Code:

java

Copy

Edit

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;


public class TestGoogle {

    public static void main(String[] args) {

        // Set the path to the ChromeDriver

        System.setProperty("webdriver.chrome.driver", "path/to/chromedriver");


        // Create a WebDriver instance

        WebDriver driver = new ChromeDriver();


        // Open Google

        driver.get("https://www.google.com");


        // Print the page title

        System.out.println("Page Title: " + driver.getTitle());


        // Close browser

        driver.quit();

    }

}

Notes:

Replace "path/to/chromedriver" with the actual path to your downloaded ChromeDriver.


You can download ChromeDriver from: https://chromedriver.chromium.org/downloads


✅ Step 6: Run the Test

Right-click the file > Run As > Java Application.


Chrome should launch and open Google, then close.


Optional: Use Maven for Dependency Management

Instead of adding JARs manually:


Create a Maven project.


Add Selenium dependency to pom.xml:


xml

Copy

Edit

<dependencies>

    <dependency>

        <groupId>org.seleniumhq.selenium</groupId>

        <artifactId>selenium-java</artifactId>

        <version>4.20.0</version> <!-- Replace with latest -->

    </dependency>

</dependencies>

Would you like help with setting up Maven or using other browsers like Firefox or Edge?

Learn Selenium JAVA Course in Hyderabad

Read More


Visit Our IHUB Talent Training in Hyderabad

Get Directions


Comments

Popular posts from this blog

How to Install and Set Up Selenium in Python (Step-by-Step)

Feeling Stuck in Manual Testing? Here’s Why You Should Learn Automation Testing

A Beginner's Guide to ETL Testing: What You Need to Know