Selenium · Browser automation foundations

How does the W3C WebDriver protocol work?

Hardw3c webdriverprotocolcapabilitiesUpdated Oct 2026
Quiz this track

Short answer

WebDriver is an HTTP and JSON protocol. A client creates a session with capabilities, then sends commands such as navigate, findElement and click to a driver, which returns a JSON response for each command.

The W3C specification standardised what was previously the JSON Wire Protocol. Every interaction is a request to a REST-like endpoint on the driver or Grid. The response includes a status value, the command result and error information. Bindings are convenience wrappers over these endpoints.

http
POST /session
Content-Type: application/json

{
  "capabilities": {
    "alwaysMatch": {
      "browserName": "chrome",
      "platformName": "linux"
    }
  }
}

HTTP/1.1 200 OK

{
  "value": {
    "sessionId": "a1b2c3",
    "capabilities": {
      "browserName": "chrome",
      "browserVersion": "128.0"
    }
  }
}
Session creation negotiates capabilities and returns the session id used by all later commands.
  • Session commands create, query and delete a session
  • Navigation commands handle back, forward, refresh and URL changes
  • Element commands find, click, send keys and read attributes
  • Script commands execute JavaScript and manage timeouts
  • Cookie, window and alert commands cover browser state
  • The newer WebDriver BiDi work adds bidirectional browser events alongside the classic protocol

Capabilities are the contract. alwaysMatch must match exactly, while firstMatch offers alternatives. A Grid uses them to pick a node, and a cloud provider uses them for billing and routing. Mismatched capabilities cause session creation errors rather than silent fallbacks.

Because the protocol is HTTP, you can inspect it. Driver logs and proxy tools reveal the actual command and response, which is often faster than guessing why a click failed.
java
ChromeOptions options = new ChromeOptions();
options.setBrowserVersion("stable");
options.addArguments("--headless=new");

WebDriver driver = new RemoteWebDriver(
    new URL("http://grid.example.com:4444"),
    options);
The binding sends these options as capability matching fields.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1What is the difference between alwaysMatch and firstMatch?
  2. 2Why did W3C standardisation matter for Selenium?
  3. 3How would you debug a failed session creation?
  4. 4What does WebDriver BiDi add?

Say it in the interview

WebDriver is an HTTP and JSON protocol. Creating a session sends capabilities, and the driver returns a session id plus the matched browser details. Every later action, such as navigating or clicking, is another endpoint call, and capabilities matter because Grid and cloud providers route and bill based on them. When something fails, I inspect the actual request and response rather than assuming the binding did what I expected.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Selenium mock interview and get scored feedback on depth, clarity and confidence.