2017-07-25 39 views
0

我硒測試對遠程運行的webdriver運行時罰款與當地的webdriver,但未能針對IE瀏覽器從SeleniumHQ docker images的Python的webdriver .quit()獲取錯誤

測試內置硒電網運行都寫在Python和硒PIP封裝我「M使用被selenium==3.3.1

try: 
    driver = webdriver.Remote(
    command_executor='http://localhost:4444/wd/hub', 
    desired_capabilities=DesiredCapabilities.CHROME, #TODO also support windowSize, implicitWait - how? 
) 
    #some other test logic goes here 

finally: 
    driver.quit() #this command raises error 

問題是爲什麼.quit()得到誤差(有時它傳遞,有時失敗),並且特別是當運行多個異步測試?我們如何解決它?

p.s.

完整的異常跟蹤

Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/proboscis/case.py", line 296, in testng_method_mistake_capture_func 
    compatability.capture_type_error(s_func) File "/usr/local/lib/python2.7/dist-packages/proboscis/compatability/exceptions_2_6.py", line 27, in capture_type_error 
    func() File "/home/namgivu/NN/code/automation_testing/test_vault/aos_web/test990101c_checkOrder.py", line 15, in test_orderStatus 
    pom.testOrderStatus() File "/home/namgivu/NN/code/automation_testing/pom/aos_web/chrome.py", line 759, in testOrderStatus 
    driver.quit() File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 522, in quit 
    self.execute(Command.QUIT) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 238, in execute 
    self.error_handler.check_response(response) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response 
    raise exception_class(message, screen, stacktrace) WebDriverException: Message: Session [686d6045-541d-41f4-b0e2-d23f64d285e1] was terminated due to TIMEOUT Stacktrace: 
    at org.openqa.grid.internal.ActiveTestSessions.getExistingSession (ActiveTestSessions.java:105) 
    at org.openqa.grid.internal.Registry.getExistingSession (Registry.java:404) 
    at org.openqa.grid.web.servlet.handler.RequestHandler.getSession (RequestHandler.java:232) 
    at org.openqa.grid.web.servlet.handler.RequestHandler.process (RequestHandler.java:117) 
    at org.openqa.grid.web.servlet.DriverServlet.process (DriverServlet.java:83) 
    at org.openqa.grid.web.servlet.DriverServlet.doDelete (DriverServlet.java:73) 
    at javax.servlet.http.HttpServlet.service (HttpServlet.java:713) 
    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.QueuedThreadPool.runJob (QueuedThreadPool.java:672) 
    at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$2.run (QueuedThreadPool.java:590) 
    at java.lang.Thread.run (Thread.java:748) 
-------------------- >> begin captured logging << -------------------- selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session {"requiredCapabilities": {}, "desiredCapabilities": {"platform": "ANY", "browserName": "chrome", "version": "", "javascriptEnabled": true}} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session {"requiredCapabilities": {}, "desiredCapabilities": {"platform": "ANY", "browserName": "chrome", "version": "", "javascriptEnabled": true}} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/url {"url": "http://ec2-54-208-76-28.compute-1.amazonaws.com/smartdesk-sit-to-stand-height-adjustable-standing-desk", "sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: GET http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/screenshot {"sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element {"using": "css selector", "sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "value": "button.buy-now.normal"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: GET http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element/0/displayed {"sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "id": "0"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element/0/click {"sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "id": "0"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: GET http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/screenshot {"sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element {"using": "xpath", "sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "value": "//h2[text()='Checkout as Guest']"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: GET http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element/1/displayed {"sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "id": "1"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: GET http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/screenshot {"sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element {"using": "css selector", "sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "value": ".checkout-signin > div:nth-of-type(2) input[name=\"email\"]"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: GET http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element/2/displayed {"sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "id": "2"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element/2/value {"sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "id": "2", "value": ["a", "o", "s", ".", "a", "u", "t", "o", "t", "e", "s", "t", ".", "t", "e", "a", "m", "@", "g", "m", "a", "i", "l", ".", "c", "o", "m"]} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: GET http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/screenshot {"sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element {"using": "css selector", "sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "value": "#guest_submit"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: GET http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element/3/displayed {"sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "id": "3"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element/3/click {"sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "id": "3"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element {"using": "xpath", "sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "value": "//h4[text()='PAYMENT METHOD']"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element {"using": "xpath", "sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "value": "//h4[text()='PAYMENT METHOD']"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element {"using": "xpath", "sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "value": "//h4[text()='PAYMENT METHOD']"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element {"using": "xpath", "sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "value": "//h4[text()='PAYMENT METHOD']"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element {"using": "xpath", "sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "value": "//h4[text()='PAYMENT METHOD']"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element {"using": "xpath", "sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "value": "//h4[text()='PAYMENT METHOD']"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element {"using": "xpath", "sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "value": "//h4[text()='PAYMENT METHOD']"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element {"using": "xpath", "sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "value": "//h4[text()='PAYMENT METHOD']"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element {"using": "xpath", "sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "value": "//h4[text()='PAYMENT METHOD']"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element {"using": "xpath", "sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "value": "//h4[text()='PAYMENT METHOD']"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287/element {"using": "xpath", "sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287", "value": "//h4[text()='PAYMENT METHOD']"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: DELETE http://127.0.0.1:4444/wd/hub/session/f56a773d-8069-4f4e-a926-f4ffa127c287 {"sessionId": "f56a773d-8069-4f4e-a926-f4ffa127c287"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: POST http://127.0.0.1:4444/wd/hub/session/686d6045-541d-41f4-b0e2-d23f64d285e1/url {"url": "http://ec2-54-208-76-28.compute-1.amazonaws.com/order/status", "sessionId": "686d6045-541d-41f4-b0e2-d23f64d285e1"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request selenium.webdriver.remote.remote_connection: DEBUG: DELETE http://127.0.0.1:4444/wd/hub/session/686d6045-541d-41f4-b0e2-d23f64d285e1 {"sessionId": "686d6045-541d-41f4-b0e2-d23f64d285e1"} selenium.webdriver.remote.remote_connection: DEBUG: Finished Request 
--------------------- >> end captured logging << --------------------- 

回答

1

當您打開留下WebDriver實例閒着無,直到超時(默認超時值爲1800 seconds但我猜你也許已經改變了這一點)發生的任何活動會出現這種情況。

所以,你可能要檢查你的測試代碼,看看是否有任何長時間運行正在之中你UI操作執行,還要檢查什麼是需要的非UI操作的時間非UI操作去完成。

+0

感謝您的建議,我會檢查這一點 - 我可以強調這一事實*錯誤只發生在遠程webdriver * –

+0

是的,我明白這一點。這僅在使用網格時纔會發生,因爲此清理機制僅駐留在網格中,而不在常規的WebDriver模式中。 –

+0

我已經檢查,結果沒有非UI操作存在 - 除了快照調用 –