✅ Understanding ChromeDriver.exe: A Key Component in Selenium Testing

Akshada AutiAkshada Auti
3 min read
  1. Introduction

If you're just starting with Selenium, running your first test in Google Chrome might seem tricky. In this blog, I’ll show you how to run your test using chromedriver.exe and explain why it's an important part of the setup.

  1. What is ChromeDriver?

ChromeDriver is a standalone server that enables Selenium WebDriver to communicate with the Chrome browser.

Without chromedriver.exe, Selenium cannot launch or control Chrome during test automation. It acts like a translator between your Java code and the Chrome browser.

  1. Why is chromedriver.exe Important?

  • Allows WebDriver commands to be translated into actions in Chrome.

  • It acts as a bridge between Selenium and Chrome.

  • Required for browser automation like clicking, navigation, and data entry

4. How to Set Up ChromeDriver with Selenium in Java

Step 1: Download ChromeDriver

Step 2: Add ChromeDriver to Your Code

package SeleniumJava;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class techChrome {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.setProperty("Webdriver.chrome.driver", "/Documents");
        WebDriver driver =new ChromeDriver();
        driver.get("https://www.google.com/");
        //driver.quit();
    }

}

✅Getting Started with Basic Selenium WebDriver Methods

5. Commonly Used Selenium WebDriver Methods

MethodDescriptionExample
get(String url)Opens a web pagedriver.get("https://google.com");
getTitle()Returns the page titleSystem.out.println(driver.getTitle());
getCurrentUrl()Returns the current URLSystem.out.println(driver.getCurrentUrl());
findElement(By locator)Finds a single web elementdriver.findElement(By.id("email"));
sendKeys(String text)Types text into input fieldelement.sendKeys("Hello");
click()Clicks an elementelement.click();
getText()Gets the text of an elementSystem.out.println(element.getText());
close()Closes the current tabdriver.close();
quit()Closes all tabs and ends the sessiondriver.quit();

6. Simple Example Using These Methods

package SeleniumJava;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Basic {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        WebDriver driver = new ChromeDriver();
        driver.get("https://www.google.com/");
        System.out.println(driver.getTitle());
        System.out.println(driver.getCurrentUrl());
        driver.close();

    }
}

How to Run Selenium Tests on Firefox and Edge Browsers

1. Run Tests on Firefox with GeckoDriver

🔹 Step 1: Download GeckoDriver

  • Go to: https://github.com/mozilla/geckodriver/releases

  • Download the version suitable for your OS (e.g., Windows 64-bit)

  • Extract geckodriver.exe to a known folder

    🔹 Step 2: Java Code to Launch Firefox

      javaCopyEditimport org.openqa.selenium.WebDriver;
      import org.openqa.selenium.firefox.FirefoxDriver;
    
      public class FirefoxTest {
          public static void main(String[] args) {
              System.setProperty("webdriver.gecko.driver", "C:\\drivers\\geckodriver.exe");
              WebDriver driver = new FirefoxDriver();
    
              driver.get("https://www.google.com");
              System.out.println("Title: " + driver.getTitle());
    
              driver.quit();
          }
      }
    

2. Run Tests on Microsoft Edge with EdgeDriver

🔹 Step 1: Download EdgeDriver

🔹 Step 2: Java Code to Launch Edge

javaCopyEditimport org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;

public class EdgeTest {
    public static void main(String[] args) {
        System.setProperty("webdriver.edge.driver", "C:\\drivers\\msedgedriver.exe");
        WebDriver driver = new EdgeDriver();

        driver.get("https://www.google.com");
        System.out.println("Title: " + driver.getTitle());

        driver.quit();
    }
}

🔧 Notes

  • Always match driver version with your browser version.

  • You can set environment variables to avoid using System.setProperty() each time.

  • You need to add the correct WebDriver jars (e.g., Selenium Java client) to your project.


📌 Summary

BrowserDriver FileJava ClassDownload Link
Chromechromedriver.exeChromeDriver()chromedriver.chromium.org
Firefoxgeckodriver.exeFirefoxDriver()geckodriver GitHub
Edgemsedgedriver.exeEdgeDriver()Edge WebDriver
0
Subscribe to my newsletter

Read articles from Akshada Auti directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Akshada Auti
Akshada Auti