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 31 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 73 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 311 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 542 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 81 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 85 def alert_text execute :get_alert_text end
authentication(credentials)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 89 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 455 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 386 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 210 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 234 def clear_session_storage execute :clear_session_storage end
click()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 329 def click execute :click, {}, {button: 0} end
click_element(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 325 def click_element(element) execute :click_element, id: element end
close()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 139 def close execute :close end
commands(command)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 41 def commands(command) COMMANDS[command] end
context_click()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 337 def context_click execute :click, {}, {button: 2} end
dialect()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 37 def dialect :oss end
dismiss_alert()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 77 def dismiss_alert execute :dismiss_alert end
double_click()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 333 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 394 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 480 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 530 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 522 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 497 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 510 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 485 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 503 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 526 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 516 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 476 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 493 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 489 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 534 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 271 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 264 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 548 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 558 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 49 def get(url) execute :get, {}, {url: url} end
go_back()
click to toggle source
navigation
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 97 def go_back execute :go_back end
go_forward()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 101 def go_forward execute :go_forward end
implicit_wait_timeout=(milliseconds)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 57 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 320 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 194 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 206 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 214 def local_storage_size execute :get_local_storage_size end
location()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 242 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 460 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
maximize_window(handle = :current)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 165 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 315 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 341 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 349 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 345 def mouse_up execute :mouse_up end
network_connection()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 252 def network_connection execute :get_network_connection end
network_connection=(type)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 256 def network_connection=(type) execute :set_network_connection, {}, {parameters: {type: type}} end
options()
click to toggle source
cookies
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 282 def options @options ||= WebDriver::Options.new(self) end
page_source()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 113 def page_source execute :get_page_source end
quit()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 133 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 143 def refresh execute :refresh end
remove_local_storage_item(key)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 202 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 226 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 175 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 159 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 447 def screen_orientation execute :get_screen_orientation end
screen_orientation=(orientation)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 443 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 186 def screenshot execute :screenshot end
script_timeout=(milliseconds)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 61 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 360 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 364 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 53 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 218 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 230 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 238 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 247 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 45 def status execute :status end
submit_element(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 390 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 129 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 121 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 125 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 117 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 65 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 109 def title execute :get_title end
touch_double_tap(element)
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 402 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 410 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 436 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 432 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 406 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 418 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 422 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 398 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 414 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 377 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 105 def url execute :get_current_url end
window_handle()
click to toggle source
# File lib/selenium/webdriver/remote/oss/bridge.rb, line 155 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 151 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 180 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 169 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 572 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 583 def execute(*args) super['value'] end