Microsoft Edge clean session Microsoft Edge clean session selenium selenium

Microsoft Edge clean session


Just encounter that issue myself today so the only way I got it to work was pretty simple in the end. You have to check "Always clear this when I close the browser" in Edge settings (and select the things that you want to clear).

With that setting you will have clean session on each new driver initialization :)selenium edge clean session


Another solution could be to open Edge in Private Mode (at least solved my problems with session and clearing cookies):

EdgeOptions options = new EdgeOptions();options.AddAdditionalCapability("InPrivate", true);this.edgeDriver = new EdgeDriver(options);


From my experience, the only way to achieve a clean session in Edge is to build it as you go. What I mean is, you must clear cookies and reload screens where necessary.

An example would be a login screen which navigates to a landing page having a popup arrive ~1-3 seconds after load.

  • Edge login pages typically don't logout the previous tests user so a Logout is often required at the beginning of these test steps if Browser=Edge.

  • The first time this all happens locally, the driver sees the popup, it's dismissed, and a cookie gets created which prevents the popup from triggering for the next test.

I don't know about your test framework, but I use ConfirmOnThisPage() methods anytime I move from one page to another. So, once I know the page has loaded, I can easily handle cookies about to be tested here with a call to a DeleteCookie(Cookie cookie) function which contains a page refresh from within my page confirmation method. I use the following:

public IWebDriver DeleteCookie(Cookie cookie){    driver.Manage().Cookies.DeleteCookieNamed(cookie);    driver.Navigate().Refresh();     return driver;}