I was trying to automate a website and it's a PWA. I need the caching data for this site as it takes too long to load, once loaded it's pretty fast. But every time I run my scripts chrome starts a new instance loading every resource from the beginning, how can I forcefully enable to use the cache or local storage data?

class ProductAdder:
    def __init__(self):
        self.url = 'https://testsite.com/'
        self.driver = webdriver.Chrome(PATH)

    def login(self):
        wait = WebDriverWait(self.driver, 120)
        wait.until(EC.presence_of_element_located((By.XPATH,"//input[@name='email']"))).send_keys('[email protected]')

    def add(self):

if __name__ == '__main__':
    selenium = ProductAdder()
  • that is for chrome how do for firefox?
    – zparto
    Commented May 14, 2022 at 18:53

1 Answer 1


Yes, you are right, from Chrome capabilities documentations

Use custom profile (also called user data directory)
By default, ChromeDriver will create a new temporary profile for each session.

Therefor you need to create and load a custom profile by user-data-dir.

ChromeOptions options = new ChromeOptions();

In your case it could look something as follow.

class ProductAdder:
    def __init__(self):
        self.url = 'https://testsite.com/'
        options = webdriver.ChromeOptions()
        # Path To Custom Profile
        self.driver = webdriver.Chrome(PATH, options=options)

As a basic, but of course to be adapted to use implementation as you like. You can check loaded profile by browsing to chrome://version

It should also be OK use the options.add_argument('--profile-directory=<profile>') to load the profile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.