Sha256: 7ae72c8c78242e94e2e91c2365db29d18c6d7438e5d31533a5e122bc26e2df3e
Contents?: true
Size: 1.22 KB
Versions: 23
Compression:
Stored size: 1.22 KB
Contents
module Perus::Pinger class Chrome < ChromeCommand description 'Connects to Chrome with the remote debugger and counts the number of warnings and errors currently in the console of the top Chrome window. The URL of the page is also sent and can be compared to an expected string in an alert.' metric! 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 { chrome_warnings: warning_count, chrome_errors: error_count, chrome_url: @page['url'] } end end end
Version data entries
23 entries across 23 versions & 1 rubygems