Search code examples
pythongoogle-chromeselenium-webdriverselenium-chromedriver

Selenium not opening the profile I needed


from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
import time


chrome_options = Options()
chrome_options.add_argument("user-data-dir=C:\\Users\\My Name\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 12")
chrome_options.add_argument("--start-maximized")
chrome_options.add_argument("profile-directory=Profile 12")

driver = webdriver.Chrome(options=chrome_options)
driver.get("https://www.example.com")

I tried this code but it is not opening the profile I wanted instead opening a normal profile


Solution

  • You should not list the profile folder, its called user-data-dir drop "\Profile 12" , why should you have to specifiy a profile folder if it allready in the first option?

    chrome_options.add_argument("user-data-dir=C:\\Users\\My Name\\AppData\\Local\\Google\\Chrome\\User Data")
    chrome_options.add_argument("--start-maximized")
    chrome_options.add_argument("profile-directory=Profile 12")