Skip to main content

Overview

The Config class encapsulates all browser configuration options. You can create a Config object to customize browser behavior, or pass parameters directly to start() or Browser.create().
Calling a Config instance (e.g., config()) returns the list of command-line arguments that will be passed to the browser.

Constructor

Parameters

PathLike
default:"None"
Path to the user data directory. If not specified, a temporary directory is created and deleted on exit.
bool
default:"False"
Run browser in headless mode (no visible window).
PathLike
default:"None"
Path to the browser executable. If not specified, nodriver will auto-detect Chrome/Chromium.
List[str]
default:"None"
Additional command-line arguments to pass to the browser.
bool
default:"True"
Enable sandbox mode. When False, adds --no-sandbox. Automatically disabled when running as root on Linux.
str
default:"en-US"
Browser language setting.
str
default:"None"
Host for remote debugging. When both host and port are set, connects to existing browser instead of launching new one.
int
default:"None"
Port for remote debugging. When both host and port are set, connects to existing browser instead of launching new one.
bool
default:"None"
Enable expert mode with additional debugging features and reduced security restrictions.
dict
default:"None"
Additional keyword arguments are stored as attributes on the Config object.

Properties

List[str]
Returns the complete list of browser arguments (default args + custom args).
str
Path to the user data directory.
bool
Whether a custom user data directory was specified (True) or a temporary one was created (False).
str
Path to the browser executable.
bool
Whether running in headless mode.
bool
Whether sandbox is enabled.
str
Browser language setting.
str
Remote debugging host.
int
Remote debugging port.
bool
Whether expert mode is enabled.

Methods

add_argument()

Add a custom browser argument.
str
required
Browser argument to add (e.g., “—disable-gpu”).
Cannot add arguments related to headless, data-dir, sandbox, or lang. Use Config properties instead.
Example:

add_extension()

Add a Chrome extension to load.
PathLike
required
Path to extension folder (containing manifest) or .crx file.
Example:

call()

Get the list of browser arguments.
Returns: Complete list of command-line arguments to pass to the browser. Example:

Default Browser Arguments

The Config class automatically includes these default arguments:
  • --remote-allow-origins=* - Allow remote connections
  • --no-first-run - Skip first run wizards
  • --no-service-autorun - Disable service auto-run
  • --no-default-browser-check - Skip default browser check
  • --homepage=about:blank - Set homepage to blank
  • --no-pings - Disable hyperlink auditing
  • --password-store=basic - Use basic password store
  • --disable-infobars - Disable info bars
  • --disable-breakpad - Disable crash reporter
  • --disable-dev-shm-usage - Disable /dev/shm usage
  • --disable-session-crashed-bubble - Disable crash bubble
  • --disable-search-engine-choice-screen - Skip search engine choice

Examples

Basic configuration

Custom user data directory

Advanced configuration

Connect to existing browser

Expert mode for testing

Multiple browser instances

Utility Functions

find_chrome_executable()

Find Chrome/Chromium executable on the system.

temp_profile_dir()

Generate a temporary profile directory path.

is_root()

Check if running as root/administrator.

Notes

When running as root on Linux, sandbox is automatically disabled as Chrome requires this to start.
Temporary user data directories are automatically cleaned up when the browser stops.
Expert mode reduces security restrictions and should only be used for testing and development.

See also