bogdanrada
12/14/2012 - 2:02 PM

Capybara add Firebug to Selenium test-- Rails+Rspec.rb

Capybara add Firebug to Selenium test-- Rails+Rspec.rb

# for more preferences visit this page
#https://getfirebug.com/wiki/index.php/Firebug_Preferences


require 'selenium/webdriver'


ORIGINAL_FIREBUG_PATH = File.expand_path(File.join(File.dirname(__FILE__),"firebug-2.0.16-fx.xpi"))
ORIGINAL_FIREBUG_URL = "https://getfirebug.com/releases/firebug/1.13/firebug-1.13.0a9.xpi";

Capybara.register_driver :selenium do |app|

  profile = Selenium::WebDriver::Firefox::Profile.new

  profile.add_extension ORIGINAL_FIREBUG_PATH



  # Prevent "Welcome!" tab
  profile["extensions.firebug.currentVersion"] = "1.13"

  # Enable for all sites.
   profile["extensions.firebug.allPagesActivation"] = "on"

  # prevent firebug open new tab
  profile["extensions.firebug.showFirstRunPage"] = false;

  # Enable all features.
  ['console', 'net', 'script', 'cookies'].each do |feature|
    profile["extensions.firebug.#{feature}.enableSites"] = true
  end
  # Opened by default.(if you want to be closed than change this to 3)
  profile["extensions.firebug.previousPlacement"] = 1

  #show javascript errors
  profile["extensions.firebug.showJSErrors"] = true

  # show AJAX requests
  profile["extensions.firebug.showXMLHttpRequests"] =true

  #show network errors
  profile["extensions.firebug.showNetworkErrors"] = true

  # stack trace
  profile["extensions.firebug.showStackTrace"] = true

  # default pane to see
  profile["extensions.firebug.defaultPanelName"] = "console"
  Capybara::Selenium::Driver.new app, :profile => profile
end