[Python] unable to open chrome profile in selenium

Discussão em 'Python' iniciado por Stack, Junho 7, 2025.

  1. Stack

    Stack Membro Participativo

    When launching Chrome via Selenium, I want it to launch with one of my existing profiles.

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    from selenium.webdriver.chrome.service import Service
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC


    def run(self):


    try:
    options = webdriver.ChromeOptions()
    options.add_argument('--user-data-dir=C:/User/USER/AppData/Local/Google/Chrome/User Data')
    options.add_argument('--profile-directory=Profile 8')

    service = Service("C:/Users/USER/Downloads/chromedriver-win64/chromedriver-win64/chromedriver.exe")
    driver = webdriver.Chrome(service=service, options=options)
    driver.get("https://chat.openai.com/")


    When I run the code, ChatGPT opens in the Chrome, but the profile is not the one I wanted and is logged out. So when I try to log in, it says that the browser or app may not be secure and I can't log in. ChatGPT also checks if I'm human and repeats the process endlessly and I can't log in.

    I've been trying different methods for 2 hours now but it hasn't worked. how can I fix it?? Thank you

    Continue reading...

Compartilhe esta Página