
The options we care about are in the Browser Privacy section of the Preferences page which you can access by visiting about:preferences#privacy in Firefox. We’ll clear the cache by emulating how a human would accomplish the task: by visiting Firefox’s preferences page and going through the appropriate UI interactions. The cache clearing process is quite similar for older versions of Firefox, and the slightly different cache clearing script written for Firefox 57 is still available in our article materials repository.

Update: These instructions have been updated to work with Firefox 61, released on June 26, 2018. The technique is quite similar to the one used to clear the Chrome browser cache, also published on our blog, so head on over there if you prefer using Chrome with Selenium. The rest of the article will describe what this utility actually does. If all you’re interested in is the end-result, take a look at the finished utility in Intoli’s article code repository. The code will be written in Python, but you should be able to adapt it to other languages without much difficulty.
#Clear cookies and cache on firefox how to
In this article I’ll describe how to clear the Firefox browser cache with Selenium. However, lingering cached resources can cause your tests to pass when they shouldn’t, prevent your scrapers from quickly starting clean sessions on demand, and cause all sorts of undesirable behavior besides. This is not particularly surprising given that the WebDriver specification that Selenium uses behind the scenes has no provision for clearing the cache.

If you use Selenium for automated testing or web scraping, you may have discovered that there is no built-in utility for clearing browser resources like cookies, cached scripts, and objects in local storage.
