JavaScript Navigator webdriver Property

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline

What You’ll Learn

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.

01

Kind

Read-only property

02

Returns

boolean

03

Baseline

Widely available

04

Meaning

Automation?

05

Normal use

Usually false

06

Use for

Test code paths

Introduction

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.

💡
Cooperation, not a firewall

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.

Understanding the webdriver Property

Think of navigator.webdriver as a simple yes/no light: “Is this session driven by WebDriver-style automation?”

  • Read-only boolean on Navigator.
  • Typically false when you open the site yourself.
  • true in automated Chrome / Firefox under the flags MDN documents.
  • Useful for alternate test / CI code paths.
  • Not a substitute for real security, rate limits, or CAPTCHA where needed.

When MDN says it is true

  • Chrome--enable-automation or --headless, or --remote-debugging-port with port 0.
  • Firefoxmarionette.enabled preference or --marionette flag.

📝 Syntax

General form of the property:

JavaScript
navigator.webdriver

Value

  • A booleantrue when controlled by automation; otherwise usually false.

Common patterns

JavaScript
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");
}

⚡ Quick Reference

GoalCode
Read the flagnavigator.webdriver
Typetypeof navigator.webdriver // "boolean"
Automation branchif (navigator.webdriver) { … }
Human / interactive branchif (!navigator.webdriver) { … }
Complete bot filter?No — cooperation signal only
Writable?No (read-only)

🔍 At a Glance

Four facts to remember about navigator.webdriver.

Returns
boolean

Automation flag

Status
Baseline

Since May 2018

Normal
false

Human browsing

Automated
true

WebDriver / flags

📋 webdriver vs Guessing from userAgent

navigator.webdriverUA / heuristic sniffing
PurposeStandard automation signalGuess browser / bot from strings
Reliability for testsHigh for cooperating driversBrittle and spoofable
MDN stanceDocumented WebDriver propertyUA sniffing generally discouraged
Best useAlternate test / CI pathsAvoid for feature gates

Examples Gallery

Examples follow MDN navigator.webdriver behavior. Prefer Try It Yourself — in a normal browser window you should usually see false.

📚 Getting Started

Read the boolean and confirm its type.

Example 1 — Read webdriver

Log the current automation flag.

JavaScript
console.log(navigator.webdriver);
Try It Yourself

How It Works

A normal interactive session almost always prints false.

Example 2 — Confirm Boolean Type

Beginner sanity check for the property type.

JavaScript
const lines = [
  "value: " + navigator.webdriver,
  "typeof: " + typeof navigator.webdriver
];
console.log(lines.join("\n"));
Try It Yourself

How It Works

MDN: the value is a boolean — not a string like "true".

📈 Practical Patterns

Branch for automation, label the session, and enable safe test hooks.

Example 3 — Alternate Code Path

Skip a slow animation when automation is driving the browser.

JavaScript
function playIntro() {
  if (navigator.webdriver) {
    return "Skip intro animation (WebDriver session)";
  }
  return "Play full intro animation (interactive session)";
}

console.log(playIntro());
Try It Yourself

How It Works

Matches MDN’s idea: trigger alternate code paths during automation.

Example 4 — Session Label for Logs

Include the flag in debug / support logs.

JavaScript
const label = navigator.webdriver
  ? "automation"
  : "interactive";

const lines = [
  "session: " + label,
  "webdriver: " + navigator.webdriver
];
console.log(lines.join("\n"));
Try It Yourself

How It Works

Helpful when reproducing bugs: was this log from CI automation or a real user?

Example 5 — Safe Test Hooks

Expose helper functions only under automation (never as your only security layer).

JavaScript
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)");
}
Try It Yourself

How It Works

Keep dangerous shortcuts behind automation checks and server-side test configuration — never trust the client flag alone.

🚀 Common Use Cases

  • Faster CI runs — disable long intros, tours, or decorative delays.
  • Stable end-to-end tests — avoid flaky waits tied to animations.
  • Debug banners — show “Automated session” in staging when WebDriver is on.
  • Support logs — record whether a report came from automation.
  • Not sole bot defense — combine with server checks if security matters.

🧠 How navigator.webdriver Works

1

Browser starts

Normal launch vs automation flags / Marionette / WebDriver.

Launch
2

UA sets the flag

Cooperating engines expose navigator.webdriver.

Signal
3

Page reads the boolean

Your script branches for test vs interactive UX.

Read
4

Alternate path runs

Skip animations, enable hooks — keep security on the server.

📝 Notes

  • Baseline Widely available (MDN, since May 2018).
  • Not Deprecated, Experimental, or Non-standard — no status banner required.
  • Read-only boolean: automation signal for cooperating WebDriver sessions.
  • Chrome / Firefox set true under the flags MDN documents.
  • Related: userAgent, userAgentData, windowControlsOverlay, Window.

Universal Browser Support

navigator.webdriver is Baseline Widely available across modern browsers (MDN: since May 2018). It exposes a boolean automation signal for cooperating WebDriver / headless sessions.

Baseline · Widely available

Navigator.webdriver

Boolean flag — true under documented automation setups, usually false for interactive browsing.

Universal Widely available
Google Chrome webdriver boolean · automation / headless flags
Full support
Mozilla Firefox webdriver boolean · Marionette flag
Full support
Microsoft Edge webdriver boolean · Chromium automation
Full support
Apple Safari webdriver boolean · modern versions
Full support
Opera webdriver boolean · modern versions
Full support
Internet Explorer Legacy / limited WebDriver story
Limited
webdriver Excellent

Bottom line: Read navigator.webdriver to branch test UX, but never treat it as your only bot or security check.

Conclusion

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.

💡 Best Practices

✅ Do

  • Use it to skip flaky animations in CI
  • Log the flag in test / support diagnostics
  • Keep alternate paths simple and documented
  • Combine with server-side test configuration
  • Expect false for normal users

❌ Don’t

  • Treat it as complete bot protection
  • Block all traffic solely because it is true
  • Assume every automated tool sets the flag
  • Assign to navigator.webdriver
  • Confuse it with userAgent sniffing

Key Takeaways

Knowledge Unlocked

Five things to remember about webdriver

Baseline automation boolean — great for tests, weak as sole bot defense.

5
Core concepts
🤖 02

True means

automation

WebDriver
👤 03

False means

usually human

Interactive
🔒 04

Access

read-only

API
🎯 05

Best use

test paths

CI

❓ Frequently Asked Questions

A boolean. It is true when the browser is controlled by automation (WebDriver), and typically false for a normal interactive browser session.
No. MDN marks it Baseline Widely available (since May 2018). It is not Deprecated, Experimental, or Non-standard.
MDN: when Chrome is started with --enable-automation or --headless, or with --remote-debugging-port set to port 0.
MDN: when the marionette.enabled preference is set or the --marionette flag is passed.
No. It is a standard cooperation signal for automation. Sophisticated bots or patched drivers may hide or omit the flag. Prefer it for test/automation code paths, not as your only security check.
No. It is a read-only Navigator property. You read the boolean; you do not assign a new value from page script.
Did you know?

Headless 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.

Explore windowControlsOverlay Next

Lay out custom title bars in desktop Progressive Web Apps.

windowControlsOverlay →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful