Selenium WebDriver 在大约 70 秒后崩溃 (WebDriverError: newSession)



我对这个新错误感到困惑,这个错误开始发生在我现有的工作项目中,即使我没有对代码进行任何更改来导致这种情况发生(但这可能是由于 FireFox 更新,或者依赖项突然失败(。在它开始发生后,我确实添加了 catch 以帮助调试导致突然退出的原因:

var prom = new Builder()
.forBrowser('firefox')
.build()
prom.catch((e) => {
console.log(e)
})
let driver: WebDriver = await prom

基本上,当我的代码到达此代码块的最后一行时,它会弹出一个 FireFox 窗口,等待大约 70 秒(现在应该已经实现了承诺(,然后抛出一个错误,该错误指向 catch 并将其记录到控制台:

{ WebDriverError: newSession
at Object.throwDecodedError (pathtonode_modulesselenium-webdriverliberror.js:550:15)
at parseHttpResponse (pathtonode_modulesselenium-webdriverlibhttp.js:542:13)
at Executor.execute (pathtonode_modulesselenium-webdriverlibhttp.js:468:26)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
name: 'WebDriverError',
remoteStacktrace: 'WebDriverError@chrome://marionette/content/error.js:178:5nUnknownCommandError@chrome://marionette/content/error.js:472:5ndespatch@chrome://marionette/content/server.js:290:13nexecute@chrome://marionette/content/server.js:271:11nonPacket/<@chrome://marionette/content/server.js:246:15nonPacket@chrome://marionette/content/server.js:245:8n_onJSONObjectReady/<@chrome://marionette/content/transport.js:490:9n' }

有趣的是,当使用Visual Studio检查WebDriverError对象时,它说它有一个消息属性"newSession",由于某种原因没有记录到控制台(或当我尝试这样做时字符串化(。

无论如何,这个错误结构很差,因为"newSession"没有告诉我足够的信息来追踪出了什么问题。

谁能帮我确定它在等待~70秒?

更新:我确定了它正在等待的 Web 请求(POST tohttp://localhost:51290/session,其中端口在每次运行时都会有所不同(。正是此请求在 70 秒后超时。我可以通过在外部应用程序(例如 SoapUI(中复制此超时,方法是将{}发送到 URL(也会弹出一个 firefox 窗口(。但是,如果我在 SoapUI 中将超时设置为巨大的时间,JSON 响应当然是:

{"value": {
"error": "unknown error",
"message": "newSession",
"stacktrace": "WebDriverError@chrome://marionette/content/error.js:178:5nUnknownCommandError@chrome://marionette/content/error.js:472:5ndespatch@chrome://marionette/content/server.js:290:13nexecute@chrome://marionette/content/server.js:271:11nonPacket/<@chrome://marionette/content/server.js:246:15nonPacket@chrome://marionette/content/server.js:245:8n_onJSONObjectReady/<@chrome://marionette/content/transport.js:490:9n"
}}

我想我需要调试FireFox方面,任何人都可以让我开始吗?

我刚刚找到了这个问题的解决方案。我的壁虎司机已经过时了。更新壁虎驱动程序解决了这个问题。

在OSX上,我必须做的是:

brew uninstall geckodriver

然后

brew install geckodriver

希望对您有所帮助!

最新更新