这是因为selenium不使用您的默认浏览器实例,而是使用临时(空)配置文件打开了另一个实例。
如果您希望它加载默认配置文件,则需要指示它这样做。
这是一个镶边示例:
from selenium import webdriverfrom selenium.webdriver.chrome.options import Optionsoptions = webdriver.ChromeOptions() options.add_argument("user-data-dir=C:\Path") #Path to your chrome profilew = webdriver.Chrome(executable_path="C:\Users\chromedriver.exe", chrome_options=options)
这是一个Firefox示例:
from selenium import webdriverfrom selenium.webdriver.firefox.webdriver import FirefoxProfileprofile = FirefoxProfile("C:\Path\to\profile")driver = webdriver.Firefox(profile)
到这里,只需在(非官方)文档中找到与此相关的链接即可。Firefox配置文件和Chrome驱动程序信息就在其下方。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)