Tuesday, November 1, 2011

Disabling caching in FirefoxDriver

 Firefox profile with no caching enabled.

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);
WebDriver driver = new FirefoxDriver(profile);

Similarly profile with alert, prompt etc disabled

  profile.setPreference("capability.policy.policynames", "strict") ;
  profile.setPreference("capability.policy.strict.Window.alert", "noAccess") ;
  profile.setPreference("capability.policy.strict.Window.confirm", "noAccess") ;
  profile.setPreference("capability.policy.strict.Window.prompt", "noAccess") ;