S S
S S

Reputation: 333

Selenium Edge- How to clear cache and close the restore pages popup

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

Upvotes: 0

Views: 3899

Answers (1)

Yu Zhou
Yu Zhou

Reputation: 12961

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.

Upvotes: 1

Related Questions