Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

selenium - Possible to disable firefox and chrome default caching?

I'm having a problem with firefox caching, when i change a site redirection firefox decides that it needs to cache this.

The point is I wan't to create a test that tests editing a redirection works, but this caching prevents me from doing this.

Is there a way to disable firefox caching? or better yet delete it when needed?

NOTE: It's not cookies but the actual firefox cache.

I'm using webdriver C# version.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Take a look at this page: http://code.google.com/p/selenium/issues/detail?id=40

To disable Firefox caching you can try: Create a new profile with firefox.exe -ProfileManager

Go to the Firefox profile directory and add the following to prefs.js:

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);

Tell Selenium to use the custom Firefox profile (This is Java):

ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile profile = allProfiles.getProfile("Selenium");
FirefoxDriver browser = new FirefoxDriver(profile);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...