Installing Java Selenium on Intellij (Windows, JUnit)

Installing Java Selenium on Intellij (Windows, JUnit)

1. Downloading and Setting up Java Development Kit

If you already have java setup on your PC as a system variable and do not wish to update it, skip to the next section:

As this guide is going to use Java as its target language, you will first need to set up Java on your PC. For the rest of the guide we will refer to the development kit as JDK.

First, click here to download the latest version of JDK. You will need to check that the download corresponds with your OS (Mac, Linux or Windows). This guide assumes you are using windows, so select the x64 installer under the windows tab.

Next, open the file that you just downloaded. Follow each of the steps in the window that opens. Take note of the folder path you are installing the JDK into.

Once it is downloaded, open the windows start menu and look for "environment variables". Click Edit the system environment variables.

Check the list of values in the system variables section:

  • If there is no variable named JAVA_HOME, click the new button. For the variable name, enter "JAVA_HOME" and for the variable value, enter the path to the folder where you installed the JDK. E.g: C:\Program Files\Java\jdk-19.

  • If there is a variable named JAVA_HOME but it doesn't contain the version corresponding with the version you installed, double-click the "JAVA_HOME" variable. Update the variable value to point to the folder where you installed the JDK. E.g: C:\Program Files\Java\jdk-19. Click OK to confirm.

Double-click the path variable.


If the folder path you entered as the value for JAVA_HOME is not present in the list of values, click new and paste in that folder path.

To check that this setup of Java was successful, open a cmd or powershell window and enter the command: java --version. If you are not shown a version of Java or if the version is not correct, go back and restart the process.

2. Installing Intellij IDE

Click here and click Download under "community".

Open the downloaded exe and follow the installation instructions. On the second page in the installation process, you will be asked where to store Intellij.

In the next page you can choose whether to create a shortcut, and whether you want to associate java files with this application. If you do not plan on using Intellij for all of your Java development, leave all boxes unselected. Otherwise, select all of them. Click Next > when you are done.

In the next screen click Install to begin installing Intellij.

When the installation is complete, check the box next to "Run IntelliJ IDEA Community Edition" and then click Finish.

For the first time launch, you will have to accept a terms and conditions before continuing.

In the intellij window click New Project.

In the "New Project" window, choose a name and location for your project, select the JDK you downloaded previously and uncheck Add sample code. Click Create to confirm.

3. Downloading Java Selenium Driver files

Click here and make sure you are under the section titled: Selenium Clients and WebDriver Language Bindings. Choose the Stable version under Java.

Extract the downloaded zip file to a location in your file system, the location doesn't matter as we will be adding them into eclipse later. Just make sure you can remember where you put them.

Click here to download the chromedriver that matches the version of chrome on your PC. To check the version of chrome you have installed, click the three small dots in the top-right of the Chrome window, then click Help > About Google Chrome.

Create a folder somewhere and store Chromedriver.exe there, note down the location for later.

4. Configuring IntelliJ to use Selenium Files

Click File > Project Structure.

In the "Project Settings" section of the settings, click Modules and then go to the Dependencies tab.

Click the + icon in dependencies box and then select JARs or Directories.

In the "Attach Files or Directories" window go to the folder where you extracted your Selenium files in the previous section and click OK to add them to the Project Structure. Repeat the process for the files inside the "lib" sub-folder within the same location.

Click Apply and then, when the loading bar at the bottom of the Intellij window is gone, click OK.

5. Installing JUnit

Click here and click Download and install.

Click junit.jar.

From the following page, click the download arrow in the row with the latest version and select jar.

Go to the previous page and click hamcrest-core.jar.

Click Downloads and then click jar.

Find an appropriate location (you can use the root C: folder for simplicity's sake) and create a new folder called "JUnit".

Move both of the jar files you just downloaded into the "JUnit" folder.

6. Adding JUnit to Intellij

Go to the Intellij window and click File > Project Structure.

In the "Project Settings" section of the settings, click Modules and then go to the Dependencies tab.

Click the + icon in dependencies box and then select JARs or Directories.

In the "Attach Files or Directories" window go to the folder where you downloaded the JUnit and hamcrest JARs. Select both JAR files and click OK.

Click Apply then click OK.

7. Testing the Selenium Setup

Right-click the src folder in your project folder and click New > Java Class.

Provide the class with a name and press ENTER.

In the script for this class, copy in the following code. Replace "NewClass" with the name of your class. Replace FILEPATH with the path to the chromedriver file.

import org.junit.After;
import org.junit.Test;
import org.junit.Assert;
import org.openqa.selenium.WebDriver;

public class NewClass {
    WebDriver driver;
    public void test() {
        System.setProperty("", "FILEPATH");
        driver = new ChromeDriver();
        Assert.assertEquals("Google", driver.getTitle());

    public void afterTest() {

Right-click anywhere in the script and click Run 'CLASSNAME' where CLASSNAME is the name of your test class.

If the installation was successful, you should see a window open and close briefly as well as the console showing the following success message

Getting errors you can't seem to fix

If you received errors during this process and can't find an easy fix anywhere, you might be considering shortcuts to finish the process. If you just want to get to a point where you can start writing your own selenium code right away, use MaxTAF Cloud.

You won't receive any errors while setting up MaxTAF Cloud because it is all already set up for you. All you need is a valid email address, and you can start writing test cases for free. The only costs occur when you feel like you need advanced features, like running many tests in parallel, or an extended storage space for test reports and cases.

Leave a reply

Your email address will not be published. Required fields are marked*

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.