How to use google chrome user in selenium webdriver python [updated]

127 views Asked by At

I tried solving this problem using the answer from (How to use Chrome Profile in Selenium Webdriver Python 3) and this is what my code looked like

chrome_options = ChromeOptions()
chrome_options.add_argument("--user-data-dir=/Users/nifiseoguntoye/Library/Application Support/Google/Chrome/")
chrome_options.add_argument('--profile-directory=Profile 7')

try:
    driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=chrome_options)
    print("ChromeDriver is successfully initiated.")
except Exception as e:
    print(f"Error: {e}")

But, I got the error:

Error: Message: session not created: Chrome failed to start: exited normally.
  (session not created: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /Applications/Google Chrome.app/Contents/MacOS/Google Chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

The solutions from that post seem to have deprecated. Does anyone know an updated way to use my chrome user in the webdriver?

1

There are 1 answers

0
Yaroslavm On BEST ANSWER

You should store Chrome profile in separate folder from Chrome.

Selenium has issue by launching Chrome profile from Chrome folder directly. (I guess due to security violations).

Create folder UserData inside Chrome folder and copy there Profile 7, so your path would be as follows:

path = '/Users/nifiseoguntoye/Library/Application Support/Google/Chrome/UserData'
options.add_argument(f"--user-data-dir={path}")
options.add_argument('--profile-directory=Profile 7')