Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear browser cache automatically in Selenium WebDriver?

How to clear browser cache before every test run? I tried with driver.manage().deleteAllCookies(); in setUp method after creating the driver instance, it is working for firefox, but for IE no use. Is there any solution for IE please provide me..

like image 215
user1441341 Avatar asked May 09 '13 12:05

user1441341


2 Answers

There is a driver capability you can set as follows:

DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);

It worked for me on IE11.

Source: http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/ie/InternetExplorerDriver.html

like image 143
Flyview Avatar answered Sep 20 '22 17:09

Flyview


IE Browser clears the cache for each element after every page load

ieCapabilities.setCapability(InternetExplorerDriver.ENABLE_ELEMENT_CACHE_CLEANUP, true);

This will do session clean up:

ieCapabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
like image 37
Avinash G V Avatar answered Sep 20 '22 17:09

Avinash G V