Class: Selenium::WebDriver::BiDi

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/webdriver/bidi.rb,
lib/selenium/webdriver/bidi/struct.rb,
lib/selenium/webdriver/bidi/network.rb,
lib/selenium/webdriver/bidi/session.rb,
lib/selenium/webdriver/bidi/log_handler.rb,
lib/selenium/webdriver/bidi/log/filter_by.rb,
lib/selenium/webdriver/bidi/log_inspector.rb,
lib/selenium/webdriver/bidi/browsing_context.rb,
lib/selenium/webdriver/bidi/log/base_log_entry.rb,
lib/selenium/webdriver/bidi/log/console_log_entry.rb,
lib/selenium/webdriver/bidi/log/generic_log_entry.rb,
lib/selenium/webdriver/bidi/log/javascript_log_entry.rb

Defined Under Namespace

Classes: BaseLogEntry, BrowsingContext, ConsoleLogEntry, FilterBy, GenericLogEntry, JavascriptLogEntry, LogHandler, LogInspector, Network, Session, Struct

Instance Method Summary collapse

Constructor Details

#initialize(url:) ⇒ BiDi

Returns a new instance of BiDi.



30
31
32
# File 'lib/selenium/webdriver/bidi.rb', line 30

def initialize(url:)
  @ws = WebSocketConnection.new(url: url)
end

Instance Method Details

#add_callback(event) ⇒ Object



42
43
44
# File 'lib/selenium/webdriver/bidi.rb', line 42

def add_callback(event, &)
  @ws.add_callback(event, &)
end

#callbacksObject



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

def callbacks
  @ws.callbacks
end

#closeObject



34
35
36
# File 'lib/selenium/webdriver/bidi.rb', line 34

def close
  @ws.close
end

#error_message(message) ⇒ Object



62
63
64
# File 'lib/selenium/webdriver/bidi.rb', line 62

def error_message(message)
  "#{message['error']}: #{message['message']}\n#{message['stacktrace']}"
end

#remove_callback(event, id) ⇒ Object



46
47
48
# File 'lib/selenium/webdriver/bidi.rb', line 46

def remove_callback(event, id)
  @ws.remove_callback(event, id)
end

#send_cmd(method, **params) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/selenium/webdriver/bidi.rb', line 54

def send_cmd(method, **params)
  data = {method: method, params: params.compact}
  message = @ws.send_cmd(**data)
  raise Error::WebDriverError, error_message(message) if message['error']

  message['result']
end

#sessionObject



50
51
52
# File 'lib/selenium/webdriver/bidi.rb', line 50

def session
  @session ||= Session.new(self)
end