Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

Clear cache #40

Closed
lukeis opened this issue Mar 2, 2016 · 18 comments
Closed

Clear cache #40

lukeis opened this issue Mar 2, 2016 · 18 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 2, 2016

Originally reported on Google Code with ID 40

In order to facilitate re-using an instance of a WebDriver (such as the
Firefox one) it would be useful to be able to clear the cache, history and
cookies. Could this be added to the API?

Reported by simon.m.stewart on 2007-11-05 16:51:55

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Just FTR about this: http://groups.google.com/group/webdriver/browse_thread/thread/843c99c02508455a/409cd62d813de648?hl=en&lnk=gst&q=Clearing+cache+in+IE#409cd62d813de648
mentions the "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 4351" trick (hack?),
see e.g. http://stackoverflow.com/questions/825144/how-to-clear-msie-wininet-cache-programatically/3725274#3725274
and http://www.howtogeek.com/howto/windows/clear-ie7-browsing-history-from-the-command-line/,
which is... good enough for us as start (and has been integrated into our in-house
InternetExplorerDriver wrapper - until available via WebDriver API.  Just thought I'd
add this here for the record for others (16 people starred this issue).

PS: http://groups.google.com/group/webdriver/browse_thread/thread/f0c1c83f091bf408/e70fdf5ee521cd4c?hl=en&lnk=gst&q=Clearing+cache+in+IE#e70fdf5ee521cd4c
says "But when 
you start a new Firefox Driver it creates a new profile (don't have to 
clear cache since it's a brand new profile)." which may be of interest to those using
FirefoxDriver (if it's correct? I'm just quoting from the list).

Reported by michael.vorburger on 2010-09-16 09:26:31

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Or you can just create a custom firefox profile with options 

in pref.js add this : 

user_pref("browser.cache.disk.enable", false);
user_pref("browser.cache.memory.enable", false);
user_pref("browser.cache.offline.enable", false);
user_pref("network.http.use-cache", false);

Here is the other pref I also have : 

user_pref("app.update.auto", false);
user_pref("app.update.lastUpdateTime.addon-background-update-timer", 1280826385);
user_pref("app.update.lastUpdateTime.background-update-timer", 1280826385);
user_pref("app.update.lastUpdateTime.blocklist-background-update-timer", 1280826385);
user_pref("app.update.lastUpdateTime.microsummary-generator-update-timer", 1280502030);
user_pref("app.update.lastUpdateTime.places-maintenance-timer", 1280826385);
user_pref("app.update.lastUpdateTime.search-engine-update-timer", 1280826385);
user_pref("browser.EULA.3.accepted", true);
user_pref("browser.EULA.override", true);
user_pref("browser.allowpopups", true);
user_pref("browser.bookmarks.restore_default_bookmarks", false);
user_pref("browser.download.manager.showWhenStarting", false);
user_pref("browser.history_expire_days.mirror", 180);
user_pref("browser.link.open_external", 2);
user_pref("browser.migration.version", 1);
user_pref("browser.places.smartBookmarksVersion", 1);
user_pref("browser.preferences.advanced.selectedTabIndex", 2);
user_pref("browser.privatebrowsing.autostart", true);
user_pref("browser.rights.3.shown", true);
user_pref("browser.safebrowsing.enabled", false);
user_pref("browser.search.update", false);
user_pref("browser.sessionstore.resume_session_once", true);
user_pref("browser.startup.homepage", "about:blank");
user_pref("browser.startup.homepage_override.mstone", "rv:1.9.1.11");
user_pref("browser.startup.page", 0);
user_pref("browser.tabs.warnOnClose", false);
user_pref("browser.tabs.warnOnOpen", false);
user_pref("browser.urlbar.autocomplete.enabled", false);
user_pref("dom.disable_open_during_load", false);
user_pref("dom.max_chrome_script_run_time", 1800);
user_pref("dom.max_script_run_time", 1800);
user_pref("extensions.lastAppVersion", "3.5.11");
user_pref("extensions.update.enabled", false);
user_pref("extensions.update.notifyUser", false);
user_pref("idle.lastDailyNotification", 1280826384);
user_pref("intl.charsetmenu.browser.cache", "UTF-8, ISO-8859-1");
user_pref("network.cookie.prefsMigrated", true);
user_pref("network.dns.disableIPv6", true);
user_pref("network.http.phishy-userpass-length", 255);
user_pref("pref.browser.homepage.disable_button.bookmark_page", false);
user_pref("pref.browser.homepage.disable_button.current_page", false);
user_pref("pref.browser.homepage.disable_button.restore_default", false);
user_pref("privacy.sanitize.migrateFx3Prefs", true);
user_pref("privacy.sanitize.timeSpan", 0);
user_pref("security.warn_entering_weak", false);
user_pref("security.warn_entering_weak.show_once", false);
user_pref("security.warn_viewing_mixed", false);
user_pref("security.warn_viewing_mixed.show_once", false);
user_pref("signon.rememberSignons", false);
user_pref("spellchecker.dictionary", "en_US");
user_pref("startup.homepage_welcome_url", "");
user_pref("urlclassifier.keyupdatetime.https://sb-ssl.google.com/safebrowsing/newkey",
1287053252);
user_pref("xpinstall.whitelist.required", false);

Reported by filirom1 on 2010-09-16 09:41:29

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

user_pref("browser.cache.disk.enable", false);
user_pref("browser.cache.memory.enable", false);
user_pref("browser.cache.offline.enable", false);
user_pref("network.http.use-cache", false);

Expect tests that use these settings to run at a snails pace :)

Reported by antlong on 2010-10-12 14:23:39

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Any info on whether this made it in to the API?

Reported by antlong on 2010-11-16 15:51:33

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Bump. 

Clearing all cookies is very important for starting each test with a clean slate.
Right now we can only delete cookies of current page.

Thanks!

Reported by streetcat on 2010-12-14 11:20:14

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Also nice to have clearing cookies/cache on remote machine using RemoteWebDriver.

Reported by slava.markovski on 2011-08-02 07:36:25

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Issue 548 has been merged into this issue.

Reported by david.burns@theautomatedtester.co.uk on 2011-08-31 14:47:11

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by barancev on 2011-10-12 18:04:59

  • Labels added: Component-WebDriver

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

IE: http://blog.patrickmeenan.com/2012/11/clearing-ies-caches-not-as-simple-as-it.html

Reported by klm@google.com on 2012-12-17 19:14:59

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

On this issue, would be interesting to hear if there are any issues and suggested solutions
for completely clearing cache for Chrome and Safari (in terms of scripted/automated
methods). Not sure about Chrome, but do know that Safari has same cache clear issue
as IE (for sure with Selenium RC at least).

Reported by mangaroo on 2012-12-17 19:35:02

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Issue 5365 has been merged into this issue.

Reported by jmleyba on 2013-03-19 17:30:31

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

If one were to extend the JsonWireProtocol:

https://code.google.com/p/selenium/wiki/JsonWireProtocol

Which one of the following would you prefer?

 1. DELETE /session/:sessionId/cache
 2. POST /session/:sessionId/cache/clear

I also think that IE could observe the "ensureCleanSession" desired capability to clear
cookies and browser cache upon a new session.

liulk

Reported by liulk@google.com on 2013-05-13 22:29:30

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

https://code.google.com/r/liulk-selenium/source/detail?r=48be0d5614f2c4005ad19fdd761b8bd62ab98bcd&name=topic/cacheclear

Adding desiredCapabilities.ensureCleanSession support to IEDriver.

liulk

Reported by liulk@google.com on 2013-05-15 18:48:52

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

On request by jimevans through klm, moved review to GitHub.

https://github.com/SeleniumHQ/selenium/pull/74

liulk

Reported by liulk@google.com on 2013-05-17 16:23:38

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Please update if, the issue is fixed.

Reported by paras.vora1801 on 2013-06-03 13:26:22

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

One should create a new session to acheive this goal.

Reported by barancev on 2014-11-05 18:44:25

  • Status changed: NotFeasible

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

There might be some confusion/conflation here between 3 scenarios:

1. Starting a new instance/restarting the whole WD server -- the Selenium jar, chromedriver,
etc.
2. Creating a new browser session via an existing WD server.
3. Clearing cache, cookies, history in an existing browser session/process -- without
restarting the browser.

Doing (1) may be logistically hard, especially when the WD server runs remote from
the test, possibly started by infrastructure "above" the test itself, i.e. the test
has no control over that.

I believe that (2) covers most reasonably structured web tests. I believe Selenium/WebDriver
already implements it for most major browsers, though there are problems with some
browsers, e.g. Mobile Safari without a jailbreak -- no public API for it that I know
of (that's an ios-driver issue, let's not discuss it here -- even doing (1) makes no
difference, it's a general iOS/Safari level problem).

(3) is exceedingly hard to implement, especially in all major browsers. I agree with
barancev@'s "not feasible" for this particular case at the Selenium-wide level. It's
fine to say that _some_ browsers _may_ offer that ability, but it's just unrealistic
to require it for all browsers.

Reported by klm@google.com on 2014-11-05 19:00:45

@lukeis
Copy link
Member Author

lukeis commented Mar 2, 2016

Reported by luke.semerau on 2015-09-17 17:47:52

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 2, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 3, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant