簡體   English   中英

如何設置Selenium Grid以在C#中運行InternetExplorerDriver

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

我目前正在努力設置Selenium Grid來執行用C#編寫的Selenium Webdriver Test。

WebDriver測試位於我的機器上。

我在VM中安裝了RC Standalone。

使用以下代碼時

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

測試在VM中運行良好(啟動了firefox,並按預期執行了測試)

問題是當我嘗試使用InternetExplorer時

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)下載InternetWebDriverServer.exe並將其安裝在VM(不是測試所在的本地計算機)中C:\\ Selenium \\ IEDriver(此C:是VM之一)

3-使用以下命令行在VM中配置RC網格:

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

運行測試時,出現以下錯誤

驅動程序可執行文件的路徑必須由webdriver.ie.driver系統屬性設置。

NB:使用以下命令在我的本地計算機上運行測試完全正常

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

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

該錯誤確切說明了您缺少的內容。

錯誤消息顯示:

驅動程序可執行文件的路徑必須由webdriver.ie.driver系統屬性設置

您正在設置webdriver.internetexplorer.driver 您需要設置webdriver.ie.driver

vs internetexplorer

這是我如何初始化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");
        }

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