0

There are 2 issues here 1.Unable to clear cache and 2. the restore pop up comes up always when edge browser is launched. Is there any edgeoption /capability available for this?

EdgeOptions Used:

EdgeOptions options = new EdgeOptions();
capabilities.setCapability("applicationCacheEnabled", false);
        options.merge(capabilities);
        options.addArguments("--no-default-browser-check");
        options.addArguments("--disable-extensions");
        options.addArguments("test-type");
        options.addArguments("--remote-debugging-port=9222");
        options.setExperimentalOption("prefs", preferences);
        options.addArguments("--disable-session-crashed-bubble");
        options.addArguments("--disable-application-cache");
        options.addArguments("--disable-gpu");
        options.addArguments("--disable-dev-shm-usage");
        options.addArguments("--no-sandbox");
        options.addArguments("--ignore-certificate-errors");

Currently using taskkill to close any existing browsers before opening the new edge browser for automation

 rt.exec("taskkill /im msedge.exe /f /t");

And for clearing the cache -> launching the clearBrowserData using the below

edge://settings/clearBrowserData

and clearing the cache

S S
  • 313
  • 4
  • 12
  • @YuZhou , currently I was doing the clear cache the same way you mentioned, but I was looking for edgeoption /capability that could help , same with restore pop up too. But yes, the method you mentioned for clearing cache works. – S S Mar 24 '21 at 04:08
  • I didn't find edge options to achieve this. I'll continue to do research about this. Let's wait to see if there are other community members who have other solutions. – Yu Zhou Mar 24 '21 at 05:25

1 Answers1

1

You can automate the page edge://settings/clearBrowserData to clear browsing data. Simulate clicking the Clear now button in the page to clear cache like this:

driver.get("edge://settings/clearBrowserData");
driver.findElement(By.id("clear-now")).sendKeys(Keys.ENTER);

About the restore popup, have you close & destroy the WebDriver and Web Client instances properly? If you close them properly in your code, I think the restore popup won't show up. You need to use driver.quit() at the end of your code to make sure closing instances properly when you finish automating. You can also refer to this thread for more information.

Yu Zhou
  • 11,532
  • 1
  • 8
  • 22