selenium icon indicating copy to clipboard operation
selenium copied to clipboard

Unable to pass chrome options into remote webdriver

Open StephenDavidson opened this issue 11 years ago • 7 comments

Python 2.7 (Selenium 2.45 package) Ubuntu 14.04 Selenium Grid 2.45

I am currently running into an issue where I am unable to pass chrome options to the grid correctly. It appears to be due to a java casting error. It matches correctly but then cannot cast chrome options, even if left as an empty string. Other capabilities work fine though, and it works correctly if I remove chrome options.

Hub stacktrace:

12:47:46.784 INFO - Got a request to create a new session: Capabilities [{platform=ANY, javascriptEnabled=true, browserName=chrome, chromeOptions={args=[--use-fake-device-for-media-stream, --disable-user-media-security=true], extensions=[]}, version=}]
12:47:46.784 INFO - Available nodes: [host :http://172.17.42.1:5555]
12:47:46.784 INFO - Trying to create a new session on node host :http://172.17.42.1:5555
12:47:46.784 INFO - Trying to create a new session on test slot {seleniumProtocol=WebDriver, platform=LINUX, chrome_binary=/usr/bin/google-chrome, browserName=chrome, maxInstances=8, version=41}
12:47:46.785 ERROR - Error running the beforeSessionListener : java.util.HashMap cannot be cast to com.google.gson.JsonObject
java.lang.ClassCastException: java.util.HashMap cannot be cast to com.google.gson.JsonObject
    at org.openqa.grid.selenium.proxy.DefaultRemoteProxy.beforeSession(DefaultRemoteProxy.java:238)
    at org.openqa.grid.web.servlet.handler.RequestHandler.beforeSessionEvent(RequestHandler.java:169)
    at org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHandler.java:110)
    at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:83)
    at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:67)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.seleniumhq.jetty7.servlet.ServletHolder.handle(ServletHolder.java:565)
    at org.seleniumhq.jetty7.servlet.ServletHandler.doHandle(ServletHandler.java:479)
    at org.seleniumhq.jetty7.server.session.SessionHandler.doHandle(SessionHandler.java:225)
    at org.seleniumhq.jetty7.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
    at org.seleniumhq.jetty7.servlet.ServletHandler.doScope(ServletHandler.java:406)
    at org.seleniumhq.jetty7.server.session.SessionHandler.doScope(SessionHandler.java:186)
    at org.seleniumhq.jetty7.server.handler.ContextHandler.doScope(ContextHandler.java:965)
    at org.seleniumhq.jetty7.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
    at org.seleniumhq.jetty7.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
    at org.seleniumhq.jetty7.server.Server.handle(Server.java:349)
    at org.seleniumhq.jetty7.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452)
    at org.seleniumhq.jetty7.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:47)
    at org.seleniumhq.jetty7.server.AbstractHttpConnection.content(AbstractHttpConnection.java:894)
    at org.seleniumhq.jetty7.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:948)
    at org.seleniumhq.jetty7.http.HttpParser.parseNext(HttpParser.java:857)
    at org.seleniumhq.jetty7.http.HttpParser.parseAvailable(HttpParser.java:235)
    at org.seleniumhq.jetty7.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:66)
    at org.seleniumhq.jetty7.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:254)
    at org.seleniumhq.jetty7.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
    at org.seleniumhq.jetty7.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
    at java.lang.Thread.run(Thread.java:745)

Python Stacktrace:

WebDriverException: Message: Error forwarding the new session The listener threw an exception ( listener bug )
Stacktrace:
    at org.openqa.grid.web.servlet.handler.RequestHandler.process (RequestHandler.java:114)
    at org.openqa.grid.web.servlet.DriverServlet.process (DriverServlet.java:83)
    at org.openqa.grid.web.servlet.DriverServlet.doPost (DriverServlet.java:67)
    at javax.servlet.http.HttpServlet.service (HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service (HttpServlet.java:820)
    at org.seleniumhq.jetty7.servlet.ServletHolder.handle (ServletHolder.java:565)
    at org.seleniumhq.jetty7.servlet.ServletHandler.doHandle (ServletHandler.java:479)
    at org.seleniumhq.jetty7.server.session.SessionHandler.doHandle (SessionHandler.java:225)
    at org.seleniumhq.jetty7.server.handler.ContextHandler.doHandle (ContextHandler.java:1031)
    at org.seleniumhq.jetty7.servlet.ServletHandler.doScope (ServletHandler.java:406)
    at org.seleniumhq.jetty7.server.session.SessionHandler.doScope (SessionHandler.java:186)
    at org.seleniumhq.jetty7.server.handler.ContextHandler.doScope (ContextHandler.java:965)
    at org.seleniumhq.jetty7.server.handler.ScopedHandler.handle (ScopedHandler.java:117)
    at org.seleniumhq.jetty7.server.handler.HandlerWrapper.handle (HandlerWrapper.java:111)
    at org.seleniumhq.jetty7.server.Server.handle (Server.java:349)
    at org.seleniumhq.jetty7.server.AbstractHttpConnection.handleRequest (AbstractHttpConnection.java:452)
    at org.seleniumhq.jetty7.server.BlockingHttpConnection.handleRequest (BlockingHttpConnection.java:47)
    at org.seleniumhq.jetty7.server.AbstractHttpConnection.content (AbstractHttpConnection.java:894)
    at org.seleniumhq.jetty7.server.AbstractHttpConnection$RequestHandler.content (AbstractHttpConnection.java:948)
    at org.seleniumhq.jetty7.http.HttpParser.parseNext (HttpParser.java:857)
    at org.seleniumhq.jetty7.http.HttpParser.parseAvailable (HttpParser.java:235)
    at org.seleniumhq.jetty7.server.BlockingHttpConnection.handle (BlockingHttpConnection.java:66)
    at org.seleniumhq.jetty7.server.bio.SocketConnector$ConnectorEndPoint.run (SocketConnector.java:254)
    at org.seleniumhq.jetty7.util.thread.QueuedThreadPool.runJob (QueuedThreadPool.java:599)
    at org.seleniumhq.jetty7.util.thread.QueuedThreadPool$3.run (QueuedThreadPool.java:534)
    at java.lang.Thread.run (Thread.java:745)

StephenDavidson avatar Mar 25 '15 12:03 StephenDavidson

which chrome options are you trying to send? and which ones work fine? looks to me it's passing --use-fake-device-for-media-stream, --disable-user-media-security=true just fine

[C-py] [I-needs investigation?]

ddavison avatar Mar 25 '15 13:03 ddavison

This error occurs even when options are an empty string. I am currently for my tests passing those two args. It matches correctly, but the test is not passed to a node due to the error in before session. I guess a more fitting title would be "hub is unable to pass test to node if chromeoptions is set"

StephenDavidson avatar Mar 25 '15 13:03 StephenDavidson

2 more questions:

  1. your platform says LINUX. Am I correct in assuming that this linux platform has a UI, and is able to run chrome?
  2. If so, which version of chrome are you running

ddavison avatar Mar 25 '15 13:03 ddavison

  1. This box using Xvfb as a display. I have successfully performed UI tests before using this box.
  2. Chrome 41.0.2272.101

StephenDavidson avatar Mar 25 '15 13:03 StephenDavidson

looks the same as #342

scott2449 avatar Mar 28 '15 14:03 scott2449

Closing in favour of #342.

andreastt avatar Mar 30 '15 16:03 andreastt

In my case the problem was related to the capabilities config. I used 'version=lastest', now I'm not configuring the 'version' property (leaving it as default) and it works. Hope this helps to someone

geekecom avatar May 24 '17 13:05 geekecom