Setting Up Eclipse/IntelliJ for Selenium Projects (Java)

Setting Up Eclipse/IntelliJ for Selenium Projects (Java)

If you’re starting with Selenium automation in Java, one of the first things you need is a proper IDE setup.

This guide shows you how to set up Selenium in Eclipse and IntelliJ IDEA, step by step.


🧑‍💻 Prerequisites

Before you begin, make sure you have:

  • Java JDK installed (Java 8 or above)

  • Eclipse IDE or IntelliJ IDEA installed

  • Chrome Browser

  • ChromeDriver downloaded (must match your Chrome version)

💡 Download ChromeDriver


🟡 Part 1: Setting Up Selenium in Eclipse

✅ Step 1: Create a New Java Project

  1. Open Eclipse

  2. Go to File > New > Java Project

  3. Enter project name (e.g., SeleniumDemo)

  4. Click Finish


✅ Step 2: Create a Package and Class

  1. Right-click src > New > Package (e.g., automation)

  2. Inside the package, create a Java class (e.g., LoginTest)

  3. Add main method:


public class LoginTest { public static void main(String[] args) { System.out.println("Selenium Test"); } }

✅ Step 3: Add Selenium JARs

  1. Download Selenium JARs from: https://www.selenium.dev/downloads/

  2. Extract the .zip file

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

  4. Go to Libraries > Add External JARs

  5. Add:

    • selenium-java-x.x.x.jar

    • All JARs inside the libs folder

Click Apply and Close


✅ Step 4: Add ChromeDriver to Your System Path

  • Extract chromedriver.exe

  • Place it in your project folder or any known path

  • Set system property in code:


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

✅ Step 5: Sample Selenium Code

import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class LoginTest { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\\drivers\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("https://www.google.com"); System.out.println("Title: " + driver.getTitle()); driver.quit(); } }

🔵 Part 2: Setting Up Selenium in IntelliJ IDEA

✅ Step 1: Create a New Project

  1. Open IntelliJ

  2. Select New Project > Java

  3. Set project name and location

  4. Select JDK and click Finish


✅ Step 2: Add Selenium Libraries

  1. Download Selenium Java JARs

  2. Right-click on project > Open Module Settings (F4)

  3. Go to Libraries > + > Java

  4. Select:

    • selenium-java-x.x.x.jar

    • All JARs in the libs folder

Click Apply and OK


✅ Step 3: Create Java Class

  1. Right-click src > New > Java Class

  2. Name it (e.g., LoginTest)

  3. Add main method and Selenium code


✅ Step 4: Add ChromeDriver Path

Same as Eclipse — add this in your code:

System.setProperty("webdriver.chrome.driver", "C:\\drivers\\chromedriver.exe");

✅ Step 5: Run the Code

Click the Run button or right-click > Run 'LoginTest'

You should see Chrome open and navigate to Google.


🧾 Final Thoughts

Whether you're using Eclipse or IntelliJ, the setup process is simple:

StepEclipseIntelliJ
Create projectJava ProjectJava Project
Add JARsExternal JARs in Build PathAdd Library in Module Settings
Create classJava class in packageJava class in src
Run testMain methodMain method

Next Steps:

  • Learn element locators (ID, name, XPath)

  • Automate real-world test cases

  • Integrate with TestNG or JUnit







Comments

Popular posts from this blog

Tosca System Requirements and Installation Guide (Step-by-Step)

How to Install Selenium for Python Step-by-Step

Tosca Commander: A Beginner’s Overview