Class: Selenium::WebDriver::Script

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/webdriver/common/script.rb

Instance Method Summary collapse

Constructor Details

#initialize(bridge) ⇒ Script

Returns a new instance of Script.



23
24
25
# File 'lib/selenium/webdriver/common/script.rb', line 23

def initialize(bridge)
  @log_handler = BiDi::LogHandler.new(bridge.bidi)
end

Instance Method Details

#add_console_message_handler(&block) ⇒ int

Returns id of the handler.

Returns:

  • (int)

    id of the handler



28
29
30
# File 'lib/selenium/webdriver/common/script.rb', line 28

def add_console_message_handler(&block)
  @log_handler.add_message_handler('console', &block)
end

#add_javascript_error_handler(&block) ⇒ int

Returns id of the handler.

Returns:

  • (int)

    id of the handler



33
34
35
# File 'lib/selenium/webdriver/common/script.rb', line 33

def add_javascript_error_handler(&block)
  @log_handler.add_message_handler('javascript', &block)
end

#remove_console_message_handler(id) ⇒ Object Also known as: remove_javascript_error_handler

Parameters:

  • id (int)

    of the handler previously added



38
39
40
# File 'lib/selenium/webdriver/common/script.rb', line 38

def remove_console_message_handler(id)
  @log_handler.remove_message_handler(id)
end