const webdriver = require("selenium-webdriver");
const chrome = require("selenium-webdriver/chrome");
const options = new chrome.Options();
options.addArguments("user-data-dir=C:\\Users\robert.car\\AppData\\Local\\Google\\Chrome\\User Data")
options.addArguments("profile-directory=Profile 1")
const driver = new webdriver.Builder()
.forBrowser('chrome')
.setChromeOptions(options)
.build();
By default, user-data-dir considers the profile, so it is not necessary to specify that. If you want to use a different profile, specify it through the profile-directory argument.
Instructions to create a new profile:
1. Open: chrome://version in the address bar
https://i.sstatic.net/mRo0r.png
2. Copy the user dir folder completely to a new directory (e.g., c:\tmp\newdir)
3. Open the copied user data (newdir) and locate the folder named Default. This folder represents the profile.
4. Rename the Default folder as "Profile 1"
To use this new profile:
options.addArguments("user-data-dir=c:\\tmp\\newdir")
options.addArguments("profile-directory=Profile 1")