Reputation: 2687
For IE you would use capabilities like this:
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
and possibly in combination with
driver.manage().deleteAllCookies();
How could this be achieved using Chrome and ChromeDriver?
Upvotes: 5
Views: 16290
Reputation: 193348
While we work with Internet Explorer Driver
we use the field IE_ENSURE_CLEAN_SESSION
IE_ENSURE_CLEAN_SESSION
As per the JavaDocs IE_ENSURE_CLEAN_SESSION
is the Capability that defines whether to clean or not browser cache before launching Internet Explorer by IEDriverServer and is configured as follows :
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);
Now let us have a look at GeckoDriver
which follows the WebDriver Spec
.
GeckoDriver
/ moz:profile
/ rust_mozprofile
If you have a closer look at the geckodriver
logs closely you will observe that each time geckodriver
is called a new moz:profile
is scopped out and the details of rust_mozprofile
occurs in the following line:
Marionette CONFIG Matched capabilities: {"browserName":"firefox","browserVersion":"56.0","platformName":"windows_nt","platformVersion":"6.2","pageLoadStrategy":"normal","acceptInsecureCerts":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"rotatable":false,"specificationLevel":0,"moz:processID":5848,"moz:profile":"C:\\Users\\AtechM_03\\AppData\\Local\\Temp\\rust_mozprofile.OfFuR9ogm33d","moz:accessibilityChecks":false,"moz:headless":false}
This log clearly indicates that Marionette scoops out a new "moz:profile":"C:\\Users\\AtechM_03\\AppData\\Local\\Temp\\rust_mozprofile.OfFuR9ogm33d"
and this configuration is handled by the WebDriver instance i.e. the GeckoDriver
.
You can find a more detailed discussion on moz:profile
in Is it Firefox or Geckodriver, which creates “rust_mozprofile” directory
discussion.
ChromeDriver
ChromeDriver
which is following the same WebDriver Spec
does abides (will be abiding) by the same suite.
Incase you are using any stored
FirefoxProfile
orChromeProfile
,WebDriver
will pick up the existing profile where theStored Browser Configurations
are picked up for reuse.
driver.manage().deleteAllCookies();
Irespective of New/Existing FirefoxProfile
or ChromeProfile
if you add the line :
driver.manage().deleteAllCookies();
Only the cookies gets deleted only to be get restored back to support the Active Browser Session
Upvotes: 6