Python Chrome不加载配置文件

Python Chrome不加载配置文件,python,selenium,automation,Python,Selenium,Automation,由于某些原因,程序不会加载配置文件。轮廓的位置很好 options = webdriver.ChromeOptions() options.add_argument("user-data-dir=C:\\Users\\Aron\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 2") capabilities = DesiredCapabilities.CHROME.copy() chromedriver = 'C:\\te

由于某些原因,程序不会加载配置文件。轮廓的位置很好

  options = webdriver.ChromeOptions() 
  options.add_argument("user-data-dir=C:\\Users\\Aron\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 2")
  capabilities = DesiredCapabilities.CHROME.copy()
  chromedriver = 'C:\\test\\chromedriver.exe'
  # Opening the browser
  driver = webdriver.Chrome(executable_path = chromedriver, chrome_options=options, desired_capabilities=capabilities)
两个步骤:

1-当为配置文件使用空文件夹时,Chrome会在该文件夹中创建一个新的配置文件。如果它创建了概要文件,您可以假设它下次也会加载它

options = webdriver.ChromeOptions()
options.add_argument(r"user-data-dir=C:\test\Profile 2")

chromedriver = r'C:\test\chromedriver.exe'
driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=options)

2-但为了确保您可以在Chrome中显示使用过的配置文件,请使用chrome://version/.

options = webdriver.ChromeOptions()
options.add_argument(r"user-data-dir=C:\test\Profile 2")

chromedriver = r'C:\test\chromedriver.exe'
driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=options)

driver.get('chrome://version/')

input('Enter')

您如何判断它没有加载配置文件?其中是获取URL的请求,例如
driver.get(“https://www.google.com“”
driver.get(sites['site'][0])我有一本网站字典,因为我必须打开多个网站。但是这不会加载配置文件,所以我每次都必须接受cookies并登录。这也适用于你的prillinger站点。处理饼干的好方法,我不知道。我在测试时遇到一件事:Chrome没有正确关闭,需要恢复下一次运行。在driver.close()之后添加time.sleep(2),可能更少?)似乎可以解决此问题。它表示已加载配置文件,但未加载Cookie。是否查看“url”chrome://settings/siteData 在第二次跑步之后?或者在关闭程序后使用文件C:\test\Profile 2\Default\Cookies中的记事本+?我的档案里有很多prillinger饼干。