123456789_123456789_123456789_123456789_123456789_

Class: Selenium::WebDriver::BiDi::Transport Private

Relationships & Source Files
Inherits: Object
Defined in: rb/lib/selenium/webdriver/bidi/transport.rb

Overview

The seam between the generated Protocol layer and the websocket: serializes a command's params, sends it, and parses the reply into its declared type.

Class Method Summary

Instance Method Summary

Constructor Details

.new(connection) ⇒ Transport

[ GitHub ]

  
# File 'rb/lib/selenium/webdriver/bidi/transport.rb', line 28

def initialize(connection)
  @connection = connection
end

Instance Method Details

#error_message(reply) (private)

[ GitHub ]

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

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

#execute(cmd:, params: nil, result: nil)

[ GitHub ]

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

def execute(cmd:, params: nil, result: nil)
  reply = @connection.send_cmd(method: cmd, params: serialize(params))
  raise Error::WebDriverError, error_message(reply) if reply['error']

  value = reply['result']
  result ? result.from_json(value) : value
end

#serialize(params) (private)

[ GitHub ]

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

def serialize(params)
  params&.as_json || {}
end