Class: Selenium::WebDriver::Remote::W3CBridge Private
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Remote::W3CBridge
- Includes:
- Atoms, BridgeHelper
- Defined in:
- lib/selenium/webdriver/remote/w3c_bridge.rb,
lib/selenium/webdriver/remote/w3c_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
Constant Summary collapse
- QUIT_ERRORS =
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.
[IOError].freeze
- 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.
{ # # session handling # new_session: [:post, 'session'.freeze], delete_session: [:delete, 'session/:session_id'.freeze], # # basic driver # get: [:post, 'session/:session_id/url'.freeze], get_current_url: [:get, 'session/:session_id/url'.freeze], back: [:post, 'session/:session_id/back'.freeze], forward: [:post, 'session/:session_id/forward'.freeze], refresh: [:post, 'session/:session_id/refresh'.freeze], get_title: [:get, 'session/:session_id/title'.freeze], # # window and Frame handling # get_window_handle: [:get, 'session/:session_id/window'.freeze], close_window: [:delete, 'session/:session_id/window'.freeze], switch_to_window: [:post, 'session/:session_id/window'.freeze], get_window_handles: [:get, 'session/:session_id/window/handles'.freeze], fullscreen_window: [:post, 'session/:session_id/window/fullscreen'.freeze], maximize_window: [:post, 'session/:session_id/window/maximize'.freeze], set_window_size: [:post, 'session/:session_id/window/size'.freeze], get_window_size: [:get, 'session/:session_id/window/size'.freeze], set_window_position: [:post, 'session/:session_id/window/position'.freeze], get_window_position: [:get, 'session/:session_id/window/position'.freeze], switch_to_frame: [:post, 'session/:session_id/frame'.freeze], switch_to_parent_frame: [:post, 'session/:session_id/frame/parent'.freeze], # # element # find_element: [:post, 'session/:session_id/element'.freeze], find_elements: [:post, 'session/:session_id/elements'.freeze], find_child_element: [:post, 'session/:session_id/element/:id/element'.freeze], find_child_elements: [:post, 'session/:session_id/element/:id/elements'.freeze], get_active_element: [:get, 'session/:session_id/element/active'.freeze], is_element_selected: [:get, 'session/:session_id/element/:id/selected'.freeze], get_element_attribute: [:get, 'session/:session_id/element/:id/attribute/:name'.freeze], get_element_property: [:get, 'session/:session_id/element/:id/property/:name'.freeze], get_element_css_value: [:get, 'session/:session_id/element/:id/css/:property_name'.freeze], get_element_text: [:get, 'session/:session_id/element/:id/text'.freeze], get_element_tag_name: [:get, 'session/:session_id/element/:id/name'.freeze], get_element_rect: [:get, 'session/:session_id/element/:id/rect'.freeze], is_element_enabled: [:get, 'session/:session_id/element/:id/enabled'.freeze], # # document handling # get_page_source: [:get, '/session/:session_id/source'.freeze], execute_script: [:post, 'session/:session_id/execute/sync'.freeze], execute_async_script: [:post, 'session/:session_id/execute/async'.freeze], # # cookies # get_all_cookies: [:get, 'session/:session_id/cookie'.freeze], get_cookie: [:get, 'session/:session_id/cookie/:name'.freeze], add_cookie: [:post, 'session/:session_id/cookie'.freeze], delete_cookie: [:delete, 'session/:session_id/cookie/:name'.freeze], delete_all_cookies: [:delete, 'session/:session_id/cookie'.freeze], # # timeouts # set_timeout: [:post, 'session/:session_id/timeouts'.freeze], # # actions # actions: [:post, 'session/:session_id/actions'.freeze], release_actions: [:delete, 'session/:session_id/actions'.freeze], # # Element Operations # element_click: [:post, 'session/:session_id/element/:id/click'.freeze], element_tap: [:post, 'session/:session_id/element/:id/tap'.freeze], element_clear: [:post, 'session/:session_id/element/:id/clear'.freeze], element_send_keys: [:post, 'session/:session_id/element/:id/value'.freeze], # # alerts # dismiss_alert: [:post, 'session/:session_id/alert/dismiss'.freeze], accept_alert: [:post, 'session/:session_id/alert/accept'.freeze], get_alert_text: [:get, 'session/:session_id/alert/text'.freeze], send_alert_text: [:post, 'session/:session_id/alert/text'.freeze], # # screenshot # take_screenshot: [:get, 'session/:session_id/screenshot'.freeze], take_element_screenshot: [:get, 'session/:session_id/element/:id/screenshot'.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(async = false) ⇒ Object
(also: #actions)
private
actions.
-
#active_element ⇒ Object
(also: #switch_to_active_element)
private
finding elements.
- #add_cookie(cookie) ⇒ Object private
- #alert=(keys) ⇒ Object private
- #alert_text ⇒ Object private
- #browser ⇒ Object private
- #clear_element(element) ⇒ Object private
- #clear_local_storage ⇒ Object private
- #clear_session_storage ⇒ Object private
- #click_element(element) ⇒ Object private
- #close ⇒ Object private
- #commands(command) ⇒ Object private
- #cookie(name) ⇒ 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
- #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
- #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
- #full_screen_window ⇒ Object private
- #get(url) ⇒ Object private
-
#go_back ⇒ Object
private
navigation.
- #go_forward ⇒ Object private
- #implicit_wait_timeout=(milliseconds) ⇒ Object private
-
#initialize(opts = {}) ⇒ W3CBridge
constructor
private
Initializes the bridge with the given server URL.
- #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
- #maximize_window(handle = :current) ⇒ Object private
- #mouse ⇒ 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
- #release_actions ⇒ Object private
- #remove_local_storage_item(key) ⇒ Object private
- #remove_session_storage_item(key) ⇒ Object private
- #reposition_window(x, y) ⇒ 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_actions(data) ⇒ Object private
-
#send_keys_to_element(element, keys) ⇒ Object
private
TODO: - Implement file verification.
-
#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
- #url ⇒ Object private
- #window_handle ⇒ Object private
-
#window_handles ⇒ Object
private
window handling.
- #window_position ⇒ 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 = {}) ⇒ W3CBridge
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.
Initializes the bridge with the given server URL.
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 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 46 def initialize(opts = {}) opts = opts.dup port = opts.delete(:port) || 4444 http_client = opts.delete(:http_client) { Http::Default.new } desired_capabilities = opts.delete(:desired_capabilities) { W3CCapabilities.firefox } url = opts.delete(:url) { "http://#{Platform.localhost}:#{port}/wd/hub" } desired_capabilities = W3CCapabilities.send(desired_capabilities) if desired_capabilities.is_a? Symbol desired_capabilities[:marionette] = opts.delete(:marionette) unless opts[:marionette].nil? unless opts.empty? raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}" 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.
36 37 38 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 36 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.
35 36 37 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 35 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.
35 36 37 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 35 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.
35 36 37 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 35 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
140 141 142 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 140 def accept_alert execute :accept_alert end |
#action(async = false) ⇒ Object Also known as: actions
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.
actions
382 383 384 385 386 387 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 382 def action(async = false) W3CActionBuilder.new self, Interactions.pointer(:mouse, name: 'mouse'), Interactions.key('keyboard'), async 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
544 545 546 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 544 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/w3c_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.
148 149 150 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 148 def alert=(keys) execute :send_alert_text, {}, {value: keys.split(//)} 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.
152 153 154 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 152 def alert_text execute :get_alert_text 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.
73 74 75 76 77 78 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 73 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.
415 416 417 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 415 def clear_element(element) execute :element_clear, 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.
288 289 290 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 288 def clear_local_storage execute_script('localStorage.clear()') 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.
312 313 314 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 312 def clear_session_storage execute_script('sessionStorage.clear()') 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.
406 407 408 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 406 def click_element(element) execute :element_click, 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.
207 208 209 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 207 def close execute :close_window 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.
91 92 93 94 95 96 97 98 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 91 def commands(command) case command when :status, :is_element_displayed Bridge::COMMANDS[command] else COMMANDS[command] end end |
#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.
366 367 368 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 366 def (name) execute :get_cookie, name: name 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.
370 371 372 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 370 def execute :get_all_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.
108 109 110 111 112 113 114 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 108 def create_session(desired_capabilities) resp = raw_execute :new_session, {}, {desiredCapabilities: desired_capabilities} @session_id = resp['sessionId'] return W3CCapabilities.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.
374 375 376 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 374 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/w3c_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.
144 145 146 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 144 def dismiss_alert execute :dismiss_alert 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.
426 427 428 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 426 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.
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 80 def driver_extensions [ DriverExtensions::UploadsFiles, DriverExtensions::TakesScreenshot, DriverExtensions::HasSessionId, DriverExtensions::Rotatable, 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.
491 492 493 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 491 def element_attribute(element, name) execute_atom :getAttribute, element, 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.
532 533 534 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 532 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.
524 525 526 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 524 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.
507 508 509 510 511 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 507 def element_location(element) data = execute :get_element_rect, 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.
513 514 515 516 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 513 def element_location_once_scrolled_into_view(element) send_keys_to_element(element, ['']) element_location(element) 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.
495 496 497 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 495 def element_property(element, name) execute :get_element_property, id: element.ref, name: 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.
528 529 530 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 528 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.
518 519 520 521 522 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 518 def element_size(element) data = execute :get_element_rect, 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
487 488 489 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 487 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.
503 504 505 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 503 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.
499 500 501 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 499 def element_value(element) element_property element, 'value' 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.
536 537 538 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 536 def element_value_of_css_property(element, prop) execute :get_element_css_value, 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.
345 346 347 348 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 345 def execute_async_script(script, *args) 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
340 341 342 343 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 340 def execute_script(script, *args) 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.
550 551 552 553 554 555 556 557 558 559 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 550 def find_element_by(how, what, parent = nil) how, what = convert_locators(how, what) 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.
561 562 563 564 565 566 567 568 569 570 571 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 561 def find_elements_by(how, what, parent = nil) how, what = convert_locators(how, what) 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 |
#full_screen_window ⇒ 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.
242 243 244 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 242 def full_screen_window execute :fullscreen_window 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.
120 121 122 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 120 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
160 161 162 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 160 def go_back execute :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.
164 165 166 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 164 def go_forward execute :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.
124 125 126 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 124 def implicit_wait_timeout=(milliseconds) timeout('implicit', 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.
394 395 396 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 394 def keyboard raise Error::UnsupportedOperationError, '#keyboard is no longer supported, use #action instead' 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
272 273 274 275 276 277 278 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 272 def local_storage_item(key, value = nil) if value execute_script("localStorage.setItem('#{key}', '#{value}')") else execute_script("return localStorage.getItem('#{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.
284 285 286 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 284 def local_storage_keys execute_script('return Object.keys(localStorage)') 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.
292 293 294 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 292 def local_storage_size execute_script('return localStorage.length') 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.
320 321 322 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 320 def location raise Error::UnsupportedOperationError, 'The W3C standard does not currently support getting location' 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.
235 236 237 238 239 240 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 235 def maximize_window(handle = :current) unless handle == :current raise Error::UnsupportedOperationError, 'Switch to desired window before changing its size' end execute :maximize_window 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.
390 391 392 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 390 def mouse raise Error::UnsupportedOperationError, '#mouse is no longer supported, use #action instead' 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.
328 329 330 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 328 def network_connection raise Error::UnsupportedOperationError, 'The W3C standard does not currently support getting 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.
332 333 334 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 332 def network_connection=(_type) raise Error::UnsupportedOperationError, 'The W3C standard does not currently support setting network connection' 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/w3c_bridge.rb', line 354 def @options ||= WebDriver::W3COptions.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.
176 177 178 179 180 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 176 def page_source execute_script('var source = document.documentElement.outerHTML;' \ 'if (!source) { source = new XMLSerializer().serializeToString(document); }' \ 'return 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.
201 202 203 204 205 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 201 def quit execute :delete_session http.close rescue *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.
211 212 213 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 211 def refresh execute :refresh end |
#release_actions ⇒ 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.
402 403 404 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 402 def release_actions execute :release_actions 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.
280 281 282 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 280 def remove_local_storage_item(key) execute_script("localStorage.removeItem('#{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.
304 305 306 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 304 def remove_session_storage_item(key) execute_script("sessionStorage.removeItem('#{key}')") end |
#reposition_window(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.
255 256 257 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 255 def reposition_window(x, y) execute :set_window_position, {}, {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.
227 228 229 230 231 232 233 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 227 def resize_window(width, height, handle = :current) unless handle == :current raise Error::WebDriverError, 'Switch to desired window before changing its size' end execute :set_window_size, {}, {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.
479 480 481 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 479 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.
475 476 477 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 475 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.
264 265 266 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 264 def screenshot execute :take_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.
128 129 130 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 128 def script_timeout=(milliseconds) timeout('script', milliseconds) end |
#send_actions(data) ⇒ 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.
398 399 400 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 398 def send_actions(data) execute :actions, {}, {actions: data} 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.
TODO: - Implement file verification
411 412 413 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 411 def send_keys_to_element(element, keys) execute :element_send_keys, {id: element}, {value: keys.join('').split(//)} 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.
104 105 106 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 104 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.
296 297 298 299 300 301 302 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 296 def session_storage_item(key, value = nil) if value execute_script("sessionStorage.setItem('#{key}', '#{value}')") else execute_script("return sessionStorage.getItem('#{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.
308 309 310 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 308 def session_storage_keys execute_script('return Object.keys(sessionStorage)') 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.
316 317 318 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 316 def session_storage_size execute_script('return sessionStorage.length') 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.
324 325 326 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 324 def set_location(_lat, _lon, _alt) raise Error::UnsupportedOperationError, 'The W3C standard does not currently support setting location' 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.
116 117 118 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 116 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.
419 420 421 422 423 424 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 419 def submit_element(element) form = find_element_by('xpath', "./ancestor-or-self::form", element) execute_script("var e = arguments[0].ownerDocument.createEvent('Event');" \ "e.initEvent('submit', true, true);" \ 'if (arguments[0].dispatchEvent(e)) { arguments[0].submit() }', form.as_json) 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.
195 196 197 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 195 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.
186 187 188 189 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 186 def switch_to_frame(id) id = find_element_by('id', id) if id.is_a? String 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.
191 192 193 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 191 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.
182 183 184 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 182 def switch_to_window(name) execute :switch_to_window, {}, {handle: 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.
132 133 134 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 132 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.
172 173 174 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 172 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.
434 435 436 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 434 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.
442 443 444 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 442 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.
468 469 470 471 472 473 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 468 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.
464 465 466 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 464 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.
438 439 440 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 438 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.
450 451 452 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 450 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.
454 455 456 457 458 459 460 461 462 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 454 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.
430 431 432 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 430 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.
446 447 448 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 446 def touch_up(x, y) execute :touch_up, {}, {x: x, y: y} 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.
168 169 170 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 168 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.
223 224 225 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 223 def window_handle execute :get_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
219 220 221 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 219 def window_handles execute :get_window_handles end |
#window_position ⇒ 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.
259 260 261 262 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 259 def window_position data = execute :get_window_position 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.
246 247 248 249 250 251 252 253 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 246 def window_size(handle = :current) unless handle == :current raise Error::UnsupportedOperationError, 'Switch to desired window before getting its size' end data = execute :get_window_size Dimension.new data['width'], data['height'] end |