Monday, October 17, 2011

Using the InternetExplorerDriver for WebDriver

Are you getting this error when trying to use the InternetExplorerDriver for WebDriver (Selenium 2.0)?

System.InvalidOperationException

"Unexpected error launching Internet Explorer. Protected Mode must be set to the same value (enabled or disabled) for all zones. (NoSuchDriver)"

Don't worry, it's easier to fix than it sounds: Simply go into your Internet Options of Internet Explorer, select the Security tab, and all four zones to have the same Protected Mode value (either all on or all off). That's it!

Sample Code

using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
 
namespace WebDriverTests
{
    public abstract class WebDriverTestBase
    {
        public IWebDriver WebDriver { get; set; }
 
        [TestFixtureSetUp]
        public void TestFixtureSetUp()
        {
            WebDriver = new InternetExplorerDriver();
        }
 
        [TestFixtureTearDown]
        public void TestFixtureTearDown()
        {
            if (WebDriver != null)
            {
                WebDriver.Close();
                WebDriver.Dispose();
            }
        }
 
        [SetUp]
        public void SetUp()
        {
            WebDriver.Url = "about:blank";
        }
    }
 
    [TestFixture]
    public class GoogleTests : WebDriverTestBase
    {
        [Test]
        public void SearchForTom()
        {
            WebDriver.Url = "http://www.google.com/";
 
            IWebElement searchBox = WebDriver
                .FindElement(By.Id("lst-ib"));
 
            searchBox.SendKeys("Tom DuPont");
            searchBox.Submit();
 
            IWebElement firstResult = WebDriver
                .FindElement(By.CssSelector("#search cite"));
 
            Assert.AreEqual("www.tomdupont.net/", firstResult.Text);
        }
    }
}
Shout it

Enjoy,
Tom

18 comments:

  1. We are a team of business logo designer designers offering high quality business logo design services and brand solutions for start-ups, small and medium entrepreneurs. With many happy customers worldwide and 5+ years in the industry, we are a pioneering logo design company with one of the highest customer satisfaction ratings. Our brand solutions start at prices as low as $ 40, making us one of the most affordable custom logo design companies, ideal for beginners and start-ups. Our brand solutions include custom logo design, stationery design, poster design, product label design, product packaging design, banner advertising design, logo vector services and logo repairs. We also provide website design services for businesses looking to build an online presence and for ecommerce businesses with powerful content management features and capabilities.

    ReplyDelete
  2. Logo Mentation is a graphic design, logo design and web design consulting service that has been developing its own websites for companies, charities and organizations since 2004. And logo design! We combine our expertise in web design and graphic design to make your product as responsive and profitable as possible. DBS has recently been tested and secured to give you complete confidence.

    ReplyDelete
  3. Logo Mentation is a graphic design, logo design and web design consulting service that has been developing its own custom logo design company, charities and organizations since 2004. And logo design! We combine our expertise in web design and graphic design to make your product as responsive and profitable as possible. DBS has recently been tested and secured to give you complete confidence.

    ReplyDelete
  4. I appreciate the instructions very substantially. While I can conduct tests in Chrome and Internet Explorer, they will only work when I am logged into the server where they are being done. The browser won't load when I try to run the test remotely for my automated tests, iphone app development company London even though Chromedriver.exe and Chrome.exe are shown in Task Manager.

    ReplyDelete
  5. You solved my problem. I was suffered from this issue since last month and it delayed my animated promotional video production work which was really important project for me. By the thanks for the step by step solution of internet explorer.

    ReplyDelete
  6. We have both manual and automatic driving instructors at our driving school in the UK. If you are interested in learning to drive, please get in touch.

    ReplyDelete
  7. When I execute the above script, the title is displayed as "webdriver" in the results, because there is another website running Manufacturer & Exporter of knitware Garments for seconds previous to the "learn-automation" webpage. What need I do to obtain the supplied page title?

    ReplyDelete
  8. We appreciate your wonderful site. I'm having trouble with IE10. best play to earn games usa Although it launches two browsers, the website does not load. Below is a trace of the mistake.

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. The dedication of Artisan coffee roasters to their craft has led to the emergence of a vibrant and diverse coffee culture, where consumers can explore a wide array of flavors and experiences. These roasters play a pivotal role in elevating coffee to an art form, making it more than just a beverage but a sensory journey worth savoring.

    ReplyDelete
  11. Dive into the world of DotNET with Tom DuPont, where coding meets commuting seamlessly with Glasgow Airport Taxi. Tom DuPont's expertise in the .NET domain is paralleled by his knack for choosing the most efficient modes of transportation,

    ReplyDelete
  12. The professional logo design London for consistently delivering top-notch, impactful designs. Your work not only enhances brand identities but also contributes to the city's reputation as a hub for design excellence

    ReplyDelete
  13. Your blog post on graphic designer is an absolute gem! As a fellow designer, I couldn't agree more with your insights into the intricate dance between creativity and functionality.

    ReplyDelete
  14. Whether you're a beginner looking to get started with InternetExplorerDriver or an experienced WebDriver user seeking to enhance your skills, this guide has something for everyone. Follow along as we explore the ins and outs of using the InternetExplorerDriver for WebDriver and empower yourself to build robust and reliable automation tests for Internet Explorer. Let's dive in!
    reckless driving lawyer emporia va

    ReplyDelete
  15. Planning your trip to or from Airport Taxi Edinburgh? Look no further! Edinburgh Airport Transfers services offer convenience, comfort, and reliability, making your journey smooth and stress-free. Here’s everything you need to know about booking and using taxis at Edinburgh Airport.

    ReplyDelete
  16. Building your dream project or renovating your space? Look no further! At BuildRight Supplies, we offer a wide range of premium buy construction material that cater to all your building needs. Our online store ensures you get the best products delivered right to your doorstep, making your ducting material online process smoother and more efficient.

    ReplyDelete

Real Time Web Analytics