python selenium clearing cache and cookies

后端 未结 1 1951
眼角桃花
眼角桃花 2020-12-14 08:56

I\'m trying to clear the cache and cookies in my firefox browser but I can\'t get it to work. I have searched it up and i\'m only getting solutions for java and C#. How do I

相关标签:
1条回答
  • 2020-12-14 09:35

    for cookies use 'delete_all_cookies()' function

    driver.delete_all_cookies()

    for cache create profile

    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)
    
    0 讨论(0)
提交回复
热议问题