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

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.
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.
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
Go to: https://googlechromelabs.github.io/chrome-for-testing/
Match the version with your installed Chrome browser.
Extract the
.exe
file to a folder (e.g.,C:\drivers\
)
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
Method | Description | Example |
get(String url) | Opens a web page | driver.get(" https://google.com "); |
getTitle() | Returns the page title | System.out.println(driver.getTitle()); |
getCurrentUrl() | Returns the current URL | System.out.println(driver.getCurrentUrl()); |
findElement(By locator) | Finds a single web element | driver.findElement( By.id ("email")); |
sendKeys(String text) | Types text into input field | element.sendKeys("Hello"); |
click() | Clicks an element | element.click (); |
getText() | Gets the text of an element | System.out.println(element.getText()); |
close() | Closes the current tab | driver.close(); |
quit() | Closes all tabs and ends the session | driver.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
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
Browser | Driver File | Java Class | Download Link |
Chrome | chromedriver.exe | ChromeDriver() | chromedriver.chromium.org |
Firefox | geckodriver.exe | FirefoxDriver() | geckodriver GitHub |
Edge | msedgedriver.exe | EdgeDriver() | Edge WebDriver |
Subscribe to my newsletter
Read articles from Akshada Auti directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
