如何将我的Firefox Cookie与Selenium一起使用?

如何将我的Firefox Cookie与Selenium一起使用?,selenium,python-3.x,Selenium,Python 3.x,我目前正在设置一个Python脚本,以便为我注册一个网站,但每次启动它时,我都必须自己登录,并且用户名/密码不会保存 问题:是否可以在脚本中使用我的Firefox配置文件中的cookie?这可以在Chrome上完成吗?您是否尝试了以下方法: profile = webdriver.FirefoxProfile() profile.set_preference("general.useragent.override", "some UA string") driver = webdriver.Fi

我目前正在设置一个Python脚本,以便为我注册一个网站,但每次启动它时,我都必须自己登录,并且用户名/密码不会保存


问题:是否可以在脚本中使用我的Firefox配置文件中的cookie?这可以在Chrome上完成吗?

您是否尝试了以下方法:

profile = webdriver.FirefoxProfile()
profile.set_preference("general.useragent.override", "some UA string")
driver = webdriver.Firefox(profile)
访问“Cookies”了解更多详细信息和示例


让我知道这是否有帮助

更改用户代理不会对Selenium启动的浏览器所拥有的cookie产生任何影响。有一种
add\u cookie
方法可用于
WebDriver
实例,我已成功使用该方法。然而,我从未尝试过从Firefox配置文件中提取cookie,所以我不知道你会怎么做。