Mozilla Firefox 68.2.0esr 浏览器在使用 GeckoDriver 和 Selenium 时崩溃

Mozilla Firefox 68.2.0esr browser is crashing using GeckoDriver and Selenium

我试图通过 selenium 启动 Firefox 浏览器,但不幸的是浏览器在启动后立即关闭。我无法从日志文件中进行解释。

以下是日志文件条目:

1582121786461   mozrunner::runner       INFO    Running command: "/usr/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile.d4XupquDfaWC"
1582121787117   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: mozillaAddons
1582121787117   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: telemetry
1582121787118   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: resource://pdf.js/
1582121787118   addons.webextension.screenshots@mozilla.org     WARN    Loading extension 'screenshots@mozilla.org': Reading manifest: Invalid extension permission: about:reader*
JavaScript error: resource:///modules/sessionstore/SessionStore.jsm, line 1325: uncaught exception: 2147746065
1582121789421   Marionette      INFO    Listening on port 33105
1582121789488   Marionette      WARN    TLS certificate errors will be ignored for this session
19:46:29.537 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C
19:46:29.559 INFO [RemoteSession$Factory.lambda$performHandshake[=10=]] - Started new session 1420379c-5cc3-444a-8309-0492333a3c5f (org.openqa.selenium.firefox.GeckoDriverService)
1582121794637   Marionette      WARN    TimedPromise timed out after 5000 ms: stacktrace:
bail@chrome://marionette/content/sync.js:237:64
Fatal: no entropy gathering module detected
Redirecting call to abort() to mozalloc_abort


###!!! [Parent][MessageChannel] Error: (msgtype=0x1E008F,name=PBrowser::Msg_Destroy) Channel error: cannot send/recv

A content process crashed and MOZ_CRASHREPORTER_SHUTDOWN is set, shutting down
JavaScript error: resource:///modules/sessionstore/SessionFile.jsm, line 376: Error: _initWorker called too early! Please read the session file from disk first.
[Parent 423702, Gecko_IOThread] WARNING: pipe error (82): Connection reset by peer: file /home/abuild/rpmbuild/BUILD/firefox-68.2.0/ipc/chromium/src/chrome/common/ipc_channel_posix.cc, line 358
1582121795636   Marionette      INFO    Stopped listening on port 33105

以下是 Browser/libraries 的版本:

我尝试过使用不同版本的 Gecko 驱动程序和 Selenium,但没有任何效果。请让我知道任何解决方案。

这个错误信息...

Fatal: no entropy gathering module detected 
Redirecting call to abort() to mozalloc_abort
.
A content process crashed and MOZ_CRASHREPORTER_SHUTDOWN is set, shutting down 
JavaScript error: resource:///modules/sessionstore/SessionFile.jsm, line 376: 
Error: _initWorker called too early! Please read the session file from disk first. 
[Parent 423702, Gecko_IOThread] WARNING: pipe error (82): Connection reset by peer: file /home/abuild/rpmbuild/BUILD/firefox-68.2.0/ipc/chromium/src/chrome/common/ipc_channel_posix.cc

...表示创建会话时 内容进程 崩溃,并且出现 内核崩溃


深潜

关于您的代码试验和 Trace 级别日志的更多信息将有助于我们以更好的方式分析问题。但是,此问题较早时已在 4.9.x kernels. At times this issue was also observed with corrupted urandom / random

中观察到

但是,您的主要问题似乎是您使用的二进制文件版本之间的不兼容,如下所示:

  • 您正在使用 2019 年 1 月 29 日GeckoDriver v0.24.0,比这早一岁多。
  • 您正在使用 Firefox v68.2.0esr
  • 我们不知道您的 JDK 版本

根据 Supported platforms there seems to be some mismatch among the binaries as Firefoxen 部分中的文档提到:

Support is best in Firefox 57 and greater, although generally the more recent the Firefox version, the better the experience as they have more bug fixes and features. Some features will only be available in the most recent Firefox versions, and we strongly advise using the latest Firefox Nightly with geckodriver. Since Windows XP support in Firefox was dropped with Firefox 53, we do not support this platform.

Note: Starting with the 0.26.0 release geckodriver is able to connect to Android devices, and to control packages which are based on GeckoView (eg. Firefox Preview aka Fenix, or Firefox Reality). But it also still supports versions of Fennec up to 68 ESR, which is the last officially supported release from Mozilla.


解决方案

确保:

  • JDK 升级到当前级别 JDK 8u341.
  • Selenium 已升级到当前级别 Version 3.141.59
  • GeckoDriver 升级到 GeckoDriver v0.26.0 级别。
  • Firefox 已升级到当前 Firefox v72.0 级别。
  • GeckoDriver 出现在所需位置。
  • GeckoDriver 具有非 root 用户的可执行权限。
  • 如果您的基础 Web 客户端 版本太旧,则通过 Revo Uninstaller 卸载它并安装最新的 GA 和发布版本的 Web 客户端.
  • 系统重启
  • 以非 root 用户身份执行 Test
  • 始终在 tearDown(){} 方法中调用 driver.quit() 以优雅地关闭和销毁 WebDriverWeb Client 实例.

结尾

根据使用 GeckoDriverSeleniumFirefox 浏览器 时的最佳实践,请遵循下面的兼容性图表:

Supported platforms