</>

Technology

Selenium

Difficulty

Beginner

Interview Question

What is Selenium WebDriver?

Selenium WebDriver (Selenium 2) is a browser automation framework that communicates directly with browsers via browser-specific drivers using the W3C WebDriver protocol.

Answer

What is Selenium WebDriver?

Selenium WebDriver (also called Selenium 2) is the current standard for browser automation. Unlike Selenium RC, it communicates directly with the browser through native browser APIs.

Key points:

1. Browser Automation Framework: WebDriver accepts test commands and sends them directly to the browser — no intermediate JavaScript injection required.

Java
WebDriver driver = new ChromeDriver();
driver.get("https://example.com");    // Command sent to Chrome
driver.findElement(By.id("btn")).click();  // Chrome executes native click

2. Implemented Through Browser-Specific Drivers: Each browser has its own driver that implements the WebDriver protocol.

BrowserDriver
ChromeChromeDriver
Firefoxgeckodriver
EdgeEdgeDriver
SafariSafariDriver
IEIEDriverServer

3. Direct Browser Communication: WebDriver communicates using the W3C WebDriver Protocol (HTTP-based JSON Wire Protocol) — direct, native, and fast.

CODE
Java Test → ChromeDriver → Chrome Browser
(W3C commands)   (native)

4. Language Support:

CODE
Java, C#, Python, Ruby, JavaScript (Node.js), PHP, Perl

Architecture:

Java
// These are all valid WebDriver implementations
WebDriver driver = new ChromeDriver();       // Chrome
WebDriver driver = new FirefoxDriver();      // Firefox
WebDriver driver = new EdgeDriver();          // Edge
WebDriver driver = new RemoteWebDriver(...); // Selenium Grid

WebDriver vs Selenium RC:

FeatureSelenium RCSelenium WebDriver
CommunicationJavaScript injectionDirect W3C protocol
SpeedSlowerFaster
Security restrictionsHas same-origin limitsNo restrictions
ArchitectureServer requiredDirect driver connection
Current statusMaintenance modeActive standard

Key points:

  1. WebDriver is a browser automation framework that accepts commands and sends them to a browser
  2. Implemented through browser-specific drivers (ChromeDriver, geckodriver, etc.)
  3. Controls the browser by directly communicating with it
  4. Supports: Java, C#, PHP, Python, Perl, Ruby

Follow AutomateQA

Related Topics