Example 1 — Read webdriver
Log the current automation flag.
console.log(navigator.webdriver); How It Works
A normal interactive session almost always prints false.

navigator.webdriver is a Baseline boolean on Navigator. It tells the page whether the browser is controlled by WebDriver automation. Learn when it is true, how to branch for tests, five examples, and what it is not for.
Read-only property
boolean
Widely available
Automation?
Usually false
Test code paths
Tools like Selenium, Playwright (when configured with WebDriver), and other automation stacks drive a real browser without a human clicking. Pages sometimes need a different path during those runs — skip animations, show debug banners, or avoid prompts that block headless tests.
navigator.webdriver is the standard cooperation signal: cooperating browsers set it to true when they are controlled by automation.
MDN describes a standard way for browsers to inform the document they are automated. It is not a complete anti-bot system — some drivers can hide the flag.
webdriver PropertyThink of navigator.webdriver as a simple yes/no light: “Is this session driven by WebDriver-style automation?”
boolean on Navigator.false when you open the site yourself.true in automated Chrome / Firefox under the flags MDN documents.true--enable-automation or --headless, or --remote-debugging-port with port 0.marionette.enabled preference or --marionette flag.General form of the property:
navigator.webdriver boolean — true when controlled by automation; otherwise usually false.console.log(navigator.webdriver); // false in a normal browsing session
if (navigator.webdriver) {
// Automated run — e.g. skip long animations, enable test hooks
console.log("Running under WebDriver automation");
} else {
console.log("Interactive (human) session");
} | Goal | Code |
|---|---|
| Read the flag | navigator.webdriver |
| Type | typeof navigator.webdriver // "boolean" |
| Automation branch | if (navigator.webdriver) { … } |
| Human / interactive branch | if (!navigator.webdriver) { … } |
| Complete bot filter? | No — cooperation signal only |
| Writable? | No (read-only) |
Four facts to remember about navigator.webdriver.
booleanAutomation flag
BaselineSince May 2018
falseHuman browsing
trueWebDriver / flags
webdriver vs Guessing from userAgentnavigator.webdriver | UA / heuristic sniffing | |
|---|---|---|
| Purpose | Standard automation signal | Guess browser / bot from strings |
| Reliability for tests | High for cooperating drivers | Brittle and spoofable |
| MDN stance | Documented WebDriver property | UA sniffing generally discouraged |
| Best use | Alternate test / CI paths | Avoid for feature gates |
Examples follow MDN navigator.webdriver behavior. Prefer Try It Yourself — in a normal browser window you should usually see false.
Read the boolean and confirm its type.
webdriverLog the current automation flag.
console.log(navigator.webdriver); A normal interactive session almost always prints false.
Beginner sanity check for the property type.
const lines = [
"value: " + navigator.webdriver,
"typeof: " + typeof navigator.webdriver
];
console.log(lines.join("\n")); MDN: the value is a boolean — not a string like "true".
Branch for automation, label the session, and enable safe test hooks.
Skip a slow animation when automation is driving the browser.
function playIntro() {
if (navigator.webdriver) {
return "Skip intro animation (WebDriver session)";
}
return "Play full intro animation (interactive session)";
}
console.log(playIntro()); Matches MDN’s idea: trigger alternate code paths during automation.
Include the flag in debug / support logs.
const label = navigator.webdriver
? "automation"
: "interactive";
const lines = [
"session: " + label,
"webdriver: " + navigator.webdriver
];
console.log(lines.join("\n")); Helpful when reproducing bugs: was this log from CI automation or a real user?
Expose helper functions only under automation (never as your only security layer).
const hooks = {};
if (navigator.webdriver) {
hooks.seedDemoData = function () {
return "Demo data seeded for automated tests";
};
}
if (hooks.seedDemoData) {
console.log(hooks.seedDemoData());
} else {
console.log("No automation hooks (interactive session)");
} Keep dangerous shortcuts behind automation checks and server-side test configuration — never trust the client flag alone.
navigator.webdriver WorksNormal launch vs automation flags / Marionette / WebDriver.
Cooperating engines expose navigator.webdriver.
Your script branches for test vs interactive UX.
Skip animations, enable hooks — keep security on the server.
true under the flags MDN documents.navigator.webdriver is Baseline Widely available across modern browsers (MDN: since May 2018). It exposes a boolean automation signal for cooperating WebDriver / headless sessions.
Boolean flag — true under documented automation setups, usually false for interactive browsing.
Bottom line: Read navigator.webdriver to branch test UX, but never treat it as your only bot or security check.
navigator.webdriver is the Baseline boolean that cooperating browsers use to say “this session is automated.” Use it for faster, more stable test paths — and keep real security decisions on the server.
Continue with windowControlsOverlay, userAgent, or the JavaScript hub.
false for normal userstruenavigator.webdriveruserAgent sniffingwebdriverBaseline automation boolean — great for tests, weak as sole bot defense.
boolean
Valueautomation
WebDriverusually human
Interactiveread-only
APItest paths
CIHeadless Chrome commonly runs with flags that set navigator.webdriver to true. That is intentional: sites and tests can cooperate. If a tool hides the flag, it is no longer playing by the same cooperation rules.
Lay out custom title bars in desktop Progressive Web Apps.
8 people found this page helpful