1

鉴于:

  • 以下所有内容均在 Windows 10 / Server 2012 R2 上
  • Selenium .Net (C#) 测试(Selenium.WebDriver nuget v3.141.0、.Net Framework v4.8)
  • ChromeDriver 78.0.3904.70
  • Google Chrome 版本 78.0.3904.97(官方版本)(64 位)
  • 测试由 Azure DevOps 服务器自动运行(本地安装)

什么时候:

似乎每隔几个小时随机一次(每几十次测试运行一次)

然后:

ChromeDriver 日志似乎显示它冻结了约 70-90 秒,然后恢复。请参阅下面引用的日志片段。测试端 (C#) 驱动程序类在 ChromeDriver 不活动 60 秒后超时并且测试失败。

这些“冻结”发生在随机时间,在测试套件的随机部分。有时遵循ClickElement命令,有时遵循Navigate命令。

发生冻结的行似乎总是与此类似:

[1580975930.724][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=265) 3DF35569FFFA4540EA485ED9C4383B72 {
   "expression": "1"

C# 超时异常如下所示:

'OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:25890/session/8ae62a10147ba1c9c0bc8f0ae6e47eed/element/fbd0ddbd-c198-4aa8-b05a-8a1d40766d83/click timed out after 60 seconds.
  ----> System.Net.WebException : The operation has timed out'.
 Stack trace: 
   at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
   at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
   at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebElement.Execute(String commandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.Remote.RemoteWebElement.Click()
   ...

来自 ChromeDriver 的日志片段:

[1580975930.723][INFO]: Waiting for pending navigations...
[1580975930.723][DEBUG]: DevTools WebSocket Event: Page.frameScheduledNavigation 3DF35569FFFA4540EA485ED9C4383B72 {
   "delay": 0,
   "frameId": "3DF35569FFFA4540EA485ED9C4383B72",
   "reason": "formSubmissionPost",
   "url": "https://site-under-test/some-page"
}
[1580975930.724][DEBUG]: DevTools WebSocket Event: Page.frameRequestedNavigation 3DF35569FFFA4540EA485ED9C4383B72 {
   "frameId": "3DF35569FFFA4540EA485ED9C4383B72",
   "reason": "formSubmissionPost",
   "url": "https://site-under-test/some-page"
}
[1580975930.724][DEBUG]: DevTools WebSocket Event: Page.frameStartedLoading 3DF35569FFFA4540EA485ED9C4383B72 {
   "frameId": "3DF35569FFFA4540EA485ED9C4383B72"
}
[1580975930.724][DEBUG]: DevTools WebSocket Event: Page.frameClearedScheduledNavigation 3DF35569FFFA4540EA485ED9C4383B72 {
   "frameId": "3DF35569FFFA4540EA485ED9C4383B72"
}
[1580975930.724][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=265) 3DF35569FFFA4540EA485ED9C4383B72 {
   "expression": "1"
}  

*******************************************************************
***** The line above is the one that freezes. Note timestamps *****
*******************************************************************

[1580976006.271][DEBUG]: DevTools WebSocket Event: Runtime.executionContextDestroyed 3DF35569FFFA4540EA485ED9C4383B72 {
   "executionContextId": 5
}
[1580976006.271][DEBUG]: DevTools WebSocket Event: Runtime.executionContextsCleared 3DF35569FFFA4540EA485ED9C4383B72 {

}
[1580976006.271][DEBUG]: DevTools WebSocket Event: Page.frameNavigated 3DF35569FFFA4540EA485ED9C4383B72 {
   "frame": {
      "id": "3DF35569FFFA4540EA485ED9C4383B72",
      "loaderId": "29E7B61049A044FA7CE34819B5BFA9B3",
      "mimeType": "text/html",
      "securityOrigin": "https://site-under-test",
      "url": "https://site-under-test/some-page"
   }
}
[1580976006.271][DEBUG]: DevTools WebSocket Event: Runtime.executionContextCreated 3DF35569FFFA4540EA485ED9C4383B72 {
   "context": {
      "auxData": {
         "frameId": "3DF35569FFFA4540EA485ED9C4383B72",
         "isDefault": true,
         "type": "default"
      },
      "id": 6,
      "name": "",
      "origin": "https://site-under-test"
   }
}
[1580976006.271][DEBUG]: DevTools WebSocket Event: DOM.documentUpdated 3DF35569FFFA4540EA485ED9C4383B72 {

}
[1580976006.271][DEBUG]: DevTools WebSocket Command: DOM.getDocument (id=266) 3DF35569FFFA4540EA485ED9C4383B72 {

}
[1580976006.272][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=265) 3DF35569FFFA4540EA485ED9C4383B72 {
   "result": {
      "description": "1",
      "type": "number",
      "value": 1
   }
}

我该如何进一步调查“冻结”的原因并解决它?

4

0 回答 0