Skip to main content
The Config class controls browser launch parameters, behavior, and Chrome command-line arguments. It provides a flexible way to customize your browser automation setup.

Creating a configuration

You can create a Config object explicitly or let the browser create one automatically:
When you don’t provide a Config object, nodriver creates one with sensible defaults automatically.

Configuration parameters

User data directory

Specify where browser profile data is stored:
PathLike
default:"AUTO"
Path to the browser profile directory. If not specified, a temporary directory is created and cleaned up on exit.
Use cases:
  • Persist cookies and login sessions between runs
  • Maintain browser extensions
  • Store cached data
When you provide a custom user_data_dir, it will NOT be automatically deleted. When using the auto-generated directory, it’s cleaned up when the browser closes.

Headless mode

bool
default:"False"
Run the browser without a visible window. Uses the new --headless=new flag.
When to use headless:
  • Server environments without displays
  • Automated testing pipelines
  • Background scraping tasks
  • When you don’t need visual feedback
Some websites detect headless browsers. nodriver automatically patches the user agent to remove “Headless” markers, but detection may still occur.

Browser executable

PathLike
default:"AUTO"
Path to the Chrome/Chromium executable. Auto-detected if not provided.
The auto-detection searches for:
  • Google Chrome
  • Chromium
  • Chrome Beta
  • Chrome Canary
Detection paths: Linux/macOS:
  • /usr/bin/google-chrome
  • /usr/bin/chromium
  • /Applications/Google Chrome.app/Contents/MacOS/Google Chrome (macOS)
Windows:
  • C:\Program Files\Google\Chrome\Application\chrome.exe
  • C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

Browser arguments

List[str]
default:"AUTO"
Additional command-line arguments passed to Chrome.
You can also add arguments after creation:
Some arguments are managed by Config properties and should not be added manually:
  • --headless (use headless parameter)
  • --user-data-dir (use user_data_dir parameter)
  • --no-sandbox (use sandbox parameter)
  • --lang (use lang parameter)

Sandbox mode

bool
default:"True"
Enable Chrome’s sandbox for security. Automatically disabled when running as root on Linux.
On Linux systems, if you’re running as root, sandbox is automatically disabled even if you set sandbox=True.

Language

str
default:"'en-US'"
Browser language setting.

Connection settings

str
default:"AUTO"
Host for the DevTools Protocol connection. Defaults to “127.0.0.1” when starting a new browser.
int
default:"AUTO"
Port for the DevTools Protocol connection. Auto-assigned to a free port when starting a new browser.
When both host and port are specified, nodriver connects to an existing browser instead of launching a new one.

Expert mode

bool
default:"AUTO"
Enable expert mode with additional debugging capabilities.
Expert mode includes:
  • --disable-site-isolation-trials flag
  • Ensures shadow roots are always in “open” mode
  • Additional debugging scripts
Expert mode is useful for development and debugging but may affect page behavior.

Target discovery

bool
default:"True"
Automatically discover and track new browser targets (tabs, windows, iframes).
This enables automatic updates when:
  • New tabs are opened
  • Windows are created
  • Tabs are closed
  • Target information changes

Default browser arguments

nodriver includes sensible defaults that are always applied:

Extensions

Load browser extensions:
PathLike
required
Path to extension folder (containing manifest.json) or .crx file.

Inspecting configuration

Get the final list of arguments:
View configuration details:
Output:

Utility functions

Find Chrome executable

Manually find Chrome installation:

Create temporary profile

Generate a temp directory path:

Check if root

Platform detection

Common configurations

Development setup

Production scraping

Docker environment

With persistent profile

Connect to remote browser

Best practices

When you need to maintain login state across runs:
The first run will be clean, but subsequent runs will have cookies, cache, and local storage preserved.
The sandbox provides security isolation. Only disable it when:
  • Running in Docker containers
  • Running as root (automatically disabled)
  • Encountering sandbox-related crashes
Begin with default configuration and add arguments only when needed. Too many arguments can cause conflicts or unexpected behavior.
Some websites behave differently in headless mode. Test both modes to ensure compatibility.
Each extension increases resource usage and may affect page behavior. Only load necessary extensions.

Troubleshooting

Browser won’t start

Chrome not found

Connection refused

Out of memory in Docker