C# Selenium 3.6 & Chrome throws error "W3C payload contained keys that do not comply with the spec: [chrome.switches]"
Meta -
OS: Windows 7
Selenium Version:
Selenium standalone server 3.6.0, selenium c# bindings 3.6.0, chrome driver 2.3.3
Browser:
Google Chrome 62.0.3202
Browser Version: 62.0.3202
Expected Behavior -
Browser opens and executes scripts
Actual Behavior -
**Exception **
Exception on Visual studio: Result Message: System.InvalidOperationException : W3C payload contained keys that do not comply with the spec: [chrome.switches]
StandAlone server log 16:25:43.276 INFO - Selenium Server is up and running 2017-10-23 16:25:50.865:INFO:osjshC.ROOT:qtp1227229563-12: org.openqa.selenium.r emote.server.WebDriverServlet-26be92ad: Initialising WebDriverServlet 16:25:50.903 INFO - Binding default provider to: org.openqa.selenium.chrome.Chro meDriverService 16:25:50.904 INFO - Found handler: org.openqa.selenium.remote.server.commandhand ler.BeginSession@3dad4b31 16:25:50.907 INFO - /session: Executing POST on /session (handler: BeginSession) Only local connections are allowed.
Steps to reproduce -
Set up a selenium project with Chrome browser with versions as mentioned above and and run the following script
[TestMethod]
public void TestMethod()
{
DesiredCapabilities capt = new DesiredCapabilities();
capt.SetCapability(CapabilityType.BrowserName, "chrome");
capt.SetCapability("chrome.switches", "--disable-extensions");
IWebDriver wd = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capt);
wd.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
wd.Manage().Window.Maximize();
wd.Navigate().GoToUrl("www.yahoo.com");
wd.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
wd.Quit();
}
NOTE: We updated from Selenium 2.53.1 to Selenium 3.6 now. All of this was working fine before.
I have similar issue but in Python.
I set user-agent and I get the same exception.
from selenium.webdriver.chrome.options import Options
opts = Options()
mobile_user_agent = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.33 Mobile Safari/537.36"
opts.add_argument("user-agent={}".format(self.mobile_user_agent))
webdriver.Remote(command_executor="http://selenium:4444/wd/hub", desired_capabilities=opts.to_capabilities())
Java traceback:
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.commandhandler.BeginSession.execute (BeginSession.java:71)
at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$0 (WebDriverServlet.java:232)
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)
Selenium 3.3.1 works well tho.
I have a similar issue when using selenium hub for Appium: https://github.com/appium/appium-dotnet-driver/issues/194
I've solved that by sync versions of selenium in python and selenium docker image.
Updating selenium to the 3.7.1 release and the client driver (nuGet) 3.7 seems to solve my issue. Be wary because the latest firefox might stop working: https://github.com/SeleniumHQ/selenium/issues/5008
I use 3.5.3. 3.7 was broken even more.
From the Selenium side, and based on some comments, this should have been fixed. Please feel free to open a new issue in case this is still present in the latest versions of Selenium WebDriver, browser driver, and browser.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.