I have one scenario to automate :

Verify login with valid input

Problem Statement : Whenever I run script in IE for second time, Found all previous session are stored as it is . (Not found this same situation in Chrome and in Firefox)

My configuration :

  • Windows 10
  • Selenium 3.4.0
  • IE 11

Code :

DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
cap.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, url);
cap.setCapability("ignoreProtectedModeSettings", false);
cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
cap.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, true);
cap.setCapability(InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, false);
cap.setCapability(InternetExplorerDriver.ELEMENT_SCROLL_BEHAVIOR, 1);
cap.setCapability("cssSelectorsEnabled", true);
cap.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false);

WebDriver driver = new InternetExplorerDriver(cap);

I want to clear all the history which is given in this picture with Selenium Webdriver + IE just before starting script.

enter image description here

Note : If is there any other way to avoid it please let me know.

  • Why you need it? Anything specific? Commented Jun 27, 2017 at 7:40
  • @NarendraC Actually whenever I open new IE browser for same script. It take all history from previous browser even after quite. So I am require to kill sessions if possible.
    – Sagar007
    Commented Jun 27, 2017 at 7:42
  • Manually check - If you have opted "start from where you left". Disable that, It will work as per your requirment Commented Jun 27, 2017 at 7:45
  • No all settings are perfect. Even if it stores all previous data
    – Sagar007
    Commented Jun 27, 2017 at 7:46

1 Answer 1


Have you tried setting EnsureCleanSession to true?

DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);


cap.setCapability("ie.ensureCleanSession", true);

When set to true, this capability clears the cache, cookies, history, and saved form data. When using this capability, be aware that this clears the cache for all running instances of Internet Explorer, including those started manually. quoted from SeleniumHQ

  • can you please provide code ?
    – Sagar007
    Commented Jun 27, 2017 at 10:03
  • I've edited my answer to include code examples and the description of the capability from SeleniumHQ Commented Jun 27, 2017 at 10:49
  • It is running perfectly.
    – Sagar007
    Commented Jun 28, 2017 at 5:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.