How to load default profile in chrome using Python Selenium Webdriver?

MadRabbit picture MadRabbit · Jun 26, 2015 · Viewed 49.2k times · Source

So I'd like to open chrome with its default profile using pythons webdriver. I've tried everything I could find but I still couldn't get it to work. Thanks for the help!

Answer

MadRabbit picture MadRabbit · Jun 26, 2015

This is what finally got it working for me.

from selenium import webdriver

options = webdriver.ChromeOptions() 
options.add_argument("user-data-dir=C:\\Path") #Path to your chrome profile
w = webdriver.Chrome(executable_path="C:\\Users\\chromedriver.exe", chrome_options=options)

To find path to your chrome profile data you need to type chrome://version/ into address bar . For ex. mine is displayed as C:\Users\pc\AppData\Local\Google\Chrome\User Data\Default, to use it in the script I had to exclude \Default\ so we end up with only C:\Users\pc\AppData\Local\Google\Chrome\User Data.

Also if you want to have separate profile just for selenium: replace the path with any other path and if it doesn't exist on start up chrome will create new profile and directory for it.