Class: Selenium::WebDriver::BiDi::LogHandler
- Inherits:
-
Object
- Object
- Selenium::WebDriver::BiDi::LogHandler
- Defined in:
- lib/selenium/webdriver/bidi/log_handler.rb
Constant Summary collapse
- ConsoleLogEntry =
BiDi::Struct.new(:level, :text, :timestamp, :stack_trace, :type, :source, :method, :args)
- JavaScriptLogEntry =
BiDi::Struct.new(:level, :text, :timestamp, :stack_trace, :type, :source)
Instance Method Summary collapse
-
#add_message_handler(type) ⇒ int
Id of the handler.
-
#initialize(bidi) ⇒ LogHandler
constructor
A new instance of LogHandler.
- #remove_message_handler(id) ⇒ Object
Constructor Details
#initialize(bidi) ⇒ LogHandler
Returns a new instance of LogHandler.
27 28 29 30 |
# File '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
Returns id of the handler.
33 34 35 36 37 38 39 40 41 |
# File '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) ⇒ Object
44 45 46 47 |
# File '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 |