Selenium: C# selenium 3.5 grid configuration throws W3C payload IllegalArgumentException with Chrome browser

Created on 11 Aug 2017  路  15Comments  路  Source: SeleniumHQ/selenium

Meta -

OS: Hub-Win10 or Win7, Node-Win8_1 or Win7
Selenium Version: selenium standalone jar version 3.5, selenium c# binding version 3.5, chrome driver server version 2.31
Browser: Chrome
Browser Version: 60.0.3112.90 (Official Build) (64-bit)

Expected Behavior -

Browser opens up

Actual Behavior -

Exception (from the Hub console):

2017-08-11 14:54:09.443:WARN:osjs.HttpChannel:qtp1795799895-13: /wd/hub/session
java.io.IOException: org.openqa.grid.common.exception.GridException: Cannot extract a capabilities from the request: {"desiredCapabilities":{"browserName":"chrome","version":"","platform":"WIN8_1","javascriptEnabled":true},"capabilities":{"firstMatch":[{"browserName":"chrome","javascriptEnabled":true}]}}
        at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:135)
        at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:68)
.
.
<!鈥擲ee attached log file for complete exception verbiage -->
.
.
Caused by:
java.lang.IllegalArgumentException: W3C payload contained keys that do not comply with the spec: [javascriptEnabled]
        at org.openqa.selenium.remote.server.NewSessionPayload.validateSpecCompliance(NewSessionPayload.java:167)
        at java.util.stream.ReferencePipeline$11$1.accept(Unknown Source)
        at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
        at java.util.LinkedList$LLSpliterator.forEachRemaining(Unknown Source)
        at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source)
        at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
        at java.util.stream.ReferencePipeline.collect(Unknown Source)
        at org.openqa.selenium.remote.server.NewSessionPayload.validate(NewSessionPayload.java:152)
        at org.openqa.selenium.remote.server.NewSessionPayload.<init>(NewSessionPayload.java:134)
        at org.openqa.grid.web.servlet.handler.WebDriverRequest.extractDesiredCapability(WebDriverRequest.java:70)
        at org.openqa.grid.web.servlet.handler.SeleniumBasedRequest.<init>(SeleniumBasedRequest.java:102)
        at org.openqa.grid.web.servlet.handler.WebDriverRequest.<init>(WebDriverRequest.java:40)
        at org.openqa.grid.web.servlet.handler.WebDriverRequestFactory.createFromRequest(WebDriverRequestFactory.java:30)
.
.
<!鈥擲ee attached log file for complete exception verbiage -->

Steps to reproduce -

Set up a selenium grid configuration with the node machine having chrome browser i.e. run the following:
Hub: java -jar "C:\SeleniumDrivers\selenium-server-standalone-3.5.0.jar" -role hub
Node: java -jar "C:\SeleniumDrivers\selenium-server-standalone-3.5.0.jar" -role node -host xxx.xxx.xxx.xxx -port 5555 -hub http:// xxx.xxx.xxx.xxx:4444/grid/register -browser "browserName=internet explorer,version=11.0" -browser "browserName=chrome" -browser "browserName=firefox"

Try running the following lines with selenium c# binding 3.5

DesiredCapabilities capability = DesiredCapabilities.Chrome();
capability.SetCapability(CapabilityType.Platform, "WIN8_1");
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capability, TimeSpan.FromSeconds(210));
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl("http://google.com");

consoleException.txt

C-dotnet R-awaiting answer

Most helpful comment

Fixed in 4ce57f6. Released as 3.5.1 of the .NET bindings.

All 15 comments

What happens if, as has been recommended for the .NET bindings for more than two years, you use the ChromeOptions class (calling its ToCapabilities() method) instead of using DesiredCapabilities directly? I suspect there will be no change in behavior, but that's the mechanism you should be using for .NET in the first place, and if it works, would be the correct approach.

Ok. So as per your suggestion, I am running the following:

ChromeOptions options = new ChromeOptions();
options.AddArgument("--start-maximized");
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), options.ToCapabilities(), TimeSpan.FromSeconds(210));
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
driver.Navigate().GoToUrl("http://google.com");

and still got the same issue/error.

One more potential workaround. What happens if you add -enablepassthrough to your hub command line?

I might be missing something here, but -enablepassthrough does not seem to be a valid command line parameter to selenium standalone server jar

Never mind. In the run-up to 3.5, there was an -enablePassThrough mode. However, in the actual release, it seems that its enabled by default.

I'm running into the same issue with exact same configurations of hub and node along with the stand alone server and C# client bindings.

The irony here is that using current sources, I suspect the issue doesn't occur. There has been some cleanup of the .NET code post-3.5 which I think has removed the problem. I was planning on taking a much-needed day off from code today, but I guess that's not happening now.

Fixed in 4ce57f6. Released as 3.5.1 of the .NET bindings.

Thank You. Tested it and works great.

Is it possible to update the docker images to selenium 3.5.2?

Hello, I'm currently getting this same error using C# bindings, connecting to a Selenium Standalone Server (v 3.5.3) with a few Appium nodes. I am new to using/setting up a Selenium Grid, so I'm sure I'm just missing something. Any help would be appreciated. Thank you.

I'm running 3.6; this has the same prolem as mentioned as soon as I include

var options = new InternetExplorerOptions();
options.UnexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Dismiss;

it starts failing (using DesiredCapabilities)

Hey guys, just ran into this, but slightly different case:

I user Docker version of selenium in version 3.5 and I get this:

WebDriverException: Message: W3C payload contained keys that do not comply with the spec: [chromeOptions, platform, version]
Stacktrace:
    at org.openqa.selenium.remote.server.NewSessionPayload.validateSpecCompliance (NewSessionPayload.java:179)
    at org.openqa.selenium.remote.server.NewSessionPayload.validate (NewSessionPayload.java:157)
    at org.openqa.selenium.remote.server.NewSessionPayload.<init> (NewSessionPayload.java:146)
    at org.openqa.selenium.remote.server.BeginSession.execute (BeginSession.java:66)
    at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$0 (WebDriverServlet.java:231)
    at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
    at java.util.concurrent.FutureTask.run (FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
    at java.lang.Thread.run (Thread.java:748)

PIece of code that causes that in my codestack (the exception happends on the last line):

opts = Options()
opts.add_argument("user-agent={}".format(self.mobile_user_agent))

self.browser = webdriver.Remote(command_executor="http://selenium:4444/wd/hub", desired_capabilities=opts.to_capabilities())

I guess you guys updated version of Chrome and the option are just wrong or just python bindings are obsolete? Can you please show me the right direction?

Agree with @jsiegmund. With 3.6 update we notice the same problem

Hey Guys what was the fix if any to this?

I'm using

Grid Config :
HUB:
selenium-server-standalone-3.8.1
command line :

java -jar selenium-server-standalone-3.8.1.jar -role hub -hubConfig hubconfig.json

Config file:

{
"port": 8100,
"newSessionWaitTimeout": -1,
"servlets" : [],
"withoutServlets": [],
"custom": {},
"capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"registryClass": "org.openqa.grid.internal.DefaultGridRegistry",
"throwOnCapabilityNotPresent": true,
"cleanUpCycle": 5000,
"role": "hub",
"debug": false,
"browserTimeout": 0,
"timeout": 1800
}

Node:

ChromeDriver : v 2.34.522940
selenium-server-standalone-3.8.1

command line :
java -Dwebdriver.gecko.driver="pathtogecko\geckodriver.exe" -jar selenium-server-standalone-3.8.1.jar -role node -nodeConfig nodeconfig.json

Browsers:
Chrome : 63.0.3239.132
Config:

{
"capabilities":
[
{
"browserName": "firefox",
"marionette": true,
"maxInstances": 2,
"seleniumProtocol": "WebDriver"
},
{
"browserName": "chrome",
"maxInstances": 2,
"seleniumProtocol": "WebDriver"
}
],
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 5,
"port": 5555,
"register": true,
"registerCycle": 5000,
"hub": "http://10.24x.14x.xxx:8100",
"nodeStatusCheckTimeout": 5000,
"nodePolling": 5000,
"role": "node",
"unregisterIfStillDownAfter": 60000,
"downPollingLimit": 2,
"debug": false,
"servlets" : [],
"withoutServlets": [],
"custom": {}
}
Code:
Chrome:
try
{
ChromeOptions chromeoptions = new ChromeOptions();
chromeoptions.AddArgument("--start-maximized");
chromeoptions.AddArgument("incognito");
chromeoptions.AddUserProfilePreference("credentials_enable_service", false);
chromeoptions.AddUserProfilePreference("profile.password_manager_enabled", false);
_driver = new RemoteWebDriver(new Uri(hub_url),chromeoptions);
_driver.Manage().Cookies.DeleteAllCookies();
_driver.FileDetector = new LocalFileDetector();
}
catch (Exception e)
{
Console.Write(e.Message);
}

Errors

Chrome:

On the hub error appears.

java.lang.IllegalArgumentException: Illegal key values seen in w3c capabilities: [chromeOptions, javascriptEnabled]

Was this page helpful?
0 / 5 - 0 ratings