Skip to content

Instantly share code, notes, and snippets.

@tkensiski
Created March 20, 2014 02:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkensiski/9656035 to your computer and use it in GitHub Desktop.
Save tkensiski/9656035 to your computer and use it in GitHub Desktop.
Using JSErrorCollector w/ Ruby + Watir
require 'watir-webdriver'
profile = Selenium::WebDriver::Firefox::Profile.new
profile.add_extension File.join(Rails.root, "/JSErrorCollector.xpi")
browser = Watir::Browser.new :firefox, :profile => profile
browser.goto 'www.google.com'
errors = browser.execute_script("return window.JSErrorCollector_errors.pump()")
if errors.any?
puts "-------------------------------------------------------------"
puts "Found #{errors.length} javascript error(s)"
puts "-------------------------------------------------------------"
errors.each do |error|
puts error["errorMessage"] + " (" + error["sourceName"] + ":" + error["lineNumber"] + ")"
end
@file.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment