rb/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb
#
#
# Registers listener to be called whenever browser receives
# a new Console API message such as console.log().
# This currently relies on DevTools so is only supported in
# Chromium browsers.
#
# @example
#   logs = []
#   driver.on_log_event do |event|
#     logs.push(event)
#   end
#
# @param [#call] block which yields DevTools::ConsoleEvent
#
Registers listener to be called whenever browser receives
a new Console API message such as console.log().
This currently relies on DevTools so is only supported in
Chromium browsers.
Registers listener to be called whenever browser receives a new Console API message such as console . log () . This currently relies on DevTools so is only supported in Chromium browsers .
def on_log_event(&block)
          console_listeners_enabled = console_listeners.any?
          console_listeners << block
          return if console_listeners_enabled
          devtools.runtime.enable
          devtools.runtime.on(:console_api_called) do |params|
            event = DevTools::ConsoleEvent.new(
              type: params['type'],
              timestamp: params['timestamp'],
              args: params['args']
            )
            console_listeners.each do |listener|
              listener.call(event)
            end
          end
        end
def on_log_event ( & block ) console_listeners_enabled = console_listeners . any? console_listeners << block return if console_listeners_enabled devtools . runtime . enable devtools . runtime . on ( :console_api_called ) do | params | event = DevTools :: ConsoleEvent . new ( type : params [ 'type' ] , timestamp : params [ 'timestamp' ] , args : params [ 'args' ] ) console_listeners . each do | listener | listener . call ( event ) end end end
Registers listener to be called whenever browser receives
a new Console API message such as console.log().
Registers listener to be called whenever browser receives a new Console API message such as console . log () .
block
<not_specific>
<not_specific>
block which yields DevTools::ConsoleEvent
block which yields DevTools :: ConsoleEvent
example
logs = [] driver.on_log_event do |event| logs.push(event) end
logs = [] driver . on_log_event do |event| logs . push ( event ) end