27

I'm working on Automation framework using WebDriver with C#. Its working fine with Firefox but not with IE.

I am getting the following error:

IEDriverServer.exe does not exist-The file c:\users\administrator\documents\visual studio 2010\projects\TestProject1\TestProject1\bin\Debug\IEDriverServer.exe does not exist. The driver can be downloaded at http://code.google.com/p/selenium/downloads/list

I am using IE 9 and Windows 7.

IWebDriver driver = new InternetExplorerDriver();
driver.Navigate().GoToUrl("http://www.google.co.uk");
IWebElement queryBox = driver.FindElement(By.Name("q"));
queryBox.SendKeys("The Automated Tester");
queryBox.SendKeys(Keys.ArrowDown);
queryBox.Submit();

See also this screenshot.

j0k
  • 22,600
  • 28
  • 79
  • 90
Pat
  • 727
  • 1
  • 10
  • 22

7 Answers7

22

The IEDriverServer.exe (as well as ChromeDriver.exe) can be downloaded from:

http://selenium-release.storage.googleapis.com/index.html.

To get these to work with your Selenium tests, include the .exe in your test project, and set its properties to 'Copy Always'.

NOTE: You'll have to adjust the Add File dialog to display .exe files.

Doing this will resolve the error.

MIWMIB
  • 1,407
  • 1
  • 14
  • 24
Peter Bernier
  • 8,038
  • 6
  • 38
  • 53
16

Here's a simple C# example of how to call the InternetExplorerDriver using the IEDriverServer.exe.

Refactor according to your needs.

Note: the use of driver.Quit() which ensures that the IEDriverServer.exe process is closed, after the test has finished.

using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.IE;

namespace SeleniumTest
{
    [TestClass]
    public class IEDriverTest
    {
        private const string URL = "http://url";
        private const string IE_DRIVER_PATH = @"C:\PathTo\IEDriverServer.exe";

        [TestMethod]
        public void Test()
        {
            var options = new InternetExplorerOptions()
            {
                InitialBrowserUrl = URL,
                IntroduceInstabilityByIgnoringProtectedModeSettings = true
            };
            var driver = new InternetExplorerDriver(IE_DRIVER_PATH, options);
            driver.Navigate();
            driver.Close(); // closes browser
            driver.Quit(); // closes IEDriverServer process
        }
    }
}
Ralph Willgoss
  • 11,750
  • 4
  • 64
  • 67
13

Per Jim Evans (who works on IEDriverServer)

The .NET bindings don't scan the %PATH% environment variable for the executable. That means for the .NET bindings only, the IEDriverServer.exe is expected to either be found in the same directory as the .NET bindings assembly, or you must specify the directory where it can be found in the constructor to the InternetExplorerDriver class.

Failure to do one of these things (or to set the UseInternalServer property in the InternetExplorerOptions class) will cause the .NET IE driver implementation to throw an exception. This is strictly by design, as we want people to begin using the standalone IEDriverServer.exe, and the ability to use an "internal" or "legacy" version of the server will be removed in a future release.

https://groups.google.com/forum/?fromgroups#!topic/webdriver/EvTyEPYchxE

Community
  • 1
  • 1
A.J
  • 4,929
  • 2
  • 27
  • 36
  • Can u help me with the code sample how to bind IEDriverServer.exe using c#.Is it this way System.Environment.SetEnvironmentVariable("webdriver.ie.driver", "D://Software//IEDriverServer.exe"); IWebDriver driver = new InternetExplorerDriver(); – Pat Jun 14 '12 at 06:00
  • I haven't worked in C# bindings. However one way to resolve this outside code is, to pass this variable while starting selenium jar. Like java -jar selenium-server.jar -Dwebdriver.ie.driver="D://Software//IEDriverServer.exe" – A.J Jun 14 '12 at 13:25
  • 1
    There are now unofficial NuGet packages for [Chrome](https://www.nuget.org/packages/Selenium.WebDriver.ChromeDriver/) and [IE](https://www.nuget.org/packages/Selenium.WebDriver.IEDriver/); these add the drivers to your packages directory, add links in your test project to them, & set to "copy if newer." Then just call the constructor overloads, passing "." for the current directory *(due to the %PATH% issue above)*; ex: `ScenarioContext.Current["browser"] = new ChromeDriver(".");` With [NCrunch](http://www.ncrunch.net/) I didn't need to configure it to copy the files either. – Damon Nov 25 '14 at 18:55
  • This worked for me: `java -jar -Dwebdriver.ie.driver="C:\IEDriverServer.exe" selenium-server-standalone-3.0.1.jar -role node -hub http://localhost:4444/grid/register`. Please note that `-Dwebdriver.ie.driver` comes immediately after `java -jar`. – kkuilla Mar 22 '17 at 11:59
1

If you're working with Visual Studio and C# I've updated my NareshScaler nuget package to install IEDriverServer, ChromeDriver etc automatically, meaning you can get up and running quicker.

http://nuget.org/packages/NareshScaler

Iain Hunter
  • 4,319
  • 1
  • 27
  • 13
1

Code for WebDriver using java to run with IE. I believe this concept might be helpful for you using C#:

DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);      
File file = new File("C:\\Program Files\\Internet Explorer\\iexplore.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
driver = new InternetExplorerDriver(capabilities);

If above code doesn't work use the following instead of "File file = new File("C:\Program Files\Internet Explorer\iexplore.exe");":

File file = new File("F:\\Ripon\\IEDriverServer_Win32_2.25.2\\IEDriverServer.exe");

[Note: The version of IEDriverServer and Windows (32 or 64 bit) may vary individual to individual]

Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
1

Give path only till folder where Internetexplorer.exe is located.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.IE;
using System.IO;

namespace Automation
  {
    class To_Run_IE
     {
        static void Main(string[] args)
        {
         //Keep Internetexplorer.exe in "D:\Automation\32\Internetexplorer.exe"
          IWebDriver driver = new InternetExplorerDriver(@"D:\Automation\32\"); \\Give path till the exe folder
         //IWebDriver driver = new Firefoxdriver()
       driver.Navigate().GoToUrl("http://www.google.com/");
       driver.Manage().Window.Maximize();         
       IWebElement query = driver.FindElement(By.Name("q"));
       query.SendKeys("Cheese");        
       query.Submit();         
       System.Console.WriteLine("Page title is: " + driver.Title);
       driver.Quit();
    }
} }
  • Hi Nithin and welcome to the site. Could you consider expanding on your answer a little to make it more complete? There's a guide to good answers [here](http://stackoverflow.com/help/how-to-answer) - generally we prefer a little more explanation than a one-line answer. – starsplusplus Feb 26 '14 at 16:18
0
      public IWebDriver IEWebDriver()
    {
        var options = new InternetExplorerOptions();
        options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
        webDriver = new   InternetExplorerDriver(ConfigurationSettings.AppSettings["IDEServerPath"].ToString(), options);//Path of ur IE WebDriver,Here I stored it in a AppConfig File
        return webDriver;
   }
Pat
  • 727
  • 1
  • 10
  • 22