How to use a specific Chrome profile in Python Selenium

Selenium is a Python automation module used to automate and test web applications. In this Answer, we'll learn how to use a specific Chrome profile in Selenium using Python.

Selenium opens Chrome by default in incognito mode. If we want to open it with any pre-existing settings like logins, Chrome extensions, etc., we can tell Selenium to open Chrome with a specific Chrome profile by providing details to the ChromeOptions object.

Let's take a look at an example of this.

Code example

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

Code explanation

In the above code snippet:

  • Line 5: We create an instance of the ChromeOptions class and assign it to the options variable.

  • Line 10: We provide the path where Chrome stores profiles as a value to the argument –user-data-dir.

    • In a Linux based system, Chrome stores profiles in the path /home/username/.config/google-chrome.

    • In Windows, Chrome stores profiles in the path C:\Users\your user name here\AppData\Local\Google\Chrome\User Data.

  • Line 13: We add the argument –profile-directory with value as the directory name of the Chrome profile to the options variable. Here, we specify to use Chrome Profile 3.

  • Line 16: We create an instance of a web driver and assign it to the driver variable.

  • Line 19: We open the webpage using the get() method.

  • Line 22: We find an element with the id home and display its value to test it.

Free Resources

Copyright ©2026 Educative, Inc. All rights reserved