To use Selenium WebDriver for test automation, we need to install Java, an IDE, Selenium JAR files, and browser drivers. Below are the step-by-step instructions for setting up Selenium WebDriver.
1. Prerequisites
Before installing Selenium WebDriver, ensure that you have the following:
β Java Development Kit (JDK) β Selenium WebDriver requires Java to run.
β Integrated Development Environment (IDE) β Recommended IDEs: Eclipse, IntelliJ IDEA, or VS Code.
β Web Browsers β Chrome, Firefox, Edge, or Safari.
β Browser Drivers β WebDriver requires specific browser drivers to communicate with browsers.
2. Step-by-Step Installation Guide
Step 1: Install Java (JDK)
- Download and install JDK from the official Oracle website.
- After installation, set up the JAVA_HOME environment variable:
- Windows:
- Open Control Panel β System β Advanced System Settings β Environment Variables.
- Under System Variables, click New.
- Set Variable Name =
JAVA_HOME
- Set Variable Value = Path of the JDK installation folder (e.g.,
C:\Program Files\Java\jdk-XX.X.X
). - Click OK and restart the system.
- Linux/Mac: Add this line to
~/.bashrc
or~/.zshrc
:export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-XX.X.X/Contents/Home export PATH=$JAVA_HOME/bin:$PATH
- Windows:
Step 2: Install an IDE
- Eclipse (Download from eclipse.org)
- IntelliJ IDEA (Download from jetbrains.com)
- VS Code (Download from code.visualstudio.com)
After downloading, install and launch the IDE.
Step 3: Download Selenium WebDriver JAR Files
- Visit the Selenium official website.
- Click on Selenium Java β Download the
.zip
file. - Extract the file and store the
.jar
files in a dedicated Selenium folder.
Step 4: Download Browser Drivers
Each browser requires a specific WebDriver to interact with Selenium.
Browser | WebDriver Download Link |
---|---|
Chrome | ChromeDriver |
Firefox | GeckoDriver |
Edge | EdgeDriver |
Safari | Safari has built-in WebDriver (enable Develop > Allow Remote Automation ). |
β Extract the downloaded driver and place it in a suitable directory.
β Add the WebDriver path to the system's Environment Variables (Windows) or export it in .bashrc
/.zshrc
(Mac/Linux).
Step 5: Verify Installation
To check if Java and Selenium WebDriver are installed correctly:
Verify Java Installation
java -version
Expected output (Example):
java version "17.0.1" 2021-10-19 LTS
Verify Browser Driver Installation
chromedriver --version
Expected output (Example):
ChromeDriver 120.0.6099.71 (cc5cf5d9d3f0)
Next Step: Configuring Selenium WebDriver
Once the installation is complete, we need to configure Selenium WebDriver in an IDE (Eclipse/IntelliJ IDEA) and write our first test script.
π Proceed to Selenium WebDriver Configuration π