class Perus::Pinger::Chrome
Public Instance Methods
run()
click to toggle source
# File lib/perus/pinger/metrics/chrome.rb, line 9 def run # we use a debugging protocol connection to read the console messages # in the top level window to count the number of warnings and errors warning_count = 0 error_count = 0 execute(['{"id":1,"method":"Console.enable"}']) do |json| if json['method'] == 'Console.messageAdded' level = json['params']['message']['level'] if level == 'error' error_count += 1 elsif level == 'warning' warning_count += 1 end end end return {} if @page.nil? { chrome_warnings: warning_count, chrome_errors: error_count, chrome_url: @page['url'] } end