I think there is an incompatibility issue:

Environment:

Windows 10

Selenium 4.10

Python 3.10.7

webdriver-manager 4.0.1

Chrome Version 122.0.6261.112 (Build officiel) (64 bits)

I am making a python script. I want to open the Chrome browser with my Chrome profile.

I tried everything ChatGPT suggested to me. I always get the same issue:

An error occurred while initializing Chrome with profile and logging: Message: unknown error: cannot parse internal JSON template: Line: 1, column: 1, Unexpected token.

So I asked chatGPT to ignore my code and to make a new script from scratch. The prompt:

ok. Well, nothing works. So let's do it another way. Ignore my code and make yourself from scratch a function that opens Chrome driver with selenium 4.18.1.

After correcting some minor issues, He gave me this code:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
import os

def initialize_chrome_with_profile_and_logging():
    try:
        # Specify the path to the user's Chrome profile
        profile_path = os.path.join(os.environ['LOCALAPPDATA'], 'Google', 'Chrome', 'User Data')
        options = webdriver.ChromeOptions()
        options.add_argument(f'user-data-dir={profile_path}')  # Path to your chrome profile

        # Enable verbose logging and specify log file path
        service = ChromeService(ChromeDriverManager().install())
        log_path = os.path.join(os.getcwd(), 'chromedriver.log')
        service.start(args=['--verbose', '--log-path=' + log_path])
        
        # Initialize the Chrome driver with options and service
        driver = webdriver.Chrome(service=service, options=options)
        return driver
    except Exception as e:
        print(f"An error occurred while initializing Chrome with profile and logging: {e}")
        return None

Can anyone have time to reproduce this issue?

I don't know if it is my PC or is there a bug?

1

There are 1 best solutions below

0
odeniz On

The only solution I found is to delete this folder C:\Users\xxx\AppData\Local\Google\Chrome and reset the profiles.