首页 > 解决方案 > Python Chrome 驱动程序配置文件问题

问题描述

在最新的 chrome 版本更新中打开特定的 Chrome 配置文件时出现问题。我正在将 Python 与 chromedriver(版本 91)一起使用。大约一周前,Chrome 发布了一个新更新,似乎在打开特定 Chrome 配置文件的情况下使稳定的 chromedriver 版本无效。

我的目标:使用我的程序打开具有特定配置文件(配置文件 1)的 Chrome。

我的问题:我将 chrome 配置文件 1 固定到任务栏,并且程序成功打开了该窗口,但它不会自动登录到该 Chrome 配置文件 1。

这是我的代码:

PATH = ("chromedriver.exe")
        chrome_options = webdriver.ChromeOptions();
        prefs = {"profile.default_content_setting_values.notifications" : 2}
        chrome_options.add_experimental_option("prefs",prefs)
        chrome_options.add_argument("--user-data-dir=C:\\Local\\Google\\Chrome\\User Data")
        chrome_options.add_argument("--profile-directory= Profile 1")
        chrome_options.add_argument("start-maximized");
        chrome_options.add_experimental_option("excludeSwitches", ['enable-automation']);
        driver = webdriver.Chrome(PATH, options=chrome_options);
        driver.get(brandURL)

系统信息:Windows 10(10.0.18363 Build 18363)Chrome 版本 91.0.4472.114 Chrome 驱动程序 91.0.4472.101

为澄清起见,此代码在最新的 Chrome 更新之前运行良好。

我的问题:我可以在我的程序内部做些什么来使这个功能像以前一样?我应该寻找一种替代方法来降级我的 Chrome 版本吗?

非常感谢您的帮助-我真的很难弄清楚这一点。

谢谢

标签: pythonseleniumgoogle-chromeselenium-chromedriver

解决方案


推荐阅读