How to instantiate InternetExplorerDriver with Selenium WebDriver using C#
Asked Answered
S

5

9
new InternetExplorerDriver();

But I could see exception as below:

OpenQA.Selenium.DriverServiceNotFoundException was unhandled by user code
  HResult=-2146233088
  Message=The IEDriverServer.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at http://code.google.com/p/selenium/downloads/list.
  Source=WebDriver
  StackTrace:
       at OpenQA.Selenium.DriverService.FindDriverServiceExecutable(String executableName, Uri downloadUrl)
       at OpenQA.Selenium.IE.InternetExplorerDriverService.CreateDefaultService()
       at OpenQA.Selenium.IE.InternetExplorerDriver..ctor(InternetExplorerOptions options)
       at OpenQA.Selenium.IE.InternetExplorerDriver..ctor()
       at Accelrys.CommonTestFramework.WebActions.WebActionLibrary.CreateSeleniumDriver()
Starnes answered 6/3, 2013 at 12:14 Comment(0)
M
7

As the exception says, you need to download IEDriverServer either 32 or 64 bit depending on IE you have and make sure it is available in our path. That is when you type IEDriverServer.exe on command line it should be resolved. Try that

Microcopy answered 6/3, 2013 at 12:20 Comment(1)
Will try to execute on command prompt and let you know about it. Thanks in advanceStarnes
B
9

Add these lines to your code before creating the object.

   System.setProperty("webdriver.ie.driver", 
        "E:\\path where your IEDriverServer is located\\IEDriverServer.exe");

You can download IEDriverServer.exe file from here.

As you are using C# you can use the below code.

private const string IE_DRIVER_PATH = @"C:\PathTo\IEDriverServer";
var driver = new InternetExplorerDriver(IE_DRIVER_PATH, options);
Berneta answered 6/3, 2013 at 12:23 Comment(0)
M
7

As the exception says, you need to download IEDriverServer either 32 or 64 bit depending on IE you have and make sure it is available in our path. That is when you type IEDriverServer.exe on command line it should be resolved. Try that

Microcopy answered 6/3, 2013 at 12:20 Comment(1)
Will try to execute on command prompt and let you know about it. Thanks in advanceStarnes
J
4

You need to install IEDriverServer and make it part of your project.

This Post contains the download link and some additional information on making it part of your project.

Jam answered 6/3, 2013 at 13:8 Comment(1)
I've downloaded IEDriverServer and unzipped the same. Path of IEDriverServer.exe is appende in PATH environmental variable. Even after doing all these prerequisites things are not working as expected.Starnes
O
2

The .NET bindings don't scan the %PATH% environment variable for the executable.

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

Hence, it does not work to put IEDriverServer in the %PATH% for .NET.

Use the unofficial NuGet version with the IE-driver bundled (it is put in the Packages-dir and referenced from the test-project), or bundle it yourself with the project, and mark the exe as Copy if newer under preferences. Then add the relative path into the constructor of InternetExplorerDriver.

Ophthalmoscope answered 20/1, 2016 at 15:7 Comment(0)
V
0

You can pass in the path to the IEDriverServer in an overload of the constructor

namespace OpenQA.Selenium.IE
    //
    // Summary:
    //     Initializes a new instance of the OpenQA.Selenium.IE.InternetExplorerDriver class
    //     using the specified path to the directory containing IEDriverServer.exe.
    //
    // Parameters:
    //   internetExplorerDriverServerDirectory:
    //     The full path to the directory containing IEDriverServer.exe.
    public InternetExplorerDriver(string internetExplorerDriverServerDirectory);

so

new InternetExplorerDriver("..\.."); // if it was two folders up
Vassili answered 24/3, 2017 at 16:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.