While running your automation code in selenium using C#.
Then, most probably chances are that you will encounter the exception as “Unexpected error launching Internet Explorer. Protected Mode must be set to the same value (enabled or disabled) for all zones. (NoSuchDriver)”. And below is the screen sot for the same.
| InvalidOperationException in IE |
The cause of this issue is due to different security level and the ability to enable or disable Protected Mode. The error message is trying to tell you that Protected Mode must either be disabled or enabled for all zones because of a limitation in Selenium's InternetExplorerDriver.
To resolve this issue you need to just add 2 extra lines of code.
The Whole Code would look like this:
var capabilitiesInternet = new OpenQA.Selenium.Remote.DesiredCapabilities();
capabilitiesInternet.SetCapability("ignoreProtectedModeSettings", true);
The Whole Code would look like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
namespace AutomationUsingSelenium
{
class Program
{
static void Main(string[] args)
{
var capabilitiesInternet = new OpenQA.Selenium.Remote.DesiredCapabilities();
capabilitiesInternet.SetCapability("ignoreProtectedModeSettings", true);
IWebDriver webDriver = new InternetExplorerDriver(capabilitiesInternet);
webDriver.Navigate().GoToUrl("http://www.google.com");
IWebElement query = webDriver.FindElement(By.Name("q"));
query.SendKeys("http://jawedm.blogspot.com");
Console.WriteLine("Page title is: "+webDriver.Title);
webDriver.Quit();
Console.ReadLine();
}
}
}
Hope this would be useful for you.
Thanks, Md. jawed
Keep looking for this space to get different types of automation solutions using Selenium in .Net.