Class: Selenium::WebDriver::BiDi::LogHandler
Relationships & Source Files | |
Inherits: | Object |
Defined in: | rb/lib/selenium/webdriver/bidi/log_handler.rb |
Constant Summary
-
ConsoleLogEntry =
# File 'rb/lib/selenium/webdriver/bidi/log_handler.rb', line 24BiDi::Struct.new(:level, :text, :, :stack_trace, :type, :source, :method, :args)
-
JavaScriptLogEntry =
# File 'rb/lib/selenium/webdriver/bidi/log_handler.rb', line 25BiDi::Struct.new(:level, :text, :, :stack_trace, :type, :source)
Class Method Summary
- .new(bidi) ⇒ LogHandler constructor
Instance Method Summary
-
#add_message_handler(type) ⇒ int
steep:ignore:start.
- #remove_message_handler(id)
- #subscribe_log_entry private
- #unsubscribe_log_entry private
Constructor Details
.new(bidi) ⇒ LogHandler
# File 'rb/lib/selenium/webdriver/bidi/log_handler.rb', line 27
def initialize(bidi) @bidi = bidi @log_entry_subscribed = false end
Instance Method Details
#add_message_handler(type) ⇒ int
steep:ignore:start
# File 'rb/lib/selenium/webdriver/bidi/log_handler.rb', line 34
def (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)
# File 'rb/lib/selenium/webdriver/bidi/log_handler.rb', line 46
def (id) @bidi.remove_callback('log.entryAdded', id) unsubscribe_log_entry if @log_entry_subscribed && @bidi.callbacks['log.entryAdded'].empty? end
#subscribe_log_entry (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/bidi/log_handler.rb', line 53
def subscribe_log_entry @bidi.session.subscribe('log.entryAdded') @log_entry_subscribed = true end
#unsubscribe_log_entry (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/bidi/log_handler.rb', line 58
def unsubscribe_log_entry @bidi.session.unsubscribe('log.entryAdded') @log_entry_subscribed = false end