0

I am aware of this question and this one, but they do not cover my case.

I simply want to start Chrome (using my user profile) with python's Selenium package. I use this code:

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

options = webdriver.ChromeOptions() 
options.add_argument("user-data-dir=C:\Users\Alexis\AppData\Local\Google\Chrome\User Data") #Path to your chrome profile
driver = webdriver.Chrome(chrome_options=options)#executable_path="C:\\Users\\chromedriver.exe",

This works without problems on one of my machines, but not on another one, despite having the same versions of Chrome and the Chrome driver in the same directories.

The error I get is:

Traceback (most recent call last):
  File "test.py", line 6, in <module>
    driver = webdriver.Chrome(chrome_options=options)#executable_path="C:\\Users\\chromedriver.exe",
  File "C:\Users\Alexis\Anaconda\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 67, in __init__
    desired_capabilities=desired_capabilities)
  File "C:\Users\Alexis\Anaconda\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 87, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "C:\Users\Alexis\Anaconda\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 141, in start_session
    'desiredCapabilities': desired_capabilities,
  File "C:\Users\Alexis\Anaconda\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 201, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Alexis\Anaconda\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 181, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: failed to write prefs file
  (Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 10.0 x86_64)
Community
  • 1
  • 1
Alexis Eggermont
  • 7,665
  • 24
  • 60
  • 93

1 Answers1

1

According to this link, this is a known issue with newer chrome driver versions. One of the comments made on 21 July says the following:

Exception "unknown error: failed to write prefs file" is thrown when same 
user-data-dir and profile is used by two chrome instances in parallel.
This is reproducible in chromedriver:2.15

I am using chromedriver 2.12.301324 and do not have this problem.

Mauritz Hansen
  • 4,674
  • 3
  • 29
  • 34