简体   繁体   中英

clearing chromedriver cache - java

Is there a way to clear chromedriver cache using a selenium API or a javascript?

I have already tried the following:

ChromeOptions options = new ChromeOptions();
                options.addArguments("user-data-dir=" + pathOfChromeProfile);
                //options.addArguments("-incognito");
                options.addArguments("-disable-cache");

                DesiredCapabilities capabilities = DesiredCapabilities.chrome();
                capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
                capabilities.setCapability(ChromeOptions.CAPABILITY, options);
                capabilities.setCapability(CapabilityType.SUPPORTS_APPLICATION_CACHE, false);

I have also tried the Java Script I have to interact with an extension that is not available in Incognito and therefore it is not an option.

I will appreciate a similar solution for SafariDriver as well.

Yes - by using a fresh profile each time.

Each test should have its own WebDriver instance. Don't "share browsers." If you share browsers, the cache does not clear. Conversely, having each test launch its own browser - starts automatically with a fresh cache.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM