Class: Perus::Pinger::Chrome
- Inherits:
-
ChromeCommand
- Object
- Command
- ChromeCommand
- Perus::Pinger::Chrome
- Defined in:
- lib/perus/pinger/metrics/chrome.rb
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
Methods inherited from ChromeCommand
Methods inherited from Command
abstract!, abstract?, #cleanup, #darwin?, description, human_name, inherited, #initialize, metric!, metric?, option, options, #shell, subclasses
Constructor Details
This class inherits a constructor from Perus::Pinger::Command
Instance Method Details
#run ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# 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 |