Sha256: c3c56e4bed9535be389792c6aedc8101d3d5c0fda5e288810782126fb4492da8

Contents?: true

Size: 1.26 KB

Versions: 21

Compression:

Stored size: 1.26 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

            return {} if @page.nil?

            {
                chrome_warnings: warning_count,
                chrome_errors: error_count,
                chrome_url: @page['url']
            }
        end
    end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
perus-1.0.7 lib/perus/pinger/metrics/chrome.rb
perus-1.0.6 lib/perus/pinger/metrics/chrome.rb
perus-1.0.5 lib/perus/pinger/metrics/chrome.rb
perus-1.0.4 lib/perus/pinger/metrics/chrome.rb
perus-1.0.3 lib/perus/pinger/metrics/chrome.rb
perus-1.0.2 lib/perus/pinger/metrics/chrome.rb
perus-1.0.1 lib/perus/pinger/metrics/chrome.rb
perus-1.0.0 lib/perus/pinger/metrics/chrome.rb
perus-0.1.35 lib/perus/pinger/metrics/chrome.rb
perus-0.1.34 lib/perus/pinger/metrics/chrome.rb
perus-0.1.33 lib/perus/pinger/metrics/chrome.rb
perus-0.1.32 lib/perus/pinger/metrics/chrome.rb
perus-0.1.31 lib/perus/pinger/metrics/chrome.rb
perus-0.1.30 lib/perus/pinger/metrics/chrome.rb
perus-0.1.29 lib/perus/pinger/metrics/chrome.rb
perus-0.1.28 lib/perus/pinger/metrics/chrome.rb
perus-0.1.27 lib/perus/pinger/metrics/chrome.rb
perus-0.1.26 lib/perus/pinger/metrics/chrome.rb
perus-0.1.25 lib/perus/pinger/metrics/chrome.rb
perus-0.1.24 lib/perus/pinger/metrics/chrome.rb