当我在本地主机中运行python代码时:
>>>from selenium import webdriver
>>>from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
>>>cap = DesiredCapabilities.PHANTOMJS.copy()
>>>webdriver = webdriver.Remote(desired_capabilities=cap)
>>>print webdriver
<selenium.webdriver.remote.webdriver.WebDriver (session="fc737dde-4ec7-47a9-ab3d-a3defae1f23a")>
但是当我在远程主机中运行相同的代码时,会收到错误消息:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/opt/retriever/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 90, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/opt/retriever/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 177, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "/opt/retriever/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/opt/retriever/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
WebDriverException: Message: Error forwarding the new session Error forwarding the request Connection reset
Stacktrace:
at org.openqa.grid.web.servlet.handler.RequestHandler.process (RequestHandler.java:115)
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:707)
at javax.servlet.http.HttpServlet.service (HttpServlet.java:790)
at org.seleniumhq.jetty9.servlet.ServletHolder.handle (ServletHolder.java:808)
at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle (ServletHandler.java:587)
at org.seleniumhq.jetty9.server.session.SessionHandler.doHandle (SessionHandler.java:221)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle (ContextHandler.java:1127)
at org.seleniumhq.jetty9.servlet.ServletHandler.doScope (ServletHandler.java:515)
at org.seleniumhq.jetty9.server.session.SessionHandler.doScope (SessionHandler.java:185)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope (ContextHandler.java:1061)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle (ScopedHandler.java:141)
at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle (HandlerWrapper.java:97)
at org.seleniumhq.jetty9.server.Server.handle (Server.java:499)
at org.seleniumhq.jetty9.server.HttpChannel.handle (HttpChannel.java:310)
at org.seleniumhq.jetty9.server.HttpConnection.onFillable (HttpConnection.java:257)
at org.seleniumhq.jetty9.io.AbstractConnection$2.run (AbstractConnection.java:540)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob (QueuedThreadPool.java:635)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$3.run (QueuedThreadPool.java:555)
at java.lang.Thread.run (Thread.java:748)
此错误是什么意思?我应该怎么做才能解决此错误?