seadowg
seadowg

Reputation: 4265

Clearing browser cache with Selenium

I've been using the Ruby selenium-webdriver gem to perform some testing on a web app at work. One thing that would be great would be the ability to programmatically clear the browsers cache before performing timed page loads etc but I can't seem to find anything in the documentation.

Does anyone know if is there a simple way of doing this with the gem?

Upvotes: 5

Views: 4226

Answers (3)

Prashanth Sams
Prashanth Sams

Reputation: 21149

Hope this helps!

@driver.manage.delete_all_cookies

Upvotes: 3

CaseyG
CaseyG

Reputation: 31

I don't have enough reputation to comment on jacksparrow007's answer, but in Ruby Selenium, his suggestion could be coded as:

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
Selenium::WebDriver.for :firefox, :profile => profile

Upvotes: 3

jacksparrow007
jacksparrow007

Reputation: 1328

I think you can do this by making a custom firefox profile and then telling your driver to use that. check this out.

Upvotes: 0

Related Questions