Class: Selenium::WebDriver::BiDi::LogHandler Private

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/webdriver/bidi/log_handler.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Implements the Log of the WebDriver-BiDi specification This functionality should be accessed through driver.script method

Constant Summary collapse

ConsoleLogEntry =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

BiDi::Struct.new(:level, :text, :timestamp, :stack_trace, :type, :source, :method, :args)
JavaScriptLogEntry =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

BiDi::Struct.new(:level, :text, :timestamp, :stack_trace, :type, :source)

Instance Method Summary collapse

Constructor Details

#initialize(bidi) ⇒ LogHandler

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of LogHandler.



32
33
34
35
# File 'lib/selenium/webdriver/bidi/log_handler.rb', line 32

def initialize(bidi)
  @bidi = bidi
  @log_entry_subscribed = false
end

Instance Method Details

#add_message_handler(type) ⇒ int

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

steep:ignore:start

Returns:

  • (int)

    id of the handler



39
40
41
42
43
44
45
46
47
# File 'lib/selenium/webdriver/bidi/log_handler.rb', line 39

def add_message_handler(type)
  subscribe_log_entry unless @log_entry_subscribed
  @bidi.add_callback('log.entryAdded') do |params|
    if params['type'] == type
      log_entry_klass = type == 'console' ? ConsoleLogEntry : JavaScriptLogEntry
      yield(log_entry_klass.new(**params))
    end
  end
end

#remove_message_handler(id) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • id (int)

    of the handler previously added



51
52
53
54
# File 'lib/selenium/webdriver/bidi/log_handler.rb', line 51

def remove_message_handler(id)
  @bidi.remove_callback('log.entryAdded', id)
  unsubscribe_log_entry if @log_entry_subscribed && @bidi.callbacks['log.entryAdded'].empty?
end