Reputation: 1168
When I start a new WebDriver session in Edge and browse to a website I previously signed in (with "remember me" cookie persisted in Edge), the WebDriver session will re-use my cookie and appear as signed in.
Is it possible to start a WebDriver session under Edge as InPrivate mode?
Upvotes: 2
Views: 1671
Reputation: 570
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 :)
Upvotes: 2
Reputation: 15423
I'm not familiar with a way to start Edge session in InPrivate mode, but as an alternative you can clean your cookies in the @Before step of each test.
For example:
@Test
public void deleteAllCookiesExample() {
driver = new ChromeDriver(); //initialize with Edge here
String url ="http://www.example.com";
driver.navigate().to(url);
driver.manage().deleteAllCookies();
}
Or delete cookies with specific name:
@Test
public void deleteCookieNamedExample() {
driver = new ChromeDriver(); //initialize with Edge here
String URL="http://www.example.com";
driver.navigate().to(URL);
driver.manage().deleteCookieNamed("__utmb"); //example cookie name
}
P.S. In previous IE versions there was a bug with it, that cookies were not accessible until you visit the page. So consider reloading the page after that or try something like (it work in IE11):
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
WebDriver driver = new InternetExplorerDriver(caps);
Upvotes: 1