Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silencing unnecessary capybara-webkit warnings

Any advice on silencing these capybara-webkit warnings?

2015-09-06 14:15:38.455 webkit_server[3700:6222738] Error loading /Users/justin/Library/Internet Plug-Ins/Google Earth Web Plug-in.plugin/Contents/MacOS/libnpgeplugin.dylib: dlopen(/Users/justin/Library/Internet Plug-Ins/Google Earth Web Plug-in.plugin/Contents/MacOS/libnpgeplugin.dylib, 265): no suitable image found. Did find: /Users/justin/Library/Internet Plug-Ins/Google Earth Web Plug-in.plugin/Contents/MacOS/libnpgeplugin.dylib: mach-o, but wrong architecture plugin,NP_Initialize start plugin,NP_Initialize end plugin,NP_GetEntryPoints start Private_Initialize plugin,NP_GetEntryPoints end 2015-09-06 14:15:38.463 webkit_server[3700:6222738] Error loading /Users/justin/Library/Application Support/Facebook/video/3.1.0.522/FacebookVideoCalling.webplugin/Contents/MacOS/FacebookVideoCalling: dlopen(/Users/justin/Library/Application Support/Facebook/video/3.1.0.522/FacebookVideoCalling.webplugin/Contents/MacOS/FacebookVideoCalling, 262): no suitable image found. Did find: /Users/justin/Library/Application Support/Facebook/video/3.1.0.522/FacebookVideoCalling.webplugin/Contents/MacOS/FacebookVideoCalling: mach-o, but wrong architecture 2015-09-06 14:15:38.493 webkit_server[3700:6222738] Cannot find executable for CFBundle 0x7ffd14fcd260 (not loaded) 2015-09-06 14:15:38.495 webkit_server[3700:6222738] Error loading /Library/Internet Plug-Ins/QuickTime Plugin.plugin/Contents/MacOS/QuickTime Plugin: dlopen(/Library/Internet Plug-Ins/QuickTime Plugin.plugin/Contents/MacOS/QuickTime Plugin, 265): no suitable image found. Did find: /Library/Internet Plug-Ins/QuickTime Plugin.plugin/Contents/MacOS/QuickTime Plugin: mach-o, but wrong architecture objc[3700]: Class AdobePDFProgressView is implemented in both /Library/Internet Plug-Ins/AdobePDFViewer.plugin/Contents/MacOS/AdobePDFViewer and /Library/Internet Plug-Ins/AdobePDFViewerNPAPI.plugin/Contents/MacOS/AdobePDFViewerNPAPI. One of the two will be used. Which one is undefined. objc[3700]: Class ObjCTimerObject is implemented in both /Library/Internet Plug-Ins/AdobePDFViewer.plugin/Contents/MacOS/AdobePDFViewer and /Library/Internet Plug-Ins/AdobePDFViewerNPAPI.plugin/Contents/MacOS/AdobePDFViewerNPAPI. One of the two will be used. Which one is undefined. objc[3700]: Class MacCocoaSocketServerHelperRtc is implemented in both /Library/Internet Plug-Ins/o1dbrowserplugin.plugin/Contents/MacOS/o1dbrowserplugin and /Library/Internet Plug-Ins/googletalkbrowserplugin.plugin/Contents/MacOS/googletalkbrowserplugin. One of the two will be used. Which one is undefined.

like image 395
justingordon Avatar asked Sep 07 '15 00:09

justingordon


1 Answers

Here is a snippet to prevent the warnings from showing up in the console: https://github.com/thoughtbot/capybara-webkit/issues/157.

Capybara::Webkit.configure do |config|
  config.block_unknown_urls  # <--- this configuration would be lost if you didn't use .merge below
end

class WebkitStderrWithQtPluginMessagesSuppressed
  IGNOREABLE = Regexp.new( [
    'CoreText performance',
    'userSpaceScaleFactor',
    'Internet Plug-Ins',
    'is implemented in bo'
  ].join('|') )

  def write(message)
    if message =~ IGNOREABLE
      0
    else
      puts(message)
      1
    end
  end
end

Capybara.register_driver :webkit_with_qt_plugin_messages_suppressed do |app|
  Capybara::Webkit::Driver.new(
    app,
    Capybara::Webkit::Configuration.to_hash.merge(  # <------ maintain configuration set in Capybara::Webkit.configure block
      stderr: WebkitStderrWithQtPluginMessagesSuppressed.new
    )
  )
end

Capybara.javascript_driver = :webkit_with_qt_plugin_messages_suppressed

While this works to hide the messages, I feel the right way of fixing it would be to prevent loading the plugins from ever being loaded. But I haven't figured out how to do that with Capybara and webkit.

like image 77
PaulMest Avatar answered Nov 04 '22 08:11

PaulMest