Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 501
RattleyCooper Avatar asked Apr 05 '16 18:04

RattleyCooper


1 Answers

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.

like image 103
RattleyCooper Avatar answered Oct 13 '22 13:10

RattleyCooper