Chrome Flags Reference

Chrome command line switches and startup flags for automation, headless mode, and debugging.

--user-data-dir

What does --user-data-dir do?

Specifies the user data directory, which is where the browser will look for all of its state.

Usage

CLILaunch Chrome with --user-data-dir using CLI

chrome --user-data-dir

PuppeteerLaunch Chrome with --user-data-dir using Puppeteer

const browser = await puppeteer.launch({
  args: ['--user-data-dir']
});

PlaywrightLaunch Chrome with --user-data-dir using Playwright

const browser = await chromium.launch({
  args: ['--user-data-dir']
});

SeleniumLaunch Chrome with --user-data-dir using Selenium

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument('--user-data-dir')

driver = webdriver.Chrome(options=options)