close

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

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to load default profile in Chrome using Python Selenium Webdriver in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

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

  1. How to load default profile in Chrome using Python Selenium Webdriver?

    To find path to your chrome profile data you need to type chrome://version/ into address bar . For ex.

  2. load default profile in Chrome using Python Selenium Webdriver

    To find path to your chrome profile data you need to type chrome://version/ into address bar . For ex.

Method 1

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.

Method 2

This solved my problem. (remove Default at the end)

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument("--user-data-dir=/home/username/.config/google-chrome")

cls.driver = webdriver.Chrome(options=options,
                              executable_path="./../ext/chromedriver")

Chrome_Options ist deprecated. Use options instead

Conclusion

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read