Setup Selenium Java
Project - Java, Maven,
IntelliJ IDEA
(Quick Guide Setup)
Prepared by :-
Kushal Parikh
Driving Quality Through Automation
Checkout my topmate - [Link]
● Setting up Java & Maven Environment Variables
■ 1️⃣ Install & Configure Java
Step 1: Check if Java is installed using Command Line CMD:
java -version
Step 2: If not installed, download and install Java:
● Windows/Mac/Linux: Download JDK
Step 3: Set environment variables:
● Windows:
1. Go to System Properties → Advanced → Environment Variables
2. Add JAVA_HOME = C:\Program Files\Java\jdk-XX
3. Add JAVA_HOME\bin to Path
Follow me on LinkedIn - [Link]
Mac/Linux: Add to ~/.bashrc or ~/.zshrc:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-
[Link]/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH
Step 4: Verify setup - Open Command Line CMD
java -version
Checkout my topmate - [Link]
■ 2️⃣ Install & Configure IntelliJ IDEA
Step 1: Download and install IntelliJ IDEA (Community Edition is free).
Step 2: Install Maven Plugin (comes pre-installed in IntelliJ).
■ 3️⃣ Install & Configure Maven
Step 1: Check if Maven is installed:
mvn -version
Step 2: If not installed, download & install:
Download Apache Maven
Step 3: Set environment variables:
● Windows:
1. Add MAVEN_HOME = C:\apache-maven-XX
2. Add MAVEN_HOME\bin to Path
Note - Already shown maven variables in above screenshots for
Java environments
Step 4: Verify setup:
mvn -version
Follow me on LinkedIn - [Link]
■
● Selenium Java Project Setup - Create Project
■ 1️⃣ Create a Maven Project in IntelliJ IDEA
Step 1: Open IntelliJ IDEA → New Project
Step 2: Select Maven, Enter your project name & click on Finish button
Checkout my topmate - [Link]
Follow me on LinkedIn - [Link]
■ 2️⃣ Add Dependencies in [Link]
Step 1: Open [Link] and add Selenium dependency from below link : -
Link - [Link]
<dependencies>
<dependency>
<groupId>[Link]</groupId>
<artifactId>selenium-java</artifactId>
<version>4.28.1</version>
</dependency>
</dependencies>
Checkout my topmate - [Link]
Click on Maven Load Icon to load the changes !
Step 2: Update project dependencies:
mvn clean install
Follow me on LinkedIn - [Link]
■ 3️⃣ Create Your First Selenium Test
Step 1: In src/test/java, create a new Java class - [Link]
Step 2: Add the following Selenium test script:
import [Link];
Checkout my topmate - [Link]
import [Link];
import [Link];
import [Link];
public class SeleniumDemoTest {
public static void main(String[] args){
// Initialize WebDriver
WebDriver driver = new ChromeDriver();
// Maximize browser window
[Link]().window().maximize();
// Open Google
[Link]("[Link]
// Print Page Title
[Link]("Page Title: " + [Link]());
// Close the browser
[Link]();
}
}
Follow me on LinkedIn - [Link]
5️⃣ Run the Selenium Test
Step 1: Right-click on [Link]
Checkout my topmate - [Link]
Step 2: The browser should launch and open Google.
■ Your Selenium Java Maven Project is Ready!
Now you have a fully configured Selenium Java Test Automation Setup using Java,
Maven & IntelliJ IDEA!
Follow me on LinkedIn - [Link]