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
- 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.
TODO: constant shouldn’t be modified in class
{}
- 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
Instance Attribute Summary collapse
- #capabilities ⇒ Object readonly private
- #context ⇒ Object private
- #file_detector ⇒ Object private
- #http ⇒ Object private
Class Method Summary collapse
-
.command(name, verb, url) ⇒ Object
private
Defines a wrapper method for a command, which ultimately calls #execute.
Instance Method Summary collapse
-
#accept_alert ⇒ Object
private
alerts.
-
#active_element ⇒ Object
(also: #switch_to_active_element)
private
finding elements.
-
#add_cookie(cookie) ⇒ Object
private
cookies.
- #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 ⇒ Object private
-
#click_element(element) ⇒ Object
private
actions.
- #close ⇒ Object private
- #context_click ⇒ Object private
-
#cookie(name) ⇒ Object
private
TODO: - write specs.
- #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
- #edge_check(opts) ⇒ 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.
-
#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_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
- #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 = nil) ⇒ 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(keys) ⇒ 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(_handle = nil) ⇒ 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.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 65 def initialize(opts = {}) edge_check(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.
55 56 57 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 55 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.
54 55 56 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 54 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.
54 55 56 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 54 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.
54 55 56 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 54 def http @http end |
Class Method Details
.command(name, verb, 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.
Defines a wrapper method for a command, which ultimately calls #execute.
50 51 52 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 50 def self.command(name, verb, url) COMMANDS[name] = [verb, url.freeze] 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
165 166 167 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 165 def accept_alert execute :acceptAlert 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
578 579 580 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 578 def active_element Element.new self, execute(:getActiveElement) 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.
cookies
378 379 380 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 378 def () execute :addCookie, {}, {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.
173 174 175 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 173 def alert=(keys) execute :sendAlertText, {}, {handler: 'prompt', text: keys} 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.
177 178 179 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 177 def alert_text execute :getAlertText 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.
93 94 95 96 97 98 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 93 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.
447 448 449 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 447 def clear_element(element) execute :elementClear, id: element.values.first 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.
312 313 314 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 312 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.
336 337 338 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 336 def clear_session_storage execute_script('sessionStorage.clear()') 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/w3c_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.
actions
403 404 405 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 403 def click_element(element) execute :elementClick, id: element.values.first 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.
232 233 234 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 232 def close execute :closeWindow 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/w3c_bridge.rb', line 415 def context_click execute :click, {}, {button: 2} 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.
TODO: - write specs
387 388 389 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 387 def (name) execute :getCookie, 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.
391 392 393 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 391 def execute :getAllCookies 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.
128 129 130 131 132 133 134 135 136 137 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 128 def create_session(desired_capabilities) # TODO - Remove this when Mozilla fixes bug desired_capabilities[:browser_name] = 'firefox' if desired_capabilities[:browser_name] == 'Firefox' resp = raw_execute :newSession, {}, {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.
395 396 397 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 395 def .each { || (['name']) } 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.
382 383 384 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 382 def (name) execute :deleteCookie, 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.
169 170 171 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 169 def dismiss_alert execute :dismissAlert 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/w3c_bridge.rb', line 411 def double_click execute :doubleClick 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.
458 459 460 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 458 def drag_element(element, right_by, down_by) execute :dragElement, {id: element.values.first}, {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.
107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 107 def driver_extensions [ DriverExtensions::HasInputDevices, DriverExtensions::UploadsFiles, DriverExtensions::TakesScreenshot, DriverExtensions::HasSessionId, DriverExtensions::Rotatable, DriverExtensions::HasTouchScreen, DriverExtensions::HasRemoteStatus, DriverExtensions::HasWebStorage ] end |
#edge_check(opts) ⇒ 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.
100 101 102 103 104 105 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 100 def edge_check(opts) caps = opts[:desired_capabilities] return unless caps && caps[:browser_name] && caps[:browser_name] == 'MicrosoftEdge' require_relative '../edge/legacy_support' extend Edge::LegacySupport 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.
523 524 525 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 523 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.
564 565 566 567 568 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 564 def element_displayed?(element) jwp = Selenium::WebDriver::Remote::Bridge::COMMANDS[:isElementDisplayed] self.class.command(:isElementDisplayed, jwp.first, jwp.last) execute :isElementDisplayed, id: element.values.first 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.
556 557 558 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 556 def element_enabled?(element) execute :isElementEnabled, id: element.values.first 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.
539 540 541 542 543 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 539 def element_location(element) data = execute :getElementRect, id: element.values.first 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.
545 546 547 548 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 545 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.
527 528 529 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 527 def element_property(element, name) execute :getElementProperty, id: element.values.first, 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.
560 561 562 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 560 def element_selected?(element) execute :isElementSelected, id: element.values.first 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.
550 551 552 553 554 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 550 def element_size(element) data = execute :getElementRect, id: element.values.first 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
519 520 521 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 519 def element_tag_name(element) execute :getElementTagName, id: element.values.first 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.
535 536 537 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 535 def element_text(element) execute :getElementText, id: element.values.first 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.
531 532 533 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 531 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.
570 571 572 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 570 def element_value_of_css_property(element, prop) execute :getElementCssValue, id: element.values.first, 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.
369 370 371 372 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 369 def execute_async_script(script, *args) result = execute :executeAsyncScript, {}, {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
364 365 366 367 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 364 def execute_script(script, *args) result = execute :executeScript, {}, {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.
584 585 586 587 588 589 590 591 592 593 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 584 def find_element_by(how, what, parent = nil) how, what = convert_locators(how, what) id = if parent execute :findChildElement, {id: parent.values.first}, {using: how, value: what} else execute :findElement, {}, {using: how, value: what} end Element.new self, 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.
595 596 597 598 599 600 601 602 603 604 605 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 595 def find_elements_by(how, what, parent = nil) how, what = convert_locators(how, what) ids = if parent execute :findChildElements, {id: parent.values.first}, {using: how, value: what} else execute :findElements, {}, {using: how, value: what} end ids.map { |id| Element.new self, 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.
267 268 269 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 267 def full_screen_window execute :fullscreenWindow 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.
145 146 147 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 145 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
185 186 187 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 185 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.
189 190 191 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 189 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.
149 150 151 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 149 def implicit_wait_timeout=(milliseconds) timeout('implicit', milliseconds) 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
296 297 298 299 300 301 302 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 296 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.
308 309 310 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 308 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.
316 317 318 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 316 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.
344 345 346 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 344 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.
260 261 262 263 264 265 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 260 def maximize_window(handle = :current) unless handle == :current raise Error::UnsupportedOperationError, 'Switch to desired window before changing its size' end execute :maximizeWindow 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/w3c_bridge.rb', line 419 def mouse_down execute :mouseDown 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/w3c_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 :mouseMoveTo, {}, 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/w3c_bridge.rb', line 423 def mouse_up execute :mouseUp 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.
352 353 354 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 352 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.
356 357 358 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 356 def network_connection=(_type) raise Error::UnsupportedOperationError, 'The W3C standard does not currently support setting network connection' 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.
201 202 203 204 205 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 201 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.
226 227 228 229 230 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 226 def quit execute :deleteSession 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.
236 237 238 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 236 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.
304 305 306 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 304 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.
328 329 330 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 328 def remove_session_storage_item(key) execute_script("sessionStorage.removeItem('#{key}')") end |
#reposition_window(_x, _y, _handle = 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.
280 281 282 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 280 def reposition_window(_x, _y, _handle = nil) raise Error::UnsupportedOperationError, 'The W3C standard does not currently support setting the Window Position' 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.
252 253 254 255 256 257 258 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 252 def resize_window(width, height, handle = :current) unless handle == :current raise Error::WebDriverError, 'Switch to desired window before changing its size' end execute :setWindowSize, {}, {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.
511 512 513 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 511 def screen_orientation execute :getScreenOrientation 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.
507 508 509 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 507 def screen_orientation=(orientation) execute :setScreenOrientation, {}, {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.
288 289 290 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 288 def screenshot execute :takeScreenshot 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.
153 154 155 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 153 def script_timeout=(milliseconds) timeout('script', milliseconds) end |
#send_keys_to_active_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.
438 439 440 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 438 def send_keys_to_active_element(keys) send_keys_to_element(active_element, keys) 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
443 444 445 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 443 def send_keys_to_element(element, keys) execute :elementSendKeys, {id: element.values.first}, {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.
124 125 126 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 124 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.
320 321 322 323 324 325 326 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 320 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.
332 333 334 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 332 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.
340 341 342 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 340 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.
348 349 350 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 348 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.
139 140 141 142 143 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 139 def status jwp = Selenium::WebDriver::Remote::Bridge::COMMANDS[:status] self.class.command(:status, jwp.first, jwp.last) 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.
451 452 453 454 455 456 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 451 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.
220 221 222 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 220 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.
211 212 213 214 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 211 def switch_to_frame(id) id = find_element_by('id', id) if id.is_a? String execute :switchToFrame, {}, {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.
216 217 218 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 216 def switch_to_parent_frame execute :switchToParentFrame 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.
207 208 209 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 207 def switch_to_window(name) execute :switchToWindow, {}, {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.
157 158 159 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 157 def timeout(type, milliseconds) execute :setTimeout, {}, {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.
197 198 199 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 197 def title execute :getTitle 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.
466 467 468 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 466 def touch_double_tap(element) execute :touchDoubleTap, {}, {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.
474 475 476 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 474 def touch_down(x, y) execute :touchDown, {}, {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.
500 501 502 503 504 505 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 500 def touch_element_flick(element, right_by, down_by, speed) execute :touchFlick, {}, {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.
496 497 498 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 496 def touch_flick(xspeed, yspeed) execute :touchFlick, {}, {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.
470 471 472 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 470 def touch_long_press(element) execute :touchLongPress, {}, {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.
482 483 484 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 482 def touch_move(x, y) execute :touchMove, {}, {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.
486 487 488 489 490 491 492 493 494 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 486 def touch_scroll(element, x, y) if element execute :touchScroll, {}, {element: element, xoffset: x, yoffset: y} else execute :touchScroll, {}, {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.
462 463 464 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 462 def touch_single_tap(element) execute :touchSingleTap, {}, {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.
478 479 480 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 478 def touch_up(x, y) execute :touchUp, {}, {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.
193 194 195 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 193 def url execute :getCurrentUrl 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.
248 249 250 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 248 def window_handle execute :getWindowHandle 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
244 245 246 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 244 def window_handles execute :getWindowHandles end |
#window_position(_handle = 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.
284 285 286 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 284 def window_position(_handle = nil) raise Error::UnsupportedOperationError, 'The W3C standard does not currently support getting the Window Position' 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.
271 272 273 274 275 276 277 278 |
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 271 def window_size(handle = :current) unless handle == :current raise Error::UnsupportedOperationError, 'Switch to desired window before getting its size' end data = execute :getWindowSize Dimension.new data['width'], data['height'] end |