skip to content

WebDriver Architecture

How a Selenium client actually drives a browser: the HTTP contract it speaks, how a session opens and closes, and where the driver binary comes from. Interviewers probe it for depth past the API.

on this pageshow

explore

questions

page 2 of 2

In Selenium 4, how do the error, message and stacktrace members of a failed command help you locate the fault?

level: seniorimportance: should knowfreq 54%

basics

~10 s

The error member is a fixed code the client maps onto an exception type, the message is the driver's text naming the specifics, and the stacktrace comes from the remote end, not your test.

open as a page

In Selenium, what profile does a Chrome session use by default, and what changes when ChromeOptions adds --user-data-dir?

level: seniorimportance: should knowfreq 46%

basics

~20 s

By default the driver creates a throwaway user-data directory per session, so every run starts with no cookies, extensions or history. Adding --user-data-dir points Chrome at a directory you keep, carrying state in and writing it back out.

open as a page

What changes when a Selenium suite swaps new ChromeDriver() for RemoteWebDriver against a URL?

level: seniorimportance: should knowfreq 55%

basics

~20 s

Only construction changes. The remote form starts no process locally, takes a reachable URL plus capabilities naming the browser, and makes every command a network round-trip. The command set, the session id and the test code stay identical.

open as a page

A Selenium suite leaves chromedriver processes and temp profile directories on the CI agent - what causes that and how do you fix it?

level: seniorimportance: should knowfreq 55%

basics

~20 s

Each leftover process is a session that was never deleted. In Selenium 4 only quit() sends Delete Session and stops the driver executable the client launched, so close-only teardown and killed runs leave both behind.

open as a page

In Selenium 4, how do you decide which capabilities belong in alwaysMatch and which belong in firstMatch?

level: principalimportance: should knowfreq 33%

basics

~10 s

Put in alwaysMatch only what a result would be meaningless without, and use firstMatch for preferences you would rather degrade than fail on. Every extra requirement trades a chance of no session for reproducibility.

open as a page

On a long-lived shared runner, how far do you go beyond driver.quit() to stop Selenium sessions accumulating?

level: principalimportance: should knowfreq 36%

basics

~20 s

Make quit() unconditional first, then add one bounded backstop for the runs where it cannot execute: a scoped pre-run sweep, a disposable run environment, or moving browsers to a remote end that reaps its own abandoned sessions.

open as a page

In Selenium, what does a started ChromeDriverService's getUrl() return, and what is it used for?

level: juniorimportance: nice to knowfreq 26%

basics

~10 s

It returns the base HTTP address the driver process is listening on, such as http://localhost:9515. Use it to log the port, to probe the driver, or to point a RemoteWebDriver at that local driver.

open as a page

In Selenium 4's WebDriver protocol, what does the value member of a command response body carry?

level: middleimportance: nice to knowfreq 32%

basics

~20 s

Every response is a JSON object with one member named value. On success it holds the command's result, which may be null, a string, an element object, an array or a script's return. On failure it holds an error object instead.

open as a page

In Selenium automation, what is Chrome for Testing and why point a session at it instead of the installed Chrome?

level: middleimportance: nice to knowfreq 38%

basics

~20 s

Chrome for Testing is a Chrome distribution published for automation that never updates itself, with a matching driver published for every build. Pointing at it keeps browser and driver on one version, so a run stays reproducible.

open as a page

In Selenium 4, how do element references, shadow root references and window handles differ as identifiers?

level: seniorimportance: nice to knowfreq 22%

basics

~10 s

Element and shadow root references are one-member JSON objects under different fixed keys, and both die with their document. A window handle is a bare string naming a tab, and it survives navigation.

open as a page

showing 31–40 of 40