C# 在C语言中,使用MbUnit框架和Selenium,使用Gallio和带Chrome驱动程序的powershell,并行测试失败-所有测试都失败

C# 在C语言中,使用MbUnit框架和Selenium,使用Gallio和带Chrome驱动程序的powershell,并行测试失败-所有测试都失败,c#,powershell,selenium,parallel-processing,automated-tests,C#,Powershell,Selenium,Parallel Processing,Automated Tests,该测试解决方案有两个项目——一个测试项目包含从基类继承的测试方法,基类详细编写了测试步骤,另一个项目是类库项目,其中包含常用方法和测试的实际步骤 使用此解决方案测试数据输入页面 问题 当我使用Selenium Grid并行执行测试时,所有测试都失败了——它打开了Chrome浏览器,然后什么也没有打开 测试报告说服务器超时了 当我按顺序运行测试时,它们都在没有Selenium网格的情况下通过 我到目前为止所做的: 使用Selenium Grid 2 1.1。要启动具有管理员访问权限的集线器打开命令

该测试解决方案有两个项目——一个测试项目包含从基类继承的测试方法,基类详细编写了测试步骤,另一个项目是类库项目,其中包含常用方法和测试的实际步骤

使用此解决方案测试数据输入页面

问题

当我使用Selenium Grid并行执行测试时,所有测试都失败了——它打开了Chrome浏览器,然后什么也没有打开

测试报告说服务器超时了

当我按顺序运行测试时,它们都在没有Selenium网格的情况下通过

我到目前为止所做的:

使用Selenium Grid 2 1.1。要启动具有管理员访问权限的集线器打开命令窗口,并在selenium目录中运行以下命令:

    java -jar selenium-server-standalone-2.5.0.jar -role hub
    java -jar selenium-server-standalone-2.5.0.jar -Dwebdriver.chrome.driver=\chromedriver.exe -role wd -hub http://4444/grid/register> 
1.2。使用管理员权限打开命令窗口的另一个实例,并在selenium目录中运行以下命令:

    java -jar selenium-server-standalone-2.5.0.jar -role hub
    java -jar selenium-server-standalone-2.5.0.jar -Dwebdriver.chrome.driver=\chromedriver.exe -role wd -hub http://4444/grid/register> 
2.在powershell中运行以下测试:

    PS>run-gallio test.dll
3.使用chrome驱动程序

    DesiredCapabilities capability = DesiredCapabilities.Chrome();
    capability.SetCapability(CapabilityType.BrowserName, "chrome");
    driver = new RemoteWebDriver(capability);
4.在assemblyinfo.cs的主测试项目中,添加了以下属性:

    [assembly: DegreeOfParallelism(4)]
    [assembly: Parallelizable(TestScope.All)]
5.每个类都有可并行化的属性,每个测试方法都有可并行化的属性

我试过的一些

使用DesiredCapabilities设置浏览器二进制位置

DesiredCapabilities - capabilities.SetCapability("chrome.binary",this.binaryLocation); 
这对我不起作用

在调用hub命令时在中设置chrome驱动程序 这会打开chrome浏览器,但之后什么也不会打开

我们也看到了这一点:

也尝试了多线程,但使用ChromeDriver代替RemoteWebDriver不起作用

我现在犯了一个错误

问题可能是什么

我可以在Selenium网格中尝试什么?如蒙指导,不胜感激

无法从selenium或C切换到其他任何东西。多谢各位

编辑: 几天后,使用Selenium-server-2.41.0,现在收到以下超时错误消息

    OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://127.0.0.1:4444/wd/hub/session/fdb51889-b9b7-4e97-beea-44dcf9637b0c/element/0/value timed out after 60 seconds. ---> System.Net.WebException: The operation has timed out  
为chrome调用remotedriver时增加了超时范围 DesiredCapabilities=DesiredCapabilities.Chrome; 驱动程序=新的RemoteWebDrivercapability; driver.Manage.Timeouts.ImplicitlyWaitTimeSpan.fromsseconds120

这不起作用。有什么建议吗

编辑 答:设法解决了问题-页面上有错误,并且由于我这边的网络问题-页面没有完全加载,脚本将搜索元素。修正了这个-谢谢丹尼尔和法兹

应该是:

[assembly: DegreeOfParallelism(2)]
[assembly:Parallelizable(TestScope.All)]
我在管理最大会话和最大实例时遇到一些问题。因此,在运行节点时,请按照如下所示进行标记

java -Dwebdriver.chrome.driver="C:\ChromeDriver\chromedriver.exe" -jar selenium-server-standalone-2.42.2.jar -role node -hub http://localhost:4444/grid/register -port 5555 -browser "browserName=chrome,maxSession=1,maxInstances=1,platform=WINDOWS,ensureCleanSession=true"

检查你的防火墙。这一行告诉您问题:System.Net.Sockets.SocketException:无法建立连接,因为目标计算机在1.2的命令中主动拒绝了4444,您正在使用http://4444....typo?Definitely 需要首先解决之前评论中的问题。同样使用最新的,2.5.0版本是古老的。谢谢Daniel Mann,我会看看这一点,Arran-在1.2命令中,它应该是本地主机,但不能在本文中写出来,Faiz-谢谢你-将使用selenium服务器2.41.0。再次感谢。Faiz-下载了您列出的selenium服务器版本,它似乎可以工作。不过还是在检查。谢谢。谢谢你们,克里希纳和塞皮顿。这就是我在assemblyInfo.cs中的内容,但它仍然一次运行一个。我还有[TestClass][Parallelizable]