Class: Selenium::WebDriver::Remote::Bridge Private
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Remote::Bridge
- Includes:
- BridgeHelper
- Defined in:
- lib/selenium/webdriver/remote/bridge.rb,
lib/selenium/webdriver/remote/commands.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Low level bridge to the remote server, through which the rest of the API works.
Direct Known Subclasses
Chrome::Bridge, Firefox::Bridge, IE::Bridge, PhantomJS::Bridge, Safari::Bridge
Constant Summary collapse
- COMMANDS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#command-reference
{ new_session: [:post, 'session'.freeze], get_capabilities: [:get, 'session/:session_id'.freeze], status: [:get, 'status'.freeze], # # basic driver # get_current_url: [:get, 'session/:session_id/url'.freeze], get: [:post, 'session/:session_id/url'.freeze], go_forward: [:post, 'session/:session_id/forward'.freeze], go_back: [:post, 'session/:session_id/back'.freeze], refresh: [:post, 'session/:session_id/refresh'.freeze], quit: [:delete, 'session/:session_id'.freeze], close: [:delete, 'session/:session_id/window'.freeze], get_page_source: [:get, 'session/:session_id/source'.freeze], get_title: [:get, 'session/:session_id/title'.freeze], find_element: [:post, 'session/:session_id/element'.freeze], find_elements: [:post, 'session/:session_id/elements'.freeze], get_active_element: [:post, 'session/:session_id/element/active'.freeze], # # window handling # get_current_window_handle: [:get, 'session/:session_id/window_handle'.freeze], get_window_handles: [:get, 'session/:session_id/window_handles'.freeze], set_window_size: [:post, 'session/:session_id/window/:window_handle/size'.freeze], set_window_position: [:post, 'session/:session_id/window/:window_handle/position'.freeze], get_window_size: [:get, 'session/:session_id/window/:window_handle/size'.freeze], get_window_position: [:get, 'session/:session_id/window/:window_handle/position'.freeze], maximize_window: [:post, 'session/:session_id/window/:window_handle/maximize'.freeze], # # script execution # execute_script: [:post, 'session/:session_id/execute'.freeze], execute_async_script: [:post, 'session/:session_id/execute_async'.freeze], # # screenshot # screenshot: [:get, 'session/:session_id/screenshot'.freeze], # # alerts # dismiss_alert: [:post, 'session/:session_id/dismiss_alert'.freeze], accept_alert: [:post, 'session/:session_id/accept_alert'.freeze], get_alert_text: [:get, 'session/:session_id/alert_text'.freeze], set_alert_value: [:post, 'session/:session_id/alert_text'.freeze], set_authentication: [:post, 'session/:session_id/alert/credentials'.freeze], # # target locator # switch_to_frame: [:post, 'session/:session_id/frame'.freeze], switch_to_parent_frame: [:post, 'session/:session_id/frame/parent'.freeze], switch_to_window: [:post, 'session/:session_id/window'.freeze], # # options # get_cookies: [:get, 'session/:session_id/cookie'.freeze], add_cookie: [:post, 'session/:session_id/cookie'.freeze], delete_all_cookies: [:delete, 'session/:session_id/cookie'.freeze], delete_cookie: [:delete, 'session/:session_id/cookie/:name'.freeze], # # timeouts # implicitly_wait: [:post, 'session/:session_id/timeouts/implicit_wait'.freeze], set_script_timeout: [:post, 'session/:session_id/timeouts/async_script'.freeze], set_timeout: [:post, 'session/:session_id/timeouts'.freeze], # # element # describe_element: [:get, 'session/:session_id/element/:id'.freeze], find_child_element: [:post, 'session/:session_id/element/:id/element'.freeze], find_child_elements: [:post, 'session/:session_id/element/:id/elements'.freeze], click_element: [:post, 'session/:session_id/element/:id/click'.freeze], submit_element: [:post, 'session/:session_id/element/:id/submit'.freeze], get_element_value: [:get, 'session/:session_id/element/:id/value'.freeze], send_keys_to_element: [:post, 'session/:session_id/element/:id/value'.freeze], upload_file: [:post, 'session/:session_id/file'.freeze], get_element_tag_name: [:get, 'session/:session_id/element/:id/name'.freeze], clear_element: [:post, 'session/:session_id/element/:id/clear'.freeze], is_element_selected: [:get, 'session/:session_id/element/:id/selected'.freeze], is_element_enabled: [:get, 'session/:session_id/element/:id/enabled'.freeze], get_element_attribute: [:get, 'session/:session_id/element/:id/attribute/:name'.freeze], element_equals: [:get, 'session/:session_id/element/:id/equals/:other'.freeze], is_element_displayed: [:get, 'session/:session_id/element/:id/displayed'.freeze], get_element_location: [:get, 'session/:session_id/element/:id/location'.freeze], get_element_location_once_scrolled_into_view: [:get, 'session/:session_id/element/:id/location_in_view'.freeze], get_element_size: [:get, 'session/:session_id/element/:id/size'.freeze], drag_element: [:post, 'session/:session_id/element/:id/drag'.freeze], get_element_value_of_css_property: [:get, 'session/:session_id/element/:id/css/:property_name'.freeze], get_element_text: [:get, 'session/:session_id/element/:id/text'.freeze], # # rotatable # get_screen_orientation: [:get, 'session/:session_id/orientation'.freeze], set_screen_orientation: [:post, 'session/:session_id/orientation'.freeze], # # interactions API # click: [:post, 'session/:session_id/click'.freeze], double_click: [:post, 'session/:session_id/doubleclick'.freeze], mouse_down: [:post, 'session/:session_id/buttondown'.freeze], mouse_up: [:post, 'session/:session_id/buttonup'.freeze], mouse_move_to: [:post, 'session/:session_id/moveto'.freeze], send_modifier_key_to_active_element: [:post, 'session/:session_id/modifier'.freeze], send_keys_to_active_element: [:post, 'session/:session_id/keys'.freeze], # # html 5 # execute_sql: [:post, 'session/:session_id/execute_sql'.freeze], get_location: [:get, 'session/:session_id/location'.freeze], set_location: [:post, 'session/:session_id/location'.freeze], get_app_cache: [:get, 'session/:session_id/application_cache'.freeze], get_app_cache_status: [:get, 'session/:session_id/application_cache/status'.freeze], clear_app_cache: [:delete, 'session/:session_id/application_cache/clear'.freeze], get_network_connection: [:get, 'session/:session_id/network_connection'.freeze], set_network_connection: [:post, 'session/:session_id/network_connection'.freeze], get_local_storage_item: [:get, 'session/:session_id/local_storage/key/:key'.freeze], remove_local_storage_item: [:delete, 'session/:session_id/local_storage/key/:key'.freeze], get_local_storage_keys: [:get, 'session/:session_id/local_storage'.freeze], set_local_storage_item: [:post, 'session/:session_id/local_storage'.freeze], clear_local_storage: [:delete, 'session/:session_id/local_storage'.freeze], get_local_storage_size: [:get, 'session/:session_id/local_storage/size'.freeze], get_session_storage_item: [:get, 'session/:session_id/session_storage/key/:key'.freeze], remove_session_storage_item: [:delete, 'session/:session_id/session_storage/key/:key'.freeze], get_session_storage_keys: [:get, 'session/:session_id/session_storage'.freeze], set_session_storage_item: [:post, 'session/:session_id/session_storage'.freeze], clear_session_storage: [:delete, 'session/:session_id/session_storage'.freeze], get_session_storage_size: [:get, 'session/:session_id/session_storage/size'.freeze], # # ime # ime_get_available_engines: [:get, 'session/:session_id/ime/available_engines'.freeze], ime_get_active_engine: [:get, 'session/:session_id/ime/active_engine'.freeze], ime_is_activated: [:get, 'session/:session_id/ime/activated'.freeze], ime_deactivate: [:post, 'session/:session_id/ime/deactivate'.freeze], ime_activate_engine: [:post, 'session/:session_id/ime/activate'.freeze], # # touch # touch_single_tap: [:post, 'session/:session_id/touch/click'.freeze], touch_double_tap: [:post, 'session/:session_id/touch/doubleclick'.freeze], touch_long_press: [:post, 'session/:session_id/touch/longclick'.freeze], touch_down: [:post, 'session/:session_id/touch/down'.freeze], touch_up: [:post, 'session/:session_id/touch/up'.freeze], touch_move: [:post, 'session/:session_id/touch/move'.freeze], touch_scroll: [:post, 'session/:session_id/touch/scroll'.freeze], touch_flick: [:post, 'session/:session_id/touch/flick'.freeze], # # logs # get_available_log_types: [:get, 'session/:session_id/log/types'.freeze], get_log: [:post, 'session/:session_id/log'.freeze] }.freeze
Instance Attribute Summary collapse
- #capabilities ⇒ Object readonly private
- #context ⇒ Object private
- #file_detector ⇒ Object private
- #http ⇒ Object private
Instance Method Summary collapse
-
#accept_alert ⇒ Object
private
alerts.
- #action ⇒ ActionBuilder
-
#active_element ⇒ Object
(also: #switch_to_active_element)
private
finding elements.
- #add_cookie(cookie) ⇒ Object private
- #alert=(keys) ⇒ Object private
- #alert_text ⇒ Object private
- #authentication(credentials) ⇒ Object private
-
#available_log_types ⇒ Object
private
logs.
- #browser ⇒ Object private
- #clear_element(element) ⇒ Object private
- #clear_local_storage ⇒ Object private
- #clear_session_storage ⇒ Object private
- #click ⇒ Object private
- #click_element(element) ⇒ Object private
- #close ⇒ Object private
- #commands(command) ⇒ Object private
- #context_click ⇒ Object private
- #cookies ⇒ Object private
- #create_session(desired_capabilities) ⇒ Object private
- #delete_all_cookies ⇒ Object private
- #delete_cookie(name) ⇒ Object private
- #dismiss_alert ⇒ Object private
- #double_click ⇒ Object private
- #drag_element(element, right_by, down_by) ⇒ Object private
- #driver_extensions ⇒ Object private
- #element_attribute(element, name) ⇒ Object private
- #element_displayed?(element) ⇒ Boolean private
- #element_enabled?(element) ⇒ Boolean private
- #element_location(element) ⇒ Object private
- #element_location_once_scrolled_into_view(element) ⇒ Object private
-
#element_property(element, name) ⇒ Object
private
Backwards compatibility for w3c.
- #element_selected?(element) ⇒ Boolean private
- #element_size(element) ⇒ Object private
-
#element_tag_name(element) ⇒ Object
private
element properties.
- #element_text(element) ⇒ Object private
- #element_value(element) ⇒ Object private
- #element_value_of_css_property(element, prop) ⇒ Object private
- #execute_async_script(script, *args) ⇒ Object private
-
#execute_script(script, *args) ⇒ Object
private
javascript execution.
- #find_element_by(how, what, parent = nil) ⇒ Object private
- #find_elements_by(how, what, parent = nil) ⇒ Object private
- #get(url) ⇒ Object private
-
#go_back ⇒ Object
private
navigation.
- #go_forward ⇒ Object private
- #implicit_wait_timeout=(milliseconds) ⇒ Object private
-
#initialize(opts = {}) ⇒ Bridge
constructor
private
A new instance of Bridge.
- #keyboard ⇒ Object private
-
#local_storage_item(key, value = nil) ⇒ Object
private
HTML 5.
- #local_storage_keys ⇒ Object private
- #local_storage_size ⇒ Object private
- #location ⇒ Object private
- #log(type) ⇒ Object private
- #maximize_window(handle = :current) ⇒ Object private
- #mouse ⇒ Object private
- #mouse_down ⇒ Object private
- #mouse_move_to(element, x = nil, y = nil) ⇒ Object private
- #mouse_up ⇒ Object private
- #network_connection ⇒ Object private
- #network_connection=(type) ⇒ Object private
-
#options ⇒ Object
private
cookies.
- #page_source ⇒ Object private
- #quit ⇒ Object private
- #refresh ⇒ Object private
- #remove_local_storage_item(key) ⇒ Object private
- #remove_session_storage_item(key) ⇒ Object private
- #reposition_window(x, y, handle = :current) ⇒ Object private
- #resize_window(width, height, handle = :current) ⇒ Object private
- #screen_orientation ⇒ Object private
- #screen_orientation=(orientation) ⇒ Object private
- #screenshot ⇒ Object private
- #script_timeout=(milliseconds) ⇒ Object private
- #send_keys_to_active_element(key) ⇒ Object private
- #send_keys_to_element(element, keys) ⇒ Object private
- #session_capabilities ⇒ Object private
-
#session_id ⇒ Object
private
Returns the current session ID.
- #session_storage_item(key, value = nil) ⇒ Object private
- #session_storage_keys ⇒ Object private
- #session_storage_size ⇒ Object private
- #set_location(lat, lon, alt) ⇒ Object private
- #status ⇒ Object private
- #submit_element(element) ⇒ Object private
- #switch_to_default_content ⇒ Object private
- #switch_to_frame(id) ⇒ Object private
- #switch_to_parent_frame ⇒ Object private
- #switch_to_window(name) ⇒ Object private
- #timeout(type, milliseconds) ⇒ Object private
- #title ⇒ Object private
- #touch_double_tap(element) ⇒ Object private
- #touch_down(x, y) ⇒ Object private
- #touch_element_flick(element, right_by, down_by, speed) ⇒ Object private
- #touch_flick(xspeed, yspeed) ⇒ Object private
- #touch_long_press(element) ⇒ Object private
- #touch_move(x, y) ⇒ Object private
- #touch_scroll(element, x, y) ⇒ Object private
- #touch_single_tap(element) ⇒ Object private
- #touch_up(x, y) ⇒ Object private
- #upload(local_file) ⇒ Object private
- #url ⇒ Object private
- #window_handle ⇒ Object private
-
#window_handles ⇒ Object
private
window handling.
- #window_position(handle = :current) ⇒ Object private
- #window_size(handle = :current) ⇒ Object private
Methods included from BridgeHelper
#element_id_from, #parse_cookie_string, #unwrap_script_result
Constructor Details
#initialize(opts = {}) ⇒ Bridge
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Bridge.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 39 def initialize(opts = {}) opts = opts.dup if opts.key?(:port) WebDriver.logger.warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze [DEPRECATION] `:port` is deprecated. Use `:url` with full path DEPRECATE end port = opts.delete(:port) || 4444 http_client = opts.delete(:http_client) { Http::Default.new } desired_capabilities = opts.delete(:desired_capabilities) { Capabilities.firefox } url = opts.delete(:url) { "http://#{Platform.localhost}:#{port}/wd/hub" } unless opts.empty? raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}" end if desired_capabilities.is_a?(Symbol) unless Capabilities.respond_to?(desired_capabilities) raise Error::WebDriverError, "invalid desired capability: #{desired_capabilities.inspect}" end desired_capabilities = Capabilities.send(desired_capabilities) end uri = url.is_a?(URI) ? url : URI.parse(url) uri.path += '/' unless uri.path =~ %r{\/$} http_client.server_url = uri @http = http_client @capabilities = create_session(desired_capabilities) @file_detector = nil end |
Instance Attribute Details
#capabilities ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 33 def capabilities @capabilities end |
#context ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 32 def context @context end |
#file_detector ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 32 def file_detector @file_detector end |
#http ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 32 def http @http end |
Instance Method Details
#accept_alert ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
alerts
145 146 147 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 145 def accept_alert execute :accept_alert end |
#action ⇒ ActionBuilder
383 384 385 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 383 def action ActionBuilder.new Mouse.new(self), Keyboard.new(self) end |
#active_element ⇒ Object Also known as: switch_to_active_element
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
finding elements
608 609 610 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 608 def active_element Element.new self, element_id_from(execute(:get_active_element)) end |
#add_cookie(cookie) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
358 359 360 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 358 def () execute :add_cookie, {}, {cookie: } end |
#alert=(keys) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
153 154 155 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 153 def alert=(keys) execute :set_alert_value, {}, {text: keys.to_s} end |
#alert_text ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
157 158 159 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 157 def alert_text execute :get_alert_text end |
#authentication(credentials) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
161 162 163 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 161 def authentication(credentials) execute :set_authentication, {}, credentials end |
#available_log_types ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
logs
528 529 530 531 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 528 def available_log_types types = execute :get_available_log_types Array(types).map(&:to_sym) end |
#browser ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
76 77 78 79 80 81 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 76 def browser @browser ||= ( name = @capabilities.browser_name name ? name.tr(' ', '_').to_sym : 'unknown' ) end |
#clear_element(element) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
459 460 461 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 459 def clear_element(element) execute :clear_element, id: element end |
#clear_local_storage ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
282 283 284 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 282 def clear_local_storage execute :clear_local_storage end |
#clear_session_storage ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
306 307 308 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 306 def clear_session_storage execute :clear_session_storage end |
#click ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
407 408 409 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 407 def click execute :click, {}, {button: 0} end |
#click_element(element) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
403 404 405 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 403 def click_element(element) execute :click_element, id: element end |
#close ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
211 212 213 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 211 def close execute :close end |
#commands(command) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
97 98 99 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 97 def commands(command) COMMANDS[command] end |
#context_click ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
415 416 417 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 415 def context_click execute :click, {}, {button: 2} end |
#cookies ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
366 367 368 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 366 def execute :get_cookies end |
#create_session(desired_capabilities) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
109 110 111 112 113 114 115 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 109 def create_session(desired_capabilities) resp = raw_execute :new_session, {}, {desiredCapabilities: desired_capabilities} @session_id = resp['sessionId'] return Capabilities.json_create resp['value'] if @session_id raise Error::WebDriverError, 'no sessionId in returned payload' end |
#delete_all_cookies ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
370 371 372 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 370 def execute :delete_all_cookies end |
#delete_cookie(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
362 363 364 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 362 def (name) execute :delete_cookie, name: name end |
#dismiss_alert ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
149 150 151 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 149 def dismiss_alert execute :dismiss_alert end |
#double_click ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
411 412 413 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 411 def double_click execute :double_click end |
#drag_element(element, right_by, down_by) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
467 468 469 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 467 def drag_element(element, right_by, down_by) execute :drag_element, {id: element}, {x: right_by, y: down_by} end |
#driver_extensions ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 83 def driver_extensions [ DriverExtensions::UploadsFiles, DriverExtensions::TakesScreenshot, DriverExtensions::HasSessionId, DriverExtensions::Rotatable, DriverExtensions::HasTouchScreen, DriverExtensions::HasLocation, DriverExtensions::HasNetworkConnection, DriverExtensions::HasRemoteStatus, DriverExtensions::HasWebStorage ] end |
#element_attribute(element, name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
553 554 555 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 553 def element_attribute(element, name) execute :get_element_attribute, id: element.ref, name: name end |
#element_displayed?(element) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
596 597 598 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 596 def element_displayed?(element) execute :is_element_displayed, id: element end |
#element_enabled?(element) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
588 589 590 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 588 def element_enabled?(element) execute :is_element_enabled, id: element end |
#element_location(element) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
570 571 572 573 574 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 570 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
576 577 578 579 580 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 576 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Backwards compatibility for w3c
558 559 560 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 558 def element_property(element, name) execute_script 'return arguments[0][arguments[1]]', element, name end |
#element_selected?(element) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
592 593 594 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 592 def element_selected?(element) execute :is_element_selected, id: element end |
#element_size(element) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
582 583 584 585 586 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 582 def element_size(element) data = execute :get_element_size, id: element Dimension.new data['width'], data['height'] end |
#element_tag_name(element) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
element properties
549 550 551 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 549 def element_tag_name(element) execute :get_element_tag_name, id: element end |
#element_text(element) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
566 567 568 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 566 def element_text(element) execute :get_element_text, id: element end |
#element_value(element) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
562 563 564 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 562 def element_value(element) execute :get_element_value, id: element end |
#element_value_of_css_property(element, prop) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
600 601 602 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 600 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
343 344 345 346 347 348 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 343 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
javascript execution
336 337 338 339 340 341 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 336 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
614 615 616 617 618 619 620 621 622 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 614 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
624 625 626 627 628 629 630 631 632 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 624 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 ids.map { |id| Element.new self, element_id_from(id) } end |
#get(url) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
121 122 123 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 121 def get(url) execute :get, {}, {url: url} end |
#go_back ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
navigation
169 170 171 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 169 def go_back execute :go_back end |
#go_forward ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
173 174 175 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 173 def go_forward execute :go_forward end |
#implicit_wait_timeout=(milliseconds) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
129 130 131 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 129 def implicit_wait_timeout=(milliseconds) execute :implicitly_wait, {}, {ms: milliseconds} end |
#keyboard ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
395 396 397 398 399 400 401 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 395 def keyboard WebDriver.logger.warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze [DEPRECATION] `Driver#keyboard` is deprecated with w3c implementation. Instead use driver.action.<command>.perform DEPRECATE Keyboard.new self end |
#local_storage_item(key, value = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
HTML 5
266 267 268 269 270 271 272 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 266 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 ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
278 279 280 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 278 def local_storage_keys execute :get_local_storage_keys end |
#local_storage_size ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
286 287 288 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 286 def local_storage_size execute :get_local_storage_size end |
#location ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
314 315 316 317 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 314 def location obj = execute(:get_location) || {} Location.new obj['latitude'], obj['longitude'], obj['altitude'] end |
#log(type) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
533 534 535 536 537 538 539 540 541 542 543 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 533 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
237 238 239 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 237 def maximize_window(handle = :current) execute :maximize_window, window_handle: handle end |
#mouse ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
387 388 389 390 391 392 393 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 387 def mouse WebDriver.logger.warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze [DEPRECATION] `Driver#mouse` is deprecated with w3c implementation. Instead use driver.action.<command>.perform DEPRECATE Mouse.new self end |
#mouse_down ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
419 420 421 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 419 def mouse_down execute :mouse_down end |
#mouse_move_to(element, x = nil, y = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
427 428 429 430 431 432 433 434 435 436 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 427 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 ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
423 424 425 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 423 def mouse_up execute :mouse_up end |
#network_connection ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
324 325 326 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 324 def network_connection execute :get_network_connection end |
#network_connection=(type) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
328 329 330 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 328 def network_connection=(type) execute :set_network_connection, {}, {parameters: {type: type}} end |
#options ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
cookies
354 355 356 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 354 def @options ||= WebDriver::Options.new(self) end |
#page_source ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
185 186 187 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 185 def page_source execute :get_page_source end |
#quit ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
205 206 207 208 209 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 205 def quit execute :quit http.close rescue *http.quit_errors end |
#refresh ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
215 216 217 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 215 def refresh execute :refresh end |
#remove_local_storage_item(key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
274 275 276 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 274 def remove_local_storage_item(key) execute :remove_local_storage_item, key: key end |
#remove_session_storage_item(key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
298 299 300 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 298 def remove_session_storage_item(key) execute :remove_session_storage_item, key: key end |
#reposition_window(x, y, handle = :current) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
247 248 249 250 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 247 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
231 232 233 234 235 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 231 def resize_window(width, height, handle = :current) execute :set_window_size, {window_handle: handle}, {width: width, height: height} end |
#screen_orientation ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
520 521 522 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 520 def screen_orientation execute :get_screen_orientation end |
#screen_orientation=(orientation) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
516 517 518 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 516 def screen_orientation=(orientation) execute :set_screen_orientation, {}, {orientation: orientation} end |
#screenshot ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
258 259 260 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 258 def screenshot execute :screenshot end |
#script_timeout=(milliseconds) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
133 134 135 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 133 def script_timeout=(milliseconds) execute :set_script_timeout, {}, {ms: milliseconds} end |
#send_keys_to_active_element(key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
438 439 440 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 438 def send_keys_to_active_element(key) execute :send_keys_to_active_element, {}, {value: key} end |
#send_keys_to_element(element, keys) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
442 443 444 445 446 447 448 449 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 442 def send_keys_to_element(element, keys) if @file_detector local_file = @file_detector.call(keys) keys = upload(local_file) if local_file end execute :send_keys_to_element, {id: element}, {value: Array(keys)} end |
#session_capabilities ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
125 126 127 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 125 def session_capabilities Capabilities.json_create execute(:get_capabilities) end |
#session_id ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the current session ID.
105 106 107 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 105 def session_id @session_id || raise(Error::WebDriverError, 'no current session exists') end |
#session_storage_item(key, value = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
290 291 292 293 294 295 296 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 290 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 ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
302 303 304 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 302 def session_storage_keys execute :get_session_storage_keys end |
#session_storage_size ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
310 311 312 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 310 def session_storage_size execute :get_session_storage_size end |
#set_location(lat, lon, alt) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
319 320 321 322 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 319 def set_location(lat, lon, alt) loc = {latitude: lat, longitude: lon, altitude: alt} execute :set_location, {}, {location: loc} end |
#status ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
117 118 119 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 117 def status execute :status end |
#submit_element(element) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
463 464 465 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 463 def submit_element(element) execute :submit_element, id: element end |
#switch_to_default_content ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
201 202 203 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 201 def switch_to_default_content switch_to_frame(nil) end |
#switch_to_frame(id) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
193 194 195 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 193 def switch_to_frame(id) execute :switch_to_frame, {}, {id: id} end |
#switch_to_parent_frame ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
197 198 199 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 197 def switch_to_parent_frame execute :switch_to_parent_frame end |
#switch_to_window(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
189 190 191 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 189 def switch_to_window(name) execute :switch_to_window, {}, {name: name} end |
#timeout(type, milliseconds) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
137 138 139 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 137 def timeout(type, milliseconds) execute :set_timeout, {}, {type: type, ms: milliseconds} end |
#title ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
181 182 183 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 181 def title execute :get_title end |
#touch_double_tap(element) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
475 476 477 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 475 def touch_double_tap(element) execute :touch_double_tap, {}, {element: element} end |
#touch_down(x, y) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
483 484 485 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 483 def touch_down(x, y) execute :touch_down, {}, {x: x, y: y} end |
#touch_element_flick(element, right_by, down_by, speed) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
509 510 511 512 513 514 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 509 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
505 506 507 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 505 def touch_flick(xspeed, yspeed) execute :touch_flick, {}, {xspeed: xspeed, yspeed: yspeed} end |
#touch_long_press(element) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
479 480 481 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 479 def touch_long_press(element) execute :touch_long_press, {}, {element: element} end |
#touch_move(x, y) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
491 492 493 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 491 def touch_move(x, y) execute :touch_move, {}, {x: x, y: y} end |
#touch_scroll(element, x, y) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
495 496 497 498 499 500 501 502 503 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 495 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) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
471 472 473 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 471 def touch_single_tap(element) execute :touch_single_tap, {}, {element: element} end |
#touch_up(x, y) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
487 488 489 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 487 def touch_up(x, y) execute :touch_up, {}, {x: x, y: y} end |
#upload(local_file) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
451 452 453 454 455 456 457 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 451 def upload(local_file) unless File.file?(local_file) raise Error::WebDriverError, "you may only upload files: #{local_file.inspect}" end execute :upload_file, {}, {file: Zipper.zip_file(local_file)} end |
#url ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
177 178 179 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 177 def url execute :get_current_url end |
#window_handle ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
227 228 229 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 227 def window_handle execute :get_current_window_handle end |
#window_handles ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
window handling
223 224 225 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 223 def window_handles execute :get_window_handles end |
#window_position(handle = :current) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
252 253 254 255 256 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 252 def window_position(handle = :current) data = execute :get_window_position, window_handle: handle Point.new data['x'], data['y'] end |
#window_size(handle = :current) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
241 242 243 244 245 |
# File 'lib/selenium/webdriver/remote/bridge.rb', line 241 def window_size(handle = :current) data = execute :get_window_size, window_handle: handle Dimension.new data['width'], data['height'] end |