How to retain Firefox cache using selenium and python

  python, selenium, selenium-firefoxdriver

I am having a small problem with my selenium automation script running on firefox. Every time I restart the container, I need to authenticate again. On chrome, I was able to use the cache, but not on Firefox. I did search for how to force firefox to use the cache, but or I am missing some step, or the answer was now outdated.

This is the piece of the code that "starts firefox":

def start_firefox():
    try:
        profile = webdriver.FirefoxProfile(profile_directory = '/tmp/firefox')
        driver = webdriver.Firefox(firefox_profile=profile,
                                   service_log_path=os.path.devnull)
        return driver
    except Exception as e:
        set_status('selenium', False)
        logging.exception(e)

Any idea on what is preventing firefox from reuse the same cache?

Source: Python Questions

LEAVE A COMMENT