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, :, :method, :args, :type)
-
JavaScriptLogEntry =
# File 'rb/lib/selenium/webdriver/bidi/log_handler.rb', line 25BiDi::Struct.new(:level, :text, :, :stack_trace, :type)
Class Method Summary
- .new(bidi) ⇒ LogHandler constructor
Instance Method Summary
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
# File 'rb/lib/selenium/webdriver/bidi/log_handler.rb', line 33
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 44
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 51
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 56
def unsubscribe_log_entry @bidi.session.unsubscribe('log.entryAdded') @log_entry_subscribed = false end