问题描述:

I'm not able to launch IE browser to run my selenium automated tests written in C#.

I know the problem is that I don't have the security settings set to the same level.

I also know that the way to fix this normally is to simply select the same security level for all zones in IE security tab. BUT My work has made the security tab unavailable to me. Does anybody know another work around for this issue?

//Start Opening browser

DesiredCapabilities caps = DesiredCapabilities.InternetExplorer();

caps.SetCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);

driver = new InternetExplorerDriver(caps);

driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

driver.Manage().Window.Maximize();

driver.Navigate().GoToUrl(this.baseURL);

Thank you in advance!

网友答案:

Yes, you can do it using DesiredCapabilities class of selenium WebDriver

// Set capability of IE driver to Ignore all zones browser protected mode settings.

DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);

// Initialize InternetExplorerDriver Instance using new capability.

WebDriver driver = new InternetExplorerDriver(caps);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

Hope the same code works for you.

网友答案:

Found a solution. In addition to ignoring protected mode settings I also ignore zoom settings and clicks were not working so I also ignore native events.

Here is the new code:

var options = new InternetExplorerOptions()
{
    InitialBrowserUrl = baseURL,
    IntroduceInstabilityByIgnoringProtectedModeSettings = true,
    IgnoreZoomLevel = true,
    EnableNativeEvents = false
};

driver = new InternetExplorerDriver(options);    
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl(this.baseURL);
相关阅读:
Top