Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clear Firefox cache in Selenium IDE

I'm using Selenium IDE to test a web application. Sometimes my tests succeed even though they should have failed. The reason is that the browser happens to load a previous version of a page from the cache instead of loading the newer version of that page. In other words, I might introduce a bug to my app without being aware of it because the tests may pass after loading a previous working version instead of loading the new buggy version.

The best solution I could have thought of is to delete the browser cache before running the tests. I have a Selenium script in which I run set-up selenium commands before running the tests. Is there a selenium command to clear Firefox cache? Alternatively, is there another way to prevent loading pages from the cache during the tests?

like image 445
snakile Avatar asked Aug 22 '13 10:08

snakile


People also ask

Does selenium clear cache?

Selenium does not provide a way to delete cache, here are some workarounds. There are a few ways in which cache can be deleted using Selenium Webdriver for regular Chrome browsers. For instance, here they explain how selenium can be used to clear cache like a real user i.e., by navigating to chrome settings.

Can I clear cache for just one website Firefox?

Chosen solution. It is not possible to clear the cache for just one website, any clear operation that involves a cache clears the full cache. This even happens if you would use "Forget About This Site" to clear data from a specific website.

How do I clear my Waterfox browser cache?

Click the Firefox/Waterfox label in the top left of your browser. Click Options. Click the Privacy tab. Within the history section you will see text which states “You may want to clear your recent history”, click it's link.


3 Answers

In python this should disable firefox cache:

profile = webdriver.FirefoxProfile()
profile.set_preference("browser.cache.disk.enable", False)
profile.set_preference("browser.cache.memory.enable", False)
profile.set_preference("browser.cache.offline.enable", False)
profile.set_preference("network.http.use-cache", False)
driver = webdriver.Firefox(profile)

hope this helps someone

like image 83
serguitus Avatar answered Oct 17 '22 06:10

serguitus


You can disable the cache in firefox profile. See this link for more details.

like image 27
Priyadarshi Kunal Avatar answered Oct 17 '22 06:10

Priyadarshi Kunal


For those programming in Java, here is how I solve the issue:

    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("browser.cache.disk.enable", false);
    profile.setPreference("browser.cache.memory.enable", false);
    profile.setPreference("browser.cache.offline.enable", false);
    profile.setPreference("network.http.use-cache", false);
    FirefoxOptions options = new FirefoxOptions().setProfile(profile);
    driver = new FirefoxDriver(options);
like image 1
BelovedFool Avatar answered Oct 17 '22 08:10

BelovedFool