skip to content

In Selenium 4, how does a client choose between a configured driver executable and Selenium Manager?

level: middleimportance: must knowfreq 55%

answer

  1. Two possible sources, one fixed order
  2. Saying nothing is what triggers resolution
  3. An explicit statement always wins
  4. Service builder or a system property
  5. Configured path means no detection, no download

basics

~20 s

An explicitly configured executable wins. If a driver path is set on the service builder or through the webdriver.chrome.driver system property, the Selenium 4 client launches that file; only when nothing is configured does it hand resolution to the bundled Selenium Manager.

solid answer

~40 s

In Selenium 4 the client needs one thing before it can create a session: the path of a driver executable to launch. It takes an **explicitly configured path first**. That means a `ChromeDriverService` built with `usingDriverExecutable(new File(...))`, or the `webdriver.chrome.driver` system property that feeds the default service. Only when neither has supplied a path does the client run the bundled **Selenium Manager** binary and use whatever path it prints. The precedence is one-way and there is no merge or fallback between them: configure a path and Selenium Manager is not invoked at all, so nothing is detected, downloaded or cached. That is exactly how you pin the driver on a host that must not fetch one, and it is also why a stale hard-coded path fails outright instead of quietly resolving something newer.

code

java · 20 lines
java
import java.io.File;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeDriverService;
import org.openqa.selenium.chrome.ChromeOptions;

public class PinnedDriverStatementTest {

    public static void main(String[] args) {
        ChromeDriverService service = new ChromeDriverService.Builder()
                .usingDriverExecutable(new File("/opt/drivers/chromedriver"))
                .build();

        ChromeDriver driver = new ChromeDriver(service, new ChromeOptions());
        try {
            driver.get("https://bank.example.com/statements");
        } finally {
            driver.quit();
        }
    }
}

go deeper

for a junior

Know that you can still point Selenium 4 at a driver file yourself, and that doing so takes priority. If you set nothing, the client resolves a driver for you automatically.

for a middle

Explain the order and its consequences: a configured executable is used as given, so no detection, download or caching happens, and a missing file fails outright instead of falling back.

for a senior

Argue the choice per environment. Automatic resolution buys clone-and-run onboarding; a configured path buys auditable provenance and no outbound request, and you should be able to say which one a given host deserves.

for a principal

Own consistency across repositories. Mixed provisioning stories produce failures that reproduce on one host and not another, so decide the default, make the exception explicit, and name who keeps pinned drivers current.

## The one thing the client needs Before a Selenium 4 client can send a **new-session** request it must have a driver process to send it to, and before that it must have the **absolute path of a driver executable** to launch. Everything in this leaf is about how that path is obtained. There are exactly two sources, and they are tried in a fixed order. ## The two sources 1. **A path you configured.** Either built into the driver service — `new ChromeDriverService.Builder().usingDriverExecutable(new File("/opt/drivers/chromedriver")).build()` — or supplied through the `webdriver.chrome.driver` system property, which the default service reads. Firefox and Edge have the matching `webdriver.gecko.driver` and `webdriver.edge.driver` properties. 2. **Selenium Manager.** The binary bundled inside the client since **Selenium 4.6**, run as a subprocess when the first source produced nothing. It detects the installed browser, resolves the matching driver, consults the driver cache, downloads only if it must, and prints a path. ## Precedence, in one rule **Configured wins, and it wins completely.** When a path is configured: - Selenium Manager is not invoked, so no browser detection happens. - Nothing is downloaded and nothing is written to the cache. - The path is used as given. If the file is absent or not executable, the run fails there rather than falling back to resolution. There is no merging, no "verify then correct", and no silent substitution. That bluntness is the feature: a team that has pinned a driver wants the run to fail loudly if the pinned file is missing, not to quietly fetch something else. | | Configured executable | Selenium Manager | |---|---|---| | Who supplies the path | You, in code or a system property | The bundled binary | | Browser detection | None | Detects the installed browser | | Network use | None | Only on a cache miss | | Failure when wrong | Immediate, at launch | Reported as a resolution failure | | Upkeep | Yours, on every host | None | ## Configuring it in Java - `ChromeDriverService.Builder().usingDriverExecutable(File)` is the explicit, per-instance form and the one to prefer in code, because the configuration sits beside the driver it applies to. - The `webdriver.chrome.driver` system property is the process-wide form: set once, it affects every default-service driver created in that JVM. - Pass the built service to the driver constructor, `new ChromeDriver(service, options)`, so the session uses exactly that executable. - Setting neither is the ordinary case, and the case the bank statement-download suite should usually be in on a developer machine. ## Choosing between them Both are legitimate defaults for different environments, and an interviewer at this level is checking that you can argue either side. - **Let Selenium Manager resolve** where machines vary, engineers come and go, and a clone-and-run repository is worth more than deterministic driver provenance. - **Configure the path** where the host must make no outbound request, where an audit needs to name the exact binary that ran, or where the driver is placed by the machine's own provisioning. - Do not do both half-way. A project that configures a path on some runs and not others has two provisioning stories and will eventually get a bug report that only reproduces under one of them. ## Telling which one a run used 1. Check whether the code configures a service executable, and whether the property is set anywhere in the launch — a build script or an inherited environment can set it without the test author knowing. 2. If neither is present, resolution went to Selenium Manager; run the bundled binary with `--debug` to see the browser it detected and the path it returned. 3. Compare that path against the executable you believe is running. A configured path that points at a file nobody updates is a common cause of "it used to work", and it will never be silently corrected. The practical takeaway is that automatic resolution in Selenium 4 is a **default, not a mandate**. It applies precisely when you have said nothing, and any explicit statement about the driver executable turns it off for that run. That framing also answers the follow-up interviewers like to add — *can you still control which driver runs?* — with a plain yes: the mechanism that made setup automatic did not remove the older, explicit route, it merely stopped being the only one. The statement-download suite can therefore run resolved-on-demand on every engineer's laptop and pinned on a controlled host, from the same source, with the difference expressed in one builder call or one system property.

  • The pinned executable is missing on one host. What does the run do?
    It fails at driver launch on that host. A configured path is used as given, with no fallback to Selenium Manager, so nothing detects the browser or downloads a replacement. That is deliberate: a pinned driver that silently became a different driver would defeat the reason for pinning it.
  • Someone set webdriver.chrome.driver in a shared launch script. How would that show up?
    As a run that never invokes Selenium Manager even though the test code says nothing about a driver. The property feeds the default service process-wide, so it silently takes precedence. Inspecting the JVM's system properties, or the launch script, is the quickest way to spot it.
  • Why prefer the service builder over the system property?
    Scope. The builder configures one driver instance and the configuration sits next to the code that uses it, whereas the property applies to every default-service driver in the JVM and can be set far from the test. Explicit, local configuration is much easier to reason about when a run misbehaves.

saying these in an interview costs you the question

  • Thinks Selenium Manager overrides an explicitly configured driver path
  • Expects a missing pinned executable to fall back to automatic resolution
  • Cannot name any way to supply the driver path explicitly
  • Believes the system property was removed in Selenium 4
  • Says both sources are merged or the newer driver is preferred