简体   繁体   English

清除chromedriver缓存-Java

[英]clearing chromedriver cache - java

Is there a way to clear chromedriver cache using a selenium API or a javascript? 有没有一种使用硒API或JavaScript清除chromedriver缓存的方法?

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. 我还尝试了Java脚本,我必须与Incognito中不可用的扩展进行交互,因此这不是一种选择。

I will appreciate a similar solution for SafariDriver as well. 我也将感谢SafariDriver的类似解决方案。

Yes - by using a fresh profile each time. 是的-每次使用新的配置文件。

Each test should have its own WebDriver instance. 每个测试应具有自己的WebDriver实例。 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. 相反,让每个测试启动其自己的浏览器-会从新的缓存自动开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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