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.
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.