RattleyCooper
RattleyCooper

Reputation: 5207

ChromeDriver "cannot create default profile directory"

I am using selenium with python, and I'm trying to use some arguments for starting the chromedriver.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options as ChromeOptions

def buildDriver():
    options = ChromeOptions()
    options.add_argument('--profile-directory="Default"')
    options.add_argument('--user-data-dir="C:/Temp/ChromeProfile"')
    browser = webdriver.Chrome(chrome_options=options)

driver = buildDriver()

I have not been able to find a solution to the following error:

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot create default profile directory

Googling this error doesn't result in anything meaningful, at least not for me.

Upvotes: 6

Views: 25446

Answers (2)

Elyas
Elyas

Reputation: 51

options.add_argument('--profile-directory=Default') options.add_argument('--user-data-dir=C:/Temp/ChromeProfile')

i had the same issue and for me, a changed the -- for ==

Upvotes: 5

RattleyCooper
RattleyCooper

Reputation: 5207

Turns out you cannot use quotes when adding an argument.

options.add_argument('--profile-directory=Default')
options.add_argument('--user-data-dir=C:/Temp/ChromeProfile')

Notice that it's --profile-directory=Default instead of --profile-directory="Default"

This is what fixed the issue for me.

Upvotes: 21

Related Questions