InvalidArgumentException: Message: invalid argument: user data directory is already in use, please specify a unique value error while opening website

This error message...

selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir

...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session for either of the following reasons:

  • There are previous instance of ChromeDriver process attached to the system memory.
  • You have a manually opened google-chrome session already running.

You need to initiate the execution of your program with a clean slate.


Further, while working with Selenium v3.x, ChromeDriver and google-chrome on windows you may need to pass the argument executable_path along with the absolute path of the ChromeDriver binary through either of the following options:

  • Double back slashes i.e. (\\)
  • Single back slash i.e (\) along with the raw (r) switch.
  • Binary extension i.e. (.exe)

So you have to change the line :

driver = webdriver.Chrome(executable_path="C:\\\\Users\\rober\\OneDrive\\Skrivebord\\Bot\\chromedriver.exe", chrome_options=options)

with :

driver = webdriver.Chrome(executable_path=r'C:\Users\rober\\OneDrive\Skrivebord\\Bot\chromedriver.exe', options=options)

or :

driver = webdriver.Chrome(executable_path="C:\\Users\\rober\\OneDrive\\Skrivebord\\Bot\\chromedriver.exe", options=options)
  

You can find a couple of relevant detailed discussions in: