After further investigation, I managed to figure this out in an unconventional way. It seems that chromedriver does not provide a way to clear the cache programmatically. Most of the suggestions revolved around setting the switch "disk-cache-size=1" and running chrome in "incognito". Both of these did not work for me.
The solution that I came up with was to load chrome with the extension - "CacheKiller" . Unfortunately, this extension requires clicking on it to enable. I had to modify the Background.js file to disable caching by default and pack the extension.
Hope this helps someone out.
On Tuesday, February 26, 2013 9:19:03 AM UTC-5, Vic11 wrote:
Hi Guys,
In one of my tests, I need to clear the cache before each webdriver .navigate() . I tried initializing chromedriver with the following switches, but it is still caching some resources like - js and css files. Would appreciate it if someone could point me in the right direction.
ChromeOptions Chromeoptions = new ChromeOptions();
Chromeoptions.AddArguments("disable-application-cache");
Chromeoptions.AddArguments("disk-cache-size=0");
_driver = new ChromeDriver(CHROMEDRIVER_PATH, Chromeoptions);