Saving cache in Firefox and Chrome - Selenium WebDriver

Our web application currently takes about 3 minutes to fully load without caching and 10 seconds with caching. When I open the application through WebDriver, it takes about 3 minutes to download, that is, caching is not used. I watched this in Firefox and Chrome browser. Not sure how to allow the driver to use the cache instead of downloading each file from the server each time the application is opened.

Here is what I have tried. 1. disable cache cleaning when the browser exits in the browser settings. 2. set 'applicationCacheEnabled' requiredcapabilitiy to 'true'

DesiredCapabilities cap = DesiredCapabilities.firefox(); cap.setCapability("applicationCacheEnabled", "true"); WebDriver d = new FirefoxDriver(cap) 

But nothing works. Please let me know how I can get webdriver to use caching.

+8
firefox google-chrome caching selenium
source share
1 answer

The problem is that selenium copies every start of a new (firefox / chrome) profile to the temp directory and starts firefox / chrome with it. However, you can always use the same profile for your test instances. I think that you can make it work faster.

For firefox, you just need to follow these steps:
1. Download your webapp to a firefox selenium instance and do not close it later (and not driver.close ();).
2. Then go to the "Help-> Troubleshooting" section and open the folder in the "Profile" folder.
3. Copy its contents to a new folder next to your test code.
4. Load the saved profile into the test code. You can do it as follows:

 FirefoxProfile profile = new FirefoxProfile(new File("profile/folder/path")); WebDriver driver = new FirefoxDriver(profile); 

I think you can do it in chrome similarly.

+5
source share

All Articles