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:
      1. Open Control PanelSystemAdvanced System SettingsEnvironment Variables.
      2. Under System Variables, click New.
      3. Set Variable Name = JAVA_HOME
      4. Set Variable Value = Path of the JDK installation folder (e.g., C:\Program Files\Java\jdk-XX.X.X).
      5. 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
      

Step 2: Install an IDE

After downloading, install and launch the IDE.


Step 3: Download Selenium WebDriver JAR Files

  1. Visit the Selenium official website.
  2. Click on Selenium Java → Download the .zip file.
  3. 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 πŸš€