简体   繁体   English

如何设置Selenium Grid以在C#中运行InternetExplorerDriver

[英]How to set up Selenium Grid to run InternetExplorerDriver in C#

I'm currently struggling to set up Selenium Grid to execute Selenium Webdriver Tests written in C#. 我目前正在努力设置Selenium Grid来执行用C#编写的Selenium Webdriver Test。

The WebDriver Tests are located on my my machine. WebDriver测试位于我的机器上。

I installed the RC Standalone in my VM. 我在VM中安装了RC Standalone。

When using the following code 使用以下代码时

public static IWebDriver Instance { get; set; }
Instance = new RemoteWebDriver(new Uri("http://192.xxx.x.xxx:4444/wd/hub"), DesiredCapabilities.Firefox());

The tests run fine in the VM (firefox is launched and the tests are exceuted as expected) 测试在VM中运行良好(启动了firefox,并按预期执行了测试)

The issue is when I am trying to use InternetExplorer 问题是当我尝试使用InternetExplorer时

1) I changed the DesiredCapabilities to Internet Explorer in my test: 1)我在测试中将DesiredCapabilities更改为Internet Explorer:

public static IWebDriver Instance { get; set; }

Instance = new RemoteWebDriver(new Uri("192.xxx.x.xxx:4444/wd/hub"), DesiredCapabilities.InternetExplorer());

2) Downloaded the InternetWebDriverServer.exe and Install it in the VM (not my local machine where the tests reside) C:\\Selenium\\IEDriver (this C: is the VM one) 2)下载InternetWebDriverServer.exe并将其安装在VM(不是测试所在的本地计算机)中C:\\ Selenium \\ IEDriver(此C:是VM之一)

3 - Configured the RC Grid in the VM with the following command line: 3-使用以下命令行在VM中配置RC网格:

java -jar C:\Selenium\RC\selenium-server-standalone-2.44.0.j
ar -Dwebdriver.internetexplorer.driver=C:\Selenium\IEDriver\IEDriverServer.exe

When I run the tests, I get the following error 运行测试时,出现以下错误

The path to the to the driver executable must be set by the webdriver.ie.driver system property. 驱动程序可执行文件的路径必须由webdriver.ie.driver系统属性设置。

NB: The tests run perfectly fine on my local machine using NB:使用以下命令在我的本地计算机上运行测试完全正常

IEWebDriverServer.exe with the following code
public static IWebDriver Instance { get; set; }

Instance = new InternetExplorerDriver(@"C:\Libraries");

The error states exactly what you are missing. 该错误确切说明了您缺少的内容。

The error message says: 错误消息显示:

The path to the to the driver executable must be set by the webdriver.ie.driver system property 驱动程序可执行文件的路径必须由webdriver.ie.driver系统属性设置

You are setting webdriver.internetexplorer.driver . 您正在设置webdriver.internetexplorer.driver You need to set webdriver.ie.driver 您需要设置webdriver.ie.driver

( ie vs internetexplorer ) vs internetexplorer

Here is an example of how I init my driver for IE11 这是我如何初始化IE11驱动程序的示例

public void Initialize()
        {
            String webURL = "http://www.google.com";
            String myHub = "http://QA_HUB:4444/wd/hub";
            var caps = DesiredCapabilities.InternetExplorer();
            caps.SetCapability(CapabilityType.BrowserName, "internet explorer");
            caps.SetCapability(CapabilityType.Platform, "VISTA");
            driver = new RemoteWebDriver(new Uri(myHub), caps, TimeSpan.FromSeconds(600));
            driver.Navigate().GoToUrl(webURL);
            Console.WriteLine("Opened Browser & Navigated To URL");
        }

The IEDriverServer.exe is saved in C:\\Program Files\\Java\\jdk1.8.0_77\\bin and ensure that you have the folder pointed in System Settings Path and not the actual exe. IEDriverServer.exe保存在C:\\ Program Files \\ Java \\ jdk1.8.0_77 \\ bin中,并确保您拥有系统设置路径中指向的文件夹,而不是实际的exe。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM