python selenium清除缓存和cookie

Tyr*_*ell 7 python cookies selenium caching

我正在尝试清除我的Firefox浏览器中的缓存和cookie,但我无法让它工作.我已经搜索过了,我只获得了java和C#的解决方案.如何清除Python中的缓存和cookie?

硒版本:3.6.0

平台:python

python版本:2.7.8

webdriver:geckodriver

浏览器平台:Firefox

Woj*_*zer 21

对于cookie使用'delete_all_cookies()'函数

driver.delete_all_cookies()

用于缓存创建配置文件

profile = webdriver.FirefoxProfile()
profile.set_preference("browser.cache.disk.enable", False)
profile.set_preference("browser.cache.memory.enable", False)
profile.set_preference("browser.cache.offline.enable", False)
profile.set_preference("network.http.use-cache", False) 
driver =webdriver.Firefox(profile)
Run Code Online (Sandbox Code Playgroud)

  • 有没有办法在不创建新的 Web 驱动程序实例的情况下清除 cookie? (2认同)