IE driver clearing browser cache, cookies, and history?

4,014 views
Skip to first unread message

David

unread,
Aug 17, 2012, 2:52:21 PM8/17/12
to webdriver
Now that WebDriver offers tighter integration with IE, is there an
option to clear IE browser cache, cookies, and history? Basically
doing the same as manually going into IE and for IE8-9, choose Tools >
Delete Browsing History, checking everything to delete.

What I notice is that in Selenium RC, only Firefox starts with clean
profile w/o any cache residing in browser (session). And also whether
RC or WebDriver, just deleting all cookies does not truly clear
browser cache.

As far as I know, in WebDriver, Firefox is still the only browser that
offers clean profile (maybe Chrome too?). Any support or planned
support for IE to have same?

I know for SafariDriver it's a known limitation that won't be possible
until someone finds a solution.

Jim Evans

unread,
Sep 25, 2012, 6:52:19 AM9/25/12
to webd...@googlegroups.com
This is a great idea, and thanks for sharing it, but for the love of all that's holy, can we please stop using the "ignoreProtectedModeSettings" capability as a matter of course in *every* *single* *example* of code I see posted? Please see http://jimevansmusic.blogspot.com/2012/08/youre-doing-it-wrong-protected-mode-and.html for the reasons why you shouldn't be using it.

On Tuesday, September 25, 2012 5:22:11 AM UTC-4, Praneel Redlapalle wrote:
Try This -

                        System.setProperty("webdriver.ie.driver", ".\\drivers\\IEDriverServer32.exe");
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability("ignoreZoomSetting", true);
caps.setCapability("ignoreProtectedModeSettings" , true);
//Delete Browser Cache since IE does not open a clean profile unlike Chrome & FireFox
try {
Runtime.getRuntime().exec("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
driver = new InternetExplorerDriver(caps);
driver.manage().deleteAllCookies();

Praneel Redlapalle

unread,
Sep 25, 2012, 8:45:09 AM9/25/12
to webd...@googlegroups.com
Very informative post. But on commenting out "ignoreProtectedModeSettings" IE browser fails to open. 
Error Thrown - 

java.lang.RuntimeException: org.openqa.selenium.WebDriverException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.21 seconds

The checkbox is enabled all zones in the Browser.
IE Browser Version - 9.0.8112.16421
IE Driver Version - 2.25.3.0

michelle macdonald

unread,
Jul 8, 2014, 8:56:21 PM7/8/14
to webd...@googlegroups.com
ALSO you can set your IE Browser Internet options
 
to DELETE BROWSING HISTORY ON EXIT as an alternative to having to  code something in your automation

I set mine to Delete history on exit, and now whenever I run automation everything is automatically cleared.

I only use IE for automation because Chrome and Firefox are my usual browser buddies. 
Reply all
Reply to author
Forward
0 new messages