How to Setup IntelliJ with Selenium WebDriver

โšก Smart Summary

IntelliJ IDEA runs Selenium WebDriver tests once the Java project carries the Selenium client library on its classpath, so the IDE compiles, runs and debugs browser automation code from a single window.

  • ๐Ÿ”˜ Prerequisites: IntelliJ IDEA, a JDK, a browser and the Selenium client library are required before setup.
  • โ˜‘๏ธ Installation: The JetBrains installer covers the destination folder, launcher options and plugin defaults.
  • โœ… Classpath: Project Structure, then Modules, then Dependencies adds the Selenium JAR files as external libraries.
  • ๐Ÿงช First test: A Java class under /src opens the browser, submits an invalid email and checks the message.
  • ๐Ÿ› ๏ธ Modern option: Maven or Gradle resolves selenium-java automatically and removes the manual JAR download.
  • โš ๏ธ Selenium 4: Selenium Manager fetches the matching browser driver, so no separate driver setup is needed.

How to setup IntelliJ with Selenium WebDriver

What is IntelliJ?

IntelliJ IDEA is a Java Integrated Development Environment (IDE) built by JetBrains. It ships as an Apache 2.0 licensed Community Edition and a commercial Ultimate Edition, and provides advanced code navigation and code refactoring capabilities.

Pre-requisites to Install IntelliJ with Selenium WebDriver

The setup needs the following pre-requisites.

  • IntelliJ
  • Any Web browser (preferably Mozilla Firefox)
  • JDK (Java Development Kit)
  • Selenium .jar files

The required jar files can be downloaded from the Selenium.org official site. After download, extract the .jar files into the desired directory.

Note: a Maven or Gradle build resolves selenium-java automatically, making this manual download optional.

How to Download & Install IntelliJ

Step 1) To download IntelliJ visit the JetBrains site. Here we selected the “Community” Version; choose “Ultimate” for mobile, web and enterprise development.

JetBrains download page showing the IntelliJ IDEA Community and Ultimate editions

Step 2) When you begin downloading, you will see a message like this.

Browser download message shown when the IntelliJ IDEA installer starts downloading

Step 3) A pop-up window will open. Click the ‘run’ button.

Windows pop-up asking whether to run the downloaded IntelliJ IDEA installer

Step 4) Click the ‘next’ button in the setup wizard.

IntelliJ IDEA setup wizard welcome screen with the Next button

Step 5) Browse to your destination folder and click the ‘next’ button.

IntelliJ IDEA installer asking for the destination installation folder

Step 6) On the installation options screen,

  1. Mark the checkbox – 32-bit launcher
  2. Mark the checkbox for language as per your requirement
  3. Click the ‘next’ button

IntelliJ IDEA installation options screen with the 32-bit launcher and language checkboxes

Note: current builds are 64-bit only, so the 32-bit launcher checkbox no longer appears.

Step 7) Click the ‘Install’ button.

IntelliJ IDEA installer Start Menu folder screen with the Install button

You can see the IntelliJ installing process is in progress.

IntelliJ IDEA installation progress bar during setup

Step 8) On the final wizard screen,

  1. To run IntelliJ, mark the checkbox and
  2. Click the ‘Finish’ button

Final IntelliJ IDEA wizard screen with the Run IntelliJ IDEA checkbox and Finish button

Step 9) If an older IntelliJ version exists, you can import its settings. No previous version is installed here, so select the second option.

Import IntelliJ IDEA settings dialog offering settings from a previous version

Step 10) After you click ‘ok’, IntelliJ asks for the JetBrains privacy policy agreement. Click ‘Accept’.

JetBrains privacy policy agreement dialog with the Accept button

Step 11) Now you can set the plugin settings.

IntelliJ IDEA plugin customisation screen during first launch

Step 12) Select the option you need: create a new project, import project or open.

IntelliJ IDEA welcome screen with Create New Project, Import Project and Open options

Step 13) On the import screen,

  1. Select the ‘Project’ and ‘file’ from the library and
  2. Click the ‘OK’ button

IntelliJ IDEA import dialog for selecting the project and file from the library

Step 14) The selected file now appears in the project directory.

IntelliJ IDEA project directory showing the imported file in the project tool window

Configure IntelliJ to Support Selenium

To support Selenium, configure IntelliJ using the following steps.

Step 1) Launch your IntelliJ IDE and make a new Project. Select File -> New -> Project

IntelliJ IDEA File menu with New and Project selected to create a Java project

Step 2) When you Click -> Next, a new screen opens. Name the project; here we used Selenium_Guru99. Then Click -> Finish.

New project screen where the project is named Selenium_Guru99 before clicking Finish

Step 3) Now you need to add the Selenium .jar files into IntelliJ as external libraries.

For this go to File -> Project Structure -> in the project setting tab look for Modules -> Dependencies -> Click the ‘+’ Sign -> Select for JARs or directories.

Project Structure dialog with Modules and Dependencies open and the plus sign highlighted

Step 4) Select all Selenium .jar files from the extracted directory and its /lib subdirectory.

File chooser used to select the Selenium jar files from the extracted lib directory

The .jar files are now added. Note that the project’s /src directory is still empty.

Project structure showing the Selenium jars added as libraries and an empty src directory

Step 5) Right Click on /src directory -> New -> Java Class. Your project structure will look as shown below.

Right-click menu on the src directory used to create a new Java Class

IntelliJ Selenium Example

Now write your first WebDriver script against https://demo.guru99.com/

In this test scenario

  1. We will launch the URL
  2. Enter Invalid Email ID
  3. Click the ‘Submit’ button
  4. The output will be as shown below- ‘Email id is not valid’

Guru99 demo bank page returning the message Email ID is not valid after an invalid entry

In the result above, you can see that

  • Running the code opens a Firefox instance.
  • The code sends an email to the WebElement, an input field (abc.gmail.com).
  • When Selenium WebDriver clicks ‘submit’, the Guru99 site verifies the email id.
  • An unregistered email shows “Email ID is not valid.”

Following is java code for test1, locating both fields by XPath.

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class TestSelenium {											
			public static void main(String[] args){        
				FirefoxDriver driver=new FirefoxDriver();        
				driver.get("https://demo.guru99.com/");        
				WebElement element=driver.findElement(By.xpath("//input[@name='emailid']"));        
				element.sendKeys("abc@gmail.com");            

				WebElement button=driver.findElement(By.xpath("//input[@name='btnLogin']"));         
			button.click();    
		}
}

Note: this Selenium 3 era snippet expects geckodriver on the PATH; on Selenium 4 it runs unchanged because Selenium Manager resolves the driver.

Advantages of using IntelliJ

Beyond Selenium support, the IDE offers several productivity features worth knowing.

  • It generates getter and setter methods for object attributes instantly.
  • Simple keystrokes wrap a statement in a try-catch or if-else block, which speeds up exception handling.
  • Inbuilt packaging tools include Gradle, sbt, Grunt and Bower.
  • Databases such as SQL, Oracle, PostgreSQL and Microsoft SQL Server open directly in the IDE.
  • It supports Java, JavaScript, Clojure and other languages.
  • It runs on Windows, Linux and macOS, and is downloadable from the JetBrains site.

FAQs

Maven is preferred today. One selenium-java dependency in pom.xml pulls every jar, and an upgrade needs only a version change.

The module has no dependency entry yet. Recheck Project Structure then Dependencies, then run File then Invalidate Caches and Restart.

Not for a main method, but JUnit or TestNG adds annotations, assertions, setup hooks, grouping and reports.

AI powered locator healing repairs selectors that shifted after a release, and machine learning models rank flaky failures for triage.

Yes. GitHub Copilot drafts page objects from a comment, but verify every suggested locator against the live DOM.

Both run Selenium well. IntelliJ has stronger code completion and refactoring out of the box; Eclipse is lighter and free at every tier. Team familiarity usually decides.

Yes. It covers Java, Maven, Gradle, JUnit and TestNG. Ultimate adds web framework, database and profiling tools instead.

Selenium 4 downloads geckodriver itself, so failures now usually mean a browser and driver version mismatch or leftover session state.

Summarize this post with: