The_Diver
The_Diver

Reputation: 1925

How to enable caching for Selenium's webdriver Firefox?

Every time I runwebdriver.Firefox.get('someurl)code, A new Firefox driver is shown and it doesn't cache any webpage that it loads. I want to make Selenium to tell every Firefox that get loaded to cache webpages so for future uses, they don't have to load every webpage from the beginning. How do I do that?

def setup(self):
        print 'running fp'
        self.path = r'path to my profile folder'
        self.profile = webdriver.FirefoxProfile(self.path)
        self.web = webdriver.Firefox(self.profile)
        self.cache = self.web.application_cache

Upvotes: 4

Views: 4582

Answers (1)

Dušan Maďar
Dušan Maďar

Reputation: 9909

How about creating a new Firefox profile with appropriate cache settings and then use it with Selenium?

Take a look at this: http://www.toolsqa.com/selenium-webdriver/custom-firefox-profile/

And then in your Python script:

from selenium import webdriver

firefox_profile = webdriver.FirefoxProfile('path_to_your_profile')
browser = webdriver.Firefox(firefox_profile)
cache = browser.application_cache

Upvotes: 3

Related Questions