“IEDriverServer does not exist” error during running Selenium test with C# in Windows 7

北城余情 提交于 2019-11-27 01:16:52

问题


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

.

回答1:


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




回答2:


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.




回答3:


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
        }
    }
}



回答4:


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




回答5:


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]




回答6:


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();
    }
} }



回答7:


      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;
   }


来源:https://stackoverflow.com/questions/11010317/iedriverserver-does-not-exist-error-during-running-selenium-test-with-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!