Selenium Can';t使用自定义配置文件运行Chrome浏览器

Selenium Can';t使用自定义配置文件运行Chrome浏览器,selenium,testing,selenium-chromedriver,Selenium,Testing,Selenium Chromedriver,我正在用包含必要cookie的自定义配置文件在chrome浏览器中启动selenium测试。 我使用Chrome57和chromedriver 2.29 我的代码是: ChromeOptions options = new ChromeOptions(); options.addArguments("chrome.switches", "--disable-extensions"); options.addArguments("user-data-dir=/Users/tester/Deskto

我正在用包含必要cookie的自定义配置文件在chrome浏览器中启动selenium测试。 我使用Chrome57和chromedriver 2.29 我的代码是:

ChromeOptions options = new ChromeOptions();
options.addArguments("chrome.switches", "--disable-extensions");
options.addArguments("user-data-dir=/Users/tester/Desktop/ChromeProf/QAChromeProfile");
options.addArguments("--ignore-certificate-errors","disable-infobars","enable-automation","--window-size=375,667");
WebDriver driver = new ChromeDriver(options);

它工作正常,但不要使用我的chrome配置文件。请帮帮我…

不要在
用户数据目录
参数中包含配置文件目录。当对任何配置文件使用
user data dir
选项时,除了默认配置文件之外,我还必须使用
profile dir
参数

确保将
用户数据目录更改为您的目录。不要担心空间。不要试图在参数值中加引号或转义空格

Profile 1

from selenium.webdriver import Chrome, ChromeOptions

options = ChromeOptions()
options.add_argument("user-data-dir=C:/Users/<username>/AppData/Local/Google/Chrome/User Data")
options.add_argument("profile-directory=Profile 1")

driver = Chrome(executable_path=r'C:/path/to/chromedriver.exe', chrome_options=options)
driver.get("https://www.google.com")
从selenium.webdriver导入Chrome、ChromeOptions
选项=色度选项()
options.add_参数(“user data dir=C:/Users//AppData/Local/Google/Chrome/user data”)
options.add_参数(“profile directory=profile 1”)
driver=Chrome(可执行路径=r'C:/path/to/chromedriver.exe',Chrome\u options=options)
驱动程序。获取(“https://www.google.com")

当运行代码时。(基本上,在使用自定义Chrome配置文件运行selenium之前,请关闭所有已打开的Chrome实例)

您能否详细说明如何尝试访问新的Chrome配置文件?我解决了我的问题。Thx。@PanamaBoy问题是什么?你能分享一下你是如何解决问题的吗?