Complete notes for Selenium 4.6+ and above, including Java JDK, Eclipse, Maven, Selenium libraries, and browser setup.
| Software | Purpose |
|---|---|
| Java JDK | Used to write and execute Selenium code |
| Eclipse IDE / IntelliJ IDEA | Used for writing code |
| Maven | Used for dependency management |
| Selenium Library | Provides Selenium classes and methods |
| Web Browser | Browser to automate |
| Internet Connection | Required for dependency downloads |
| Software | Recommended Version |
|---|---|
| Java JDK | JDK 17 or above |
| Eclipse | Latest version |
| Maven | Latest version |
| Selenium | Selenium 4.6+ |
| Chrome Browser | Latest version |
Java is required because Selenium scripts are written and compiled using Java.
Download Java: Download Java JDK and install it according to your operating system.
Refer to the Java setup guide for detailed installation steps: https://prowessapps.com/java/java-environment-setup
Verify Java installation:
java -version
Example output:
java version "21.0.1"
Java(TM) SE Runtime Environment
Check Java compiler:
javac -version
Example output:
javac 21.0.1
After installing Java, configure environment variables so Selenium and Maven can find the JDK.
Open:
Create a new system variable:
Add this path under System Path:
%JAVA_HOME%\bin
Verify the variable:
echo %JAVA_HOME%
Eclipse provides an environment for writing and executing Selenium scripts.
Install Eclipse: Download and install Eclipse IDE.
Recommended package: Eclipse IDE for Java Developers.
Launch Eclipse and select your workspace.
Your workspace may look like:
C:\Users\Username\workspace
Click Launch to open Eclipse.
Maven automatically manages project dependencies.
Navigate:
Search for Maven Project.
Select:
Click Next.
Select workspace settings and make sure Create a simple project is unchecked.
Click Next.
Select archetype maven-archetype-quickstart from org.apache.maven.archetypes.
Click Next.
Enter project details:
Click Finish.
After project creation, the structure should look like:
SeleniumProject
│
├── src/main/java
│
├── src/test/java
│
├── JRE System Library
│
├── Maven Dependencies
│
└── pom.xml
Open pom.xml and add the Selenium dependency.
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.33.0</version>
</dependency>
</dependencies>
Save the file. Maven will download Selenium libraries automatically.
Create a Java class inside src/test/java.
Example:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class FirstTest {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com");
System.out.println(driver.getTitle());
driver.quit();
}
}
WebDriver driver = new ChromeDriver(); opens the Chrome browser.driver.get("https://www.google.com"); loads the website.driver.getTitle(); returns the page title.driver.quit(); closes all browser windows.Test Script
↓
Selenium WebDriver
↓
Selenium Manager
↓
Browser Driver
↓
Browser
Earlier versions used explicit driver setup:
System.setProperty(
"webdriver.chrome.driver",
"C:\Drivers\chromedriver.exe"
);
WebDriver driver = new ChromeDriver();
In Selenium 4.6+, this is generally not required.
Error: 'java' is not recognized
Solution: Configure JAVA_HOME correctly.
Error: The import org.openqa cannot be resolved
Solution: Update the Maven project so dependencies are downloaded.
Error: session not created
Solution: Update the browser version to match the driver.
| Software | Purpose |
|---|---|
| Python | Used to write Selenium scripts |
| IDE (PyCharm / VS Code) | Used to write and execute code |
| Selenium Package | Provides Selenium methods |
| Browser | Browser to automate |
| Internet Connection | Required to download packages |
| Software | Recommended Version |
|---|---|
| Python | Python 3.10+ |
| Selenium | Selenium 4.6+ |
| VS Code | Latest Version |
| Chrome Browser | Latest Version |
Download and install Python according to your operating system.
During installation, make sure to check Add Python to PATH.
Click Install Now.
Verify Python installation:
python --version
Example output:
Python 3.12.2
Check pip installation:
pip --version
Example output:
pip 24.0
Popular IDEs include:
Example folder structure:
SeleniumProject
│
├── test.py
│
├── requirements.txt
│
└── venv
Virtual environments isolate project packages.
Open terminal:
python -m venv venv
Activate the virtual environment:
Windows
venv\Scripts\activate
macOS/Linux
source venv/bin/activate
After activation, (venv) appears in the terminal.
Install Selenium:
pip install selenium
Verify installation:
pip show selenium
Example output:
Name: selenium
Version: 4.x.x
Create a new file named test.py.
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.google.com")
print(driver.title)
driver.quit()
from selenium import webdriver imports Selenium browser classes.driver = webdriver.Chrome() launches Chrome browser.driver.get("https://www.google.com") navigates to the URL.print(driver.title) displays the page title.driver.quit() closes all browser windows.Open terminal and run:
python test.py
Expected output:
Google
Python Script
↓
Selenium WebDriver
↓
Selenium Manager
↓
Browser Driver
↓
Browser
Earlier versions required:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
service = Service(
executable_path="C:/Drivers/chromedriver.exe"
)
driver = webdriver.Chrome(service=service)
This is usually unnecessary in Selenium 4.6+.
Error: 'python' is not recognized
Solution: Reinstall Python and enable Add Python to PATH.
Error: ModuleNotFoundError: No module named 'selenium'
Solution: Run pip install selenium.
Error: session not created
Solution: Update the browser version.