1

Leo's question on 8/16/2019 was marked duplicate, yet was not! I too get the error

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

I've tried various forms of options and chrome_options with no change. I tried with and without specifying the use-data-dir, which then just brings up a generic profile.

DebanjanB reported

This question already has an answer here:

How to open a Chrome Profile through Python

How to open a Chrome Profile through --user-data-dir argument of Selenium

How to use Chrome Profile in Selenium Webdriver Python 3

However, these only show how to use selenium, which I am pretty sure Leo and I have written in the code, yet still get this error. Help!

Here is the code:

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

CrOptions = Options()
ProfilePath = "C:\\Users\\name\\AppData\\Local\\Google\\Chrome\\User Data\\"
CrOptions.add_argument("user-data-dir=" + ProfilePath)
ProfileName = "Profile 3"
CrOptions.add_argument("profile-directory=" + ProfileName)
browser = webdriver.Chrome(options=CrOptions)

browser.get("HTTP://msftconnectiontest.com/redirect")

It opens up the correct profile in Chrome, but meanwhile gives the InvalidArgumentException and the get command returns:

selenium.common.exceptions.WebDriverException: Message: chrome not reachable

Community
  • 1
  • 1
Jedi-X
  • 21
  • 6
  • So which error are you seeing exactly `selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: user data directory is already in use` or `selenium.common.exceptions.WebDriverException: Message: chrome not reachable` – undetected Selenium Oct 31 '19 at 10:11
  • 1
    hi, You have solved this problem? This problem happens because the previous testcase has opened a chrome browser which is not closed yet. – Rajagopalan Nov 22 '19 at 05:27

0 Answers0