oba*_*lis 10 c# selenium selenium-grid remotewebdriver
我有一个使用Selenium.WebDriver v3.4.0的示例UI测试项目.
当我针对本地驱动程序运行测试时,一切正常,但我想使用Selenium Grid 2来完成工作.
一旦我尝试实例化一个新的RemoteWebDriver,我就会得到一个细节很少的异常.
Driver = new RemoteWebDriver(new Uri(GridUrl), Capabilities);
Run Code Online (Sandbox Code Playgroud)
注意:GridUrl是" http:// localhost:4444/wd/hub "
使用StackTrace引发System.InvalidOperationException,如下所示:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(Uri remoteAddress, ICapabilities desiredCapabilities)
at xxxx.Ui.Tests.SeleniumTests.TestInitialize() in C:\Users\xxxx\Documents\Visual Studio 2015\Projects\xxxx.Ui.Tests\xxxx.Tests\PersonTests.cs:line 38
Run Code Online (Sandbox Code Playgroud)
我在本地运行的集线器v3.4.0具有以下配置:
{
"port": 4444,
"newSessionWaitTimeout": -1,
"servlets" : [],
"withoutServlets": [],
"custom": {},
"capabilityMatcher":"org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"cleanUpCycle": 5000,
"role": "hub",
"debug": false,
"browserTimeout": 0,
"timeout": 1800
}
Run Code Online (Sandbox Code Playgroud)
Hub始于:
java -jar selenium-server-standalone-3.4.0.jar -role hub
我尝试了许多节点(chromedriver.exe,IEDriverServer.exe和geckodrvier.exe).这些都不适用于RemoteWebDriver.所有这些都在一个已添加到我的系统PATH变量的目录中.
{
"capabilities":
[
{
"browserName": "chrome",
"maxInstances": 5,
"seleniumProtocol": "WebDriver"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 5,
"port": 5556,
"register": true,
"registerCycle": 5000,
"hub": "http://localhost:4444",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets" : [],
"withoutServlets": [],
"custom": {}
}
Run Code Online (Sandbox Code Playgroud)
节点开始于:
java -jar selenium-server-standalone-3.4.0.jar -role node -nodeConfig chromeNodeConfig.json
除了不同的浏览器名称和端口之外,其他节点配置大致相同.
我无法从异常中得到很多.这是我的驱动程序的版本问题吗?我已经尝试自定义DesiredCapabilities以确保我匹配节点配置中的那些.所有这一切看起来都很好.
根据要求,我正在添加一些关于我如何尝试启动浏览器的细节.没有一个浏览器使用RemoteWebDriver,而它们使用本地驱动程序.显示Chrome示例 - 每个之间的区别仅在于我传递给基类构造函数的功能.
在我的测试课上
[TestClass]
public class PersonTests : PersonTestBase
{
public PersonTests()
: base(DesiredCapabilities.Chrome())
{
}
[TestCategory("Chrome")]
[TestMethod]
public void Chrome_ShouldCreatePlacement()
{
this.ShouldCreatePerson();
}
}
Run Code Online (Sandbox Code Playgroud)
在我的基类中,我正在做以下事情
public abstract class PersonTestBase
{
protected IWebDriver Driver;
protected ICapabilities Capabilities;
protected string TargetUrl;
protected string GridUrl;
protected PersonTests(ICapabilities capabilities)
{
this.Capabilities = capabilities;
}
[TestInitialize]
public void TestInitialize()
{
TargetUrl = "http://urlOfMyWebsite";
GridUrl = "http://localhost:4444/wd/hub"
Driver = new RemoteWebDriver(new Uri(GridUrl), Capabilities);
}
[TestCleanup]
public void TestCleanup()
{
Driver.Quit();
}
protected void ShouldCreatePerson()
{
Driver.Navigate().GoToUrl(TargetUrl);
//rest of test code ommitted
}
}
Run Code Online (Sandbox Code Playgroud)
Ste*_*der 11
降级到3.3.0,直到此问题得到解决,并且可以使用新版本的Selenium Standalone Server(推荐的解决方案)
要么
go //dotnet:release注意:此变通办法不解决任何事情!它忽略了导致失败的硒网格代码.
另请注意:请注意升级到Selenium 3.4可能还需要升级Web驱动程序
| 归档时间: |
|
| 查看次数: |
7012 次 |
| 最近记录: |