class Selenium::WebDriver::Remote::OSS::Bridge
Low level bridge to the remote server implementing JSON wire protocol (OSS dialect), through which the rest of the API works. @api private
github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#command-reference @api private
Constants
- COMMANDS
Public Class Methods
new(capabilities, session_id, **opts)
click to toggle source
Calls superclass method
Selenium::WebDriver::Remote::Bridge.new
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 32 def initialize(capabilities, session_id, **opts) @capabilities = capabilities @session_id = session_id super(opts) end
Public Instance Methods
accept_alert()
click to toggle source
alerts
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 74 def accept_alert execute :accept_alert end
action()
click to toggle source
@return [ActionBuilder] @api public
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 312 def action ActionBuilder.new Mouse.new(self), Keyboard.new(self) end
active_element()
click to toggle source
finding elements
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 543 def active_element Element.new self, element_id_from(execute(:get_active_element)) end
Also aliased as: switch_to_active_element
alert=(keys)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 82 def alert=(keys) execute :set_alert_value, {}, {text: keys.to_s} end
alert_text()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 86 def alert_text execute :get_alert_text end
authentication(credentials)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 90 def authentication(credentials) execute :set_authentication, {}, credentials end
available_log_types()
click to toggle source
logs
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 456 def available_log_types types = execute :get_available_log_types Array(types).map(&:to_sym) end
clear_element(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 387 def clear_element(element) execute :clear_element, id: element end
clear_local_storage()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 211 def clear_local_storage execute :clear_local_storage end
clear_session_storage()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 235 def clear_session_storage execute :clear_session_storage end
click()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 330 def click execute :click, {}, {button: 0} end
click_element(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 326 def click_element(element) execute :click_element, id: element end
close()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 140 def close execute :close end
commands(command)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 42 def commands(command) COMMANDS[command] end
context_click()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 338 def context_click execute :click, {}, {button: 2} end
dialect()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 38 def dialect :oss end
dismiss_alert()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 78 def dismiss_alert execute :dismiss_alert end
double_click()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 334 def double_click execute :double_click end
drag_element(element, right_by, down_by)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 395 def drag_element(element, right_by, down_by) execute :drag_element, {id: element}, {x: right_by, y: down_by} end
element_attribute(element, name)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 481 def element_attribute(element, name) execute :get_element_attribute, id: element.ref, name: name end
element_displayed?(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 531 def element_displayed?(element) execute :is_element_displayed, id: element.ref end
element_enabled?(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 523 def element_enabled?(element) execute :is_element_enabled, id: element end
element_location(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 498 def element_location(element) data = execute :get_element_location, id: element Point.new data['x'], data['y'] end
element_location_once_scrolled_into_view(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 511 def element_location_once_scrolled_into_view(element) data = execute :get_element_location_once_scrolled_into_view, id: element Point.new data['x'], data['y'] end
element_property(element, name)
click to toggle source
Backwards compatibility for w3c
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 486 def element_property(element, name) execute_script 'return arguments[0][arguments[1]]', element, name end
element_rect(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 504 def element_rect(element) loc = execute :get_element_location, id: element size = execute :get_element_size, id: element Rectangle.new loc['x'], loc['y'], size['width'], size['height'] end
element_selected?(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 527 def element_selected?(element) execute :is_element_selected, id: element end
element_size(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 517 def element_size(element) data = execute :get_element_size, id: element Dimension.new data['width'], data['height'] end
element_tag_name(element)
click to toggle source
element properties
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 477 def element_tag_name(element) execute :get_element_tag_name, id: element end
element_text(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 494 def element_text(element) execute :get_element_text, id: element end
element_value(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 490 def element_value(element) execute :get_element_value, id: element end
element_value_of_css_property(element, prop)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 535 def element_value_of_css_property(element, prop) execute :get_element_value_of_css_property, id: element, property_name: prop end
execute_async_script(script, *args)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 272 def execute_async_script(script, *args) assert_javascript_enabled result = execute :execute_async_script, {}, {script: script, args: args} unwrap_script_result result end
execute_script(script, *args)
click to toggle source
javascript execution
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 265 def execute_script(script, *args) assert_javascript_enabled result = execute :execute_script, {}, {script: script, args: args} unwrap_script_result result end
find_element_by(how, what, parent = nil)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 549 def find_element_by(how, what, parent = nil) id = if parent execute :find_child_element, {id: parent}, {using: how, value: what} else execute :find_element, {}, {using: how, value: what} end Element.new self, element_id_from(id) end
find_elements_by(how, what, parent = nil)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 559 def find_elements_by(how, what, parent = nil) ids = if parent execute :find_child_elements, {id: parent}, {using: how, value: what} else execute :find_elements, {}, {using: how, value: what} end # see https://github.com/SeleniumHQ/selenium/issues/4555 ids ||= [] ids.map { |id| Element.new self, element_id_from(id) } end
get(url)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 50 def get(url) execute :get, {}, {url: url} end
go_back()
click to toggle source
navigation
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 98 def go_back execute :go_back end
go_forward()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 102 def go_forward execute :go_forward end
implicit_wait_timeout=(milliseconds)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 58 def implicit_wait_timeout=(milliseconds) execute :implicitly_wait, {}, {ms: milliseconds} end
keyboard()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 321 def keyboard WebDriver.logger.deprecate 'Driver#keyboard', 'driver.action.<command>.perform' Keyboard.new self end
local_storage_item(key, value = nil)
click to toggle source
HTML 5
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 195 def local_storage_item(key, value = nil) if value execute :set_local_storage_item, {}, {key: key, value: value} else execute :get_local_storage_item, key: key end end
local_storage_keys()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 207 def local_storage_keys execute :get_local_storage_keys end
local_storage_size()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 215 def local_storage_size execute :get_local_storage_size end
location()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 243 def location obj = execute(:get_location) || {} Location.new obj['latitude'], obj['longitude'], obj['altitude'] end
log(type)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 461 def log(type) data = execute :get_log, {}, {type: type.to_s} Array(data).map do |l| begin LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message') rescue KeyError next end end end
manage()
click to toggle source
cookies
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 283 def manage @manage ||= WebDriver::Manager.new(self) end
maximize_window(handle = :current)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 166 def maximize_window(handle = :current) execute :maximize_window, window_handle: handle end
mouse()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 316 def mouse WebDriver.logger.deprecate 'Driver#mouse', 'driver.action.<command>.perform' Mouse.new self end
mouse_down()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 342 def mouse_down execute :mouse_down end
mouse_move_to(element, x = nil, y = nil)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 350 def mouse_move_to(element, x = nil, y = nil) params = {element: element} if x && y params[:xoffset] = x params[:yoffset] = y end execute :mouse_move_to, {}, params end
mouse_up()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 346 def mouse_up execute :mouse_up end
network_connection()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 253 def network_connection execute :get_network_connection end
network_connection=(type)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 257 def network_connection=(type) execute :set_network_connection, {}, {parameters: {type: type}} end
page_source()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 114 def page_source execute :get_page_source end
quit()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 134 def quit execute :quit http.close rescue *http.quit_errors end
refresh()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 144 def refresh execute :refresh end
remove_local_storage_item(key)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 203 def remove_local_storage_item(key) execute :remove_local_storage_item, key: key end
remove_session_storage_item(key)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 227 def remove_session_storage_item(key) execute :remove_session_storage_item, key: key end
reposition_window(x, y, handle = :current)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 176 def reposition_window(x, y, handle = :current) execute :set_window_position, {window_handle: handle}, {x: x, y: y} end
resize_window(width, height, handle = :current)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 160 def resize_window(width, height, handle = :current) execute :set_window_size, {window_handle: handle}, {width: width, height: height} end
screen_orientation()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 448 def screen_orientation execute :get_screen_orientation end
screen_orientation=(orientation)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 444 def screen_orientation=(orientation) execute :set_screen_orientation, {}, {orientation: orientation} end
screenshot()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 187 def screenshot execute :screenshot end
script_timeout=(milliseconds)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 62 def script_timeout=(milliseconds) execute :set_script_timeout, {}, {ms: milliseconds} end
send_keys_to_active_element(key)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 361 def send_keys_to_active_element(key) execute :send_keys_to_active_element, {}, {value: key} end
send_keys_to_element(element, keys)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 365 def send_keys_to_element(element, keys) # TODO: rework file detectors before Selenium 4.0 if @file_detector local_files = keys.first.split("\n").map { |key| @file_detector.call(Array(key)) }.compact if local_files.any? keys = local_files.map { |local_file| upload(local_file) } keys = keys.join("\n") end end execute :send_keys_to_element, {id: element}, {value: Array(keys)} end
session_capabilities()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 54 def session_capabilities Capabilities.json_create execute(:get_capabilities) end
session_storage_item(key, value = nil)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 219 def session_storage_item(key, value = nil) if value execute :set_session_storage_item, {}, {key: key, value: value} else execute :get_session_storage_item, key: key end end
session_storage_keys()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 231 def session_storage_keys execute :get_session_storage_keys end
session_storage_size()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 239 def session_storage_size execute :get_session_storage_size end
set_location(lat, lon, alt)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 248 def set_location(lat, lon, alt) loc = {latitude: lat, longitude: lon, altitude: alt} execute :set_location, {}, {location: loc} end
status()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 46 def status execute :status end
submit_element(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 391 def submit_element(element) execute :submit_element, id: element end
switch_to_default_content()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 130 def switch_to_default_content switch_to_frame(nil) end
switch_to_frame(id)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 122 def switch_to_frame(id) execute :switch_to_frame, {}, {id: id} end
switch_to_parent_frame()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 126 def switch_to_parent_frame execute :switch_to_parent_frame end
switch_to_window(name)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 118 def switch_to_window(name) execute :switch_to_window, {}, {name: name} end
timeout(type, milliseconds)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 66 def timeout(type, milliseconds) execute :set_timeout, {}, {type: type, ms: milliseconds} end
title()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 110 def title execute :get_title end
touch_double_tap(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 403 def touch_double_tap(element) execute :touch_double_tap, {}, {element: element} end
touch_down(x, y)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 411 def touch_down(x, y) execute :touch_down, {}, {x: x, y: y} end
touch_element_flick(element, right_by, down_by, speed)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 437 def touch_element_flick(element, right_by, down_by, speed) execute :touch_flick, {}, {element: element, xoffset: right_by, yoffset: down_by, speed: speed} end
touch_flick(xspeed, yspeed)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 433 def touch_flick(xspeed, yspeed) execute :touch_flick, {}, {xspeed: xspeed, yspeed: yspeed} end
touch_long_press(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 407 def touch_long_press(element) execute :touch_long_press, {}, {element: element} end
touch_move(x, y)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 419 def touch_move(x, y) execute :touch_move, {}, {x: x, y: y} end
touch_scroll(element, x, y)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 423 def touch_scroll(element, x, y) if element execute :touch_scroll, {}, {element: element, xoffset: x, yoffset: y} else execute :touch_scroll, {}, {xoffset: x, yoffset: y} end end
touch_single_tap(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 399 def touch_single_tap(element) execute :touch_single_tap, {}, {element: element} end
touch_up(x, y)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 415 def touch_up(x, y) execute :touch_up, {}, {x: x, y: y} end
upload(local_file)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 378 def upload(local_file) unless File.file?(local_file) WebDriver.logger.debug("File detector only works with files. #{local_file.inspect} isn`t a file!") raise Error::WebDriverError, "You are trying to work with something that isn't a file." end execute :upload_file, {}, {file: Zipper.zip_file(local_file)} end
url()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 106 def url execute :get_current_url end
window_handle()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 156 def window_handle execute :get_current_window_handle end
window_handles()
click to toggle source
window handling
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 152 def window_handles execute :get_window_handles end
window_position(handle = :current)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 181 def window_position(handle = :current) data = execute :get_window_position, window_handle: handle Point.new data['x'], data['y'] end
window_size(handle = :current)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 170 def window_size(handle = :current) data = execute :get_window_size, window_handle: handle Dimension.new data['width'], data['height'] end
Private Instance Methods
assert_javascript_enabled()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 573 def assert_javascript_enabled return if capabilities.javascript_enabled? raise Error::UnsupportedOperationError, 'underlying webdriver instance does not support javascript' end
execute(*args)
click to toggle source
executes a command on the remote server.
Returns the 'value' of the returned payload
Calls superclass method
Selenium::WebDriver::Remote::Bridge#execute
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 585 def execute(*args) super['value'] end