Disable browser cache for cucumber scenarios

Some time back, we faced this issue where we had setup cache control headers for certain actions in our rails app. Now when the cucumber scenarios for these actions ran, for scenarios in the same feature when the browser did not go off, the cached results would show up and our build would fail.

So here’s a quick tip to disable browser cache (for firefox) for cucumber. In your env.rb where you initialize the selenium driver, you need to put in some settings for the profile that gets used for your browser.

Capybara.register_driver :selenium do |app|

    profile = Selenium::WebDriver::Firefox::Profile.new

    profile[“browser.cache.disk.enable”] = false

    profile[“browser.cache.memory.enable”] = false

    Capybara::Driver::Selenium.new(app, :profile => profile, :http_client => WebDriver::Remote::Http::Curb)



For details on these two properties of firefox see