Re: [selenium-users] How to Cache clear in Selenium WebDriver?

11,243 views
Skip to first unread message

nellore krishna

unread,
Feb 6, 2013, 8:37:25 AM2/6/13
to seleniu...@googlegroups.com
driver.manage().deleteAllCookies() .  This should work for you

On Wed, Feb 6, 2013 at 4:22 PM, Parth Mehta <mehtapart...@gmail.com> wrote:
Hi All:
 
I am using IE for running the selenium recordings in JAVA.
 
My page is heavily cached so after the first test run the rest fails.
 
Please help me with the same. Can someone get me the code how to clear the cache.
 
Thanks:
Parth

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/DEg_6LMnyawJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

David

unread,
Feb 6, 2013, 3:07:02 PM2/6/13
to seleniu...@googlegroups.com
Anyone know if deleting all cookies clears all cache or just cookies? Want to mention that that method also might only work if the cookie is visible to the browser (e.g. can see it with browser dev tools), so you might have to start on the right page before deleting all cookies (e.g. site home page) and not delete cookies at start of test before even navigating anywhere (e.g. blank page). That is definitely the case with Selenium RC, not sure if that was ever changed for WebDriver.

Also, if needing to delete other types of cache like HTML5 local or session storage, you can do it via javascript calls to the HTML5 local/sessionStorage object API to clear them out. (And refresh page afterwards, etc. to see the change reflected).

Mark Collin

unread,
Feb 7, 2013, 5:23:27 AM2/7/13
to seleniu...@googlegroups.com
Unless things have changed recently, the IE driver doesn't have a way to
clear the cache in IE. You can use the command line to clear the IE
cache, have a look at:

http://ie-support.blogspot.co.uk/2011/02/use-command-line-to-delete-ie-browsing.html

I've found this isn't optimal though as it fires off the cache cleaning
as a different thread and doesn't block until the cache has been
cleared. This also blows away everything cached in IE so not a good
thing to use if you use IE for your day to day browsing.

vishnu

unread,
Jul 30, 2013, 12:10:03 PM7/30/13
to seleniu...@googlegroups.com
Same solution that Mark has pointed, implemented in C#.Net. Here is the link for quick reference:

http://automationoverflow.blogspot.in/2013/07/clean-session-in-internet-explorer.html

Thanks
Vishnu
Reply all
Reply to author
Forward
0 new messages