I need that when a new session of the browser is started, the cache is disabled. Manually, I achieve that by going to the Network tab of the developer tools and checking the box to disable cache:
I tried to run the automated tests with incognito but it doesn’t work. Is there any desired capability or browser preference I can set to achieve this? I need this both for Firefox and Chrome.
I checked the ID of the button to delete cookies and it’s correct. Even tried the following with no success: driver.findElement(By.id("#clearBrowsingDataConfirm")).click();
Also this solution doesn’t suit me because it appears to apply only to Chrome browser and I need it to work in Firefox as well.
What I usually do is what I showed about, I set web driver preferences with RunConfiguration. It worked for other things such as changing the default download path of files or opening in incognito.
The desired capabilities approach is not my preferred one because I need this to work for Chrome, Firefox, Firefox headless and Chrome headless, so I’d have to write code for each one of this browsers.
In any case I just tried this before doing the opening of browser:
System.setProperty("webdriver.chrome.driver","C://WebDrivers/chromedriver.exe");
DesiredCapabilities cap = DesiredCapabilities.chrome()
cap.setCapability("applicationCacheEnabled", false)
and it didn’t work as well. I am not even sure if the WebUI.openBrowser() picks up the capabilities I just set because in the example from that page, it’s necessary to pass the capabilities to the web driver constructor.