我试图让selenium网格第一次工作。
在设置中我有以下
Driver = new ChromeDriver(AppDomain.CurrentDomain.BaseDirectory + "../../../Drivers");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities = DesiredCapabilities.Chrome();
capabilities.SetCapability(CapabilityType.BrowserName, "chrome");
capabilities.SetCapability(CapabilityType.Platform, new Platform(PlatformType.Windows));
Driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capabilities);
这是在c#中使用XUNIT并使用resharper执行。
我在visual studio中收到错误
OpenQA.Selenium.WebDriverException
Unexpected error.
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 MoneyUITests.Methods.General.StartBrowserDriver() in
C:\Projects\Money_AT\MoneyUITests\Methods\General.cs:line 276
at MoneyUITests.Tests.Navigation.NavigationExecuteTests..ctor() in
C:\Projects\XXXX\XXXX\Tests\Navigation\NavigationTests.cs:line
36
在控制台中,我收到以下错误
2017-11-06 17:08:35.821:WARN:osjs.HttpChannel:qtp22982090-131:
/wd/hub/session
java.io.IOException: org.openqa.grid.common.exception.GridException: Cannot
extract a capabilities from the request: {"desiredCapabilities":{"browserName":"chrome","version":"","platform":"WINDOWS","javascriptEnabled":true},"capabilities":{"firstMatch":[{"browserName":"chrome","javascriptEnabled":true}]}}
at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:135)
和
Caused by: org.openqa.grid.common.exception.GridException: Cannot extract a capabilities from the request: {"desiredCapabilities":{"browserName":"chrome","version":"","platform":"WINDOWS","javascriptEnabled":true},"capabilities":{"firstMatch":[{"browserName":"chrome","javascriptEnabled":true}]}}
和
Caused by:java.lang.IllegalArgumentException: Illegal key values seen in w3c capabilities: [javascriptEnabled]
这是我第一次尝试使用硒网格,任何指南或提示都将非常受欢迎。
我遵循了本指南 - https://seleniumautomation84.wordpress.com/2014/08/06/selenium-grid-fundamentals-implemented-in-c/
提前致谢
答案 0 :(得分:1)
我发现了这个
https://github.com/SeleniumHQ/selenium/issues/4461
将selenium更新为3.7.0后,我不再收到此错误。
显然,Selenium Grid 2和Selenium 3.4 / 5存在问题,因此更新NuGet包的最新版本将解决此问题。