26

Estoy trabajando en el marco de automatización con WebDriver con C#. Funciona bien con Firefox pero no con IE.Error de "IEDriverServer no existe" durante la ejecución de la prueba de Selenium con C# en Windows 7

estoy consiguiendo el error siguiente:

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

estoy usando IE 9 y 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(); 

Véase también this screenshot.

+0

Simplemente cópielo en el directorio de salida Bin \ Debug si no está allí. –

Respuesta

11

por Jim Evans (que trabaja en 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

+0

¿Puede ayudarme con el ejemplo de código de cómo enlazar IEDriverServer.exe utilizando C#? Es así System.Environment.SetEnvironmentVariable ("webdriver.ie.driver", "D: //Software//IEDriverServer.exe") ; IWebDriver driver = new InternetExplorerDriver(); – Pat

+0

No he trabajado en enlaces C#. Sin embargo, una forma de resolver este código externo es pasar esta variable mientras se inicia el jar de selenio. Como java -jar selenium-server.jar -Dwebdriver.ie.driver = "D: //Software//IEDriverServer.exe" –

+0

Ahora hay paquetes no oficiales de NuGet para [Chrome] (https://www.nuget.org/ packages/Selenium.WebDriver.ChromeDriver /) y [IE] (https://www.nuget.org/packages/Selenium.WebDriver.IEDriver/); estos agregan los controladores a su directorio de paquetes, agregan enlaces en su proyecto de prueba y los configura en "copiar si son más nuevos". Luego solo llama a las sobrecargas del constructor, pasando "." para el directorio actual * (debido al problema de% PATH% anterior) *; ex: 'ScenarioContext.Current [" browser "] = new ChromeDriver (". ");' Con [NCrunch] (http://www.ncrunch.net/) No necesité configurarlo para copiar los archivos . – Damon

1

Si está trabajando con Visual Studio y C# He actualizado mi paquete Nuget NareshScaler instalar IEDriverServer, etc automáticamente ChromeDriver , lo que significa que puedes ponerte en marcha más rápido.

http://nuget.org/packages/NareshScaler

+0

Puede ayudarme a hacerlo sin usar el paquete NareshScaler usando el código C# – Pat

16

Aquí es un simple ejemplo de C# de cómo llamar la InternetExplorerDriver utilizando el IEDriverServer.exe.

Refactor de acuerdo a sus necesidades.

Nota: el uso dedriver.Quit() que asegura que el proceso de IEDriverServer.exe está cerrada, después de la prueba ha terminado.

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

Gracias Ralp ... Funciona bien ahora. – Pat

20

El IEDriverServer.exe (así como ChromeDriver.exe) se puede descargar desde:

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

Para que funcionen con sus pruebas de Selenium, incluya el .exe en su proyecto de prueba y establezca sus propiedades en 'Copiar siempre'.

NOTA: Deberá ajustar el cuadro de diálogo Agregar archivo para mostrar los archivos .exe.

Hacer esto resolverá el error.

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

Código para WebDriver usando java para ejecutar con IE. Creo que este concepto podría ser útil para usted usando 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); 

Si el código anterior no funciona utilice el siguiente lugar de "archivo del archivo = new File (" C: \ Archivos de programa \ Internet Explorer \ iexplore. exe ");":

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

[Nota: La versión de IEDriverServer y Windows (32 o 64 bits) puede variar individuo a individuo]

+0

He descargado "IEDriverServer_Win32_2.31.0.zip". De acuerdo con tu guía, está funcionando bien. Gracias Ripon –

+0

@ user2027659: Es un placer –

1

Dale un camino sólo hasta la carpeta donde se encuentra Internetexplorer.exe.

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

Hola Nithin y bienvenido al sitio. ¿Podría considerar expandir su respuesta un poco para hacerlo más completo? Hay una guía de buenas respuestas [aquí] (http://stackoverflow.com/help/how-to-answer). Por lo general, preferimos un poco más de explicación que una respuesta de una línea. – starsplusplus

Cuestiones relacionadas