0

I found the following:

How to clear browser cache automatically in Selenium WebDriver?

However, I don't have the propertity IE_ENSURE_CLEAN_SESSION for InternetExplorerDriver in C#.

All I can find to clear it's cache on the web is for java.

What is the equivalent in C#? Will also need to do firefox and chrome eventually...

Community
  • 1
  • 1
Cher
  • 2,789
  • 10
  • 37
  • 64
  • what version of Selenium are you using? [`InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION`](https://github.com/SeleniumHQ/selenium/commit/9b041165457915895883be4b8aa5566774276acc#diff-41f768943e8ae70d74aa34ec198abe9aR135) was introduced a while ago, back in version 2.35 – ddavison May 27 '16 at 18:43
  • thanks for you quick aanswer. 2.53.0 : http://www.seleniumhq.org/download/. But I'm using C#, not java. – Cher May 27 '16 at 18:47

1 Answers1

2

C# has this option in InternetExplorerOptions.cs:

public bool EnsureCleanSession
{
    get { return this.EnsureCleanSession; }
    set { this.EnsureCleanSession = value; }
}

So what you need is something like

var options = new InternetExplorerOptions();
options.EnsureCleanSession = true;
// ...
IWebDriver driver = new InternetExplorerDriver(options);

If you are using IWebDriver driver = new RemoteWebDriver(...) as you said in the comments, then you can

var options = new InternetExplorerOptions();
options.EnsureCleanSession = true;
DesiredCapabilities cap = (DesiredCapabilities)options.ToCapabilities();
cap.SetCapability(CapabilityType.BrowserName, DesiredCapabilities.InternetExplorer());
// continue adding other capabilities
IWebDriver driver = new RemoteWebDriver(cap)
Cher
  • 2,789
  • 10
  • 37
  • 64
timbre timbre
  • 12,648
  • 10
  • 46
  • 77