From fbcdeacddd4a9336c4d9415a8d7354069cb123db Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sun, 27 Jan 2013 14:42:11 -0500 Subject: [PATCH] disable the cache --- lib/persistent_selenium/browser.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/persistent_selenium/browser.rb b/lib/persistent_selenium/browser.rb index 11ed202..da641b4 100644 --- a/lib/persistent_selenium/browser.rb +++ b/lib/persistent_selenium/browser.rb @@ -9,7 +9,20 @@ module PersistentSelenium end def browser - @browser ||= Selenium::WebDriver.for(@browser_type) + case @browser_type + when :firefox + profile = Selenium::WebDriver::Firefox::Profile.new + profile['browser.cache.disk.enable'] = false + profile['browser.cache.memory.enable'] = false + profile['browser.cache.offline.enable'] = false + profile['network.http.use-cache'] = false + + options = { :profile => profile } + when :chrome + options = { :switches => %w{--disk-cache-size=1 --media-cache-size=1} } + end + + @browser ||= Selenium::WebDriver.for(@browser_type, options) end def options