1. 程式人生 > >selenium server執行報錯

selenium server執行報錯

使用的環境:python3.6.1,selenium3.4.3
啟動的服務:selenium-server-standalone-3.4.0.jar

正常啟動服務後執行指令碼,提示錯誤如下:


selenium.common.exceptions.WebDriverException: Message: None
Stacktrace:
    at java.util.HashMap.putMapEntries (HashMap.java:500)
    at java.util.HashMap.putAll (HashMap.java:784)
    at org.openqa
.selenium.remote.DesiredCapabilities.<init> (DesiredCapabilities.java:55) at org.openqa.grid.web.servlet.handler.RequestHandler.process (RequestHandler.java:104) 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:841) at org.seleniumhq.jetty9.servlet.ServletHandler
.doHandle (ServletHandler.java:543) at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle (ScopedHandler.java:188) at org.seleniumhq.jetty9.server.session.SessionHandler.doHandle (SessionHandler.java:1584) at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle (ScopedHandler.java:188) at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle (ContextHandler.java:1228) at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope (ScopedHandler.java:168) at org.seleniumhq.jetty9.servlet.ServletHandler.doScope (ServletHandler.java:481) at org.seleniumhq.jetty9.server.session.SessionHandler.doScope (SessionHandler.java:1553) at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope (ScopedHandler.java:166) at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope (ContextHandler.java:1130) at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle (ScopedHandler.java:141) at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle (HandlerWrapper.java:132) at org.seleniumhq.jetty9.server.Server.handle (Server.java:564) at org.seleniumhq.jetty9.server.HttpChannel.handle (HttpChannel.java:320) at org.seleniumhq.jetty9.server.HttpConnection.onFillable (HttpConnection.java:251) at org.seleniumhq.jetty9.io.AbstractConnection$ReadCallback.succeeded (AbstractConnection.java:279) at org.seleniumhq.jetty9.io.FillInterest.fillable (FillInterest.java:112) at org.seleniumhq.jetty9.io.ChannelEndPoint$2.run (ChannelEndPoint.java:124) at org.seleniumhq.jetty9.util.thread.Invocable.invokePreferred (Invocable.java:122) at org.seleniumhq.jetty9.util.thread.strategy.ExecutingExecutionStrategy.invoke (ExecutingExecutionStrategy.java:58) at org.seleniumhq.jetty9.util.thread.strategy.ExecuteProduceConsume.produceConsume (ExecuteProduceConsume.java:201) at org.seleniumhq.jetty9.util.thread.strategy.ExecuteProduceConsume.run (ExecuteProduceConsume.java:133) at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob (QueuedThreadPool.java:672) at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$2.run (QueuedThreadPool.java:590) at java.lang.Thread.run (Thread.java:745) [Finished in 0.3s]

解決方法:
降級selenium

首先我把selenium降到3.0.0,問題解決
然後發現新問題,每次執行測試指令碼後都會提示以下資訊:

Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.chrome.service.Service object at 0x000002F439156160>>
Traceback (most recent call last):
  File "D:\python3.6\lib\site-packages\selenium\webdriver\common\service.py", line 163, in __del__
  File "D:\python3.6\lib\site-packages\selenium\webdriver\common\service.py", line 139, in stop
  File "D:\python3.6\lib\site-packages\selenium\webdriver\common\service.py", line 110, in send_remote_shutdown_command
ImportError: sys.meta_path is None, Python is likely shutting down

最後使用:selenium3.3.1
啟動的服務:selenium-server-standalone-3.4.0.jar
到此以上問題解決