28

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 clear the cache and cookies in Python?

selenium version: 3.6.0

platform: python

python version: 2.7.8

webdriver: geckodriver

browser platform: Firefox

1
  • Close the webdriver and open it again Commented Oct 2, 2017 at 17:59

1 Answer 1

61

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)
Sign up to request clarification or add additional context in comments.

1 Comment

Is there any way to clear cookies without creating a new instance of a web driver?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.