Q3 of 37 · Selenium
What is Selenium WebDriver and what does it do?
Short answer
Short answer: Selenium WebDriver is a browser automation library that drives a real browser via the W3C WebDriver protocol. Your test code sends commands (click, type, navigate); the browser executes them. It's the de-facto standard for cross-browser, cross-language UI automation.
Detail
Selenium WebDriver is a library — not a test runner — that lets your code control a real browser. You write tests in any supported language (Java, Python, JavaScript, C#, Ruby), and the WebDriver bindings translate your commands into the W3C WebDriver protocol, which the browser implements through its driver (chromedriver, geckodriver, msedgedriver).
The architecture has three layers:
- Your test code — calls like
driver.findElement(By.id("submit")).click(). - Language bindings — the Selenium client library, which speaks the WebDriver protocol over HTTP.
- Browser driver — a process the browser vendor ships, which receives the HTTP commands and drives the actual browser.
What it gives you: real browser behaviour (real DOM, real CSS, real JS execution), cross-browser coverage (Chrome, Firefox, Safari, Edge), and a stable protocol that's now a W3C standard, so vendors maintain their drivers.
What it does not give you: a test runner (you bring TestNG, JUnit, pytest, Mocha), assertion libraries, reporting, parallel execution across machines (that's Selenium Grid). Selenium is the engine; the framework around it is yours to assemble.
// EXAMPLE
FirstTest.java
import org.openqa.selenium.By;
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://example.com");
String title = driver.getTitle();
System.out.println("Title: " + title);
driver.findElement(By.cssSelector("a")).click();
driver.quit();
}
}