Class: Selenium::WebDriver::Remote::W3C::Bridge Private

Inherits:
Bridge
  • Object
show all
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.

http://www.w3.org/TR/2015/WD-webdriver-20150918/#list-of-endpoints

API:

  • private

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.

API:

  • private

[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.

API:

  • private

{

  #
  # session handling
  #

  new_session: [:post, 'session'],
  delete_session: [:delete, 'session/:session_id'],

  #
  # basic driver
  #

  get: [:post, 'session/:session_id/url'],
  get_current_url: [:get, 'session/:session_id/url'],
  back: [:post, 'session/:session_id/back'],
  forward: [:post, 'session/:session_id/forward'],
  refresh: [:post, 'session/:session_id/refresh'],
  get_title: [:get, 'session/:session_id/title'],

  #
  # window and Frame handling
  #

  get_window_handle: [:get, 'session/:session_id/window'],
  new_window: [:post, 'session/:session_id/window/new'],
  close_window: [:delete, 'session/:session_id/window'],
  switch_to_window: [:post, 'session/:session_id/window'],
  get_window_handles: [:get, 'session/:session_id/window/handles'],
  fullscreen_window: [:post, 'session/:session_id/window/fullscreen'],
  minimize_window: [:post, 'session/:session_id/window/minimize'],
  maximize_window: [:post, 'session/:session_id/window/maximize'],
  set_window_size: [:post, 'session/:session_id/window/size'],
  get_window_size: [:get, 'session/:session_id/window/size'],
  set_window_position: [:post, 'session/:session_id/window/position'],
  get_window_position: [:get, 'session/:session_id/window/position'],
  set_window_rect: [:post, 'session/:session_id/window/rect'],
  get_window_rect: [:get, 'session/:session_id/window/rect'],
  switch_to_frame: [:post, 'session/:session_id/frame'],
  switch_to_parent_frame: [:post, 'session/:session_id/frame/parent'],

  #
  # element
  #

  find_element: [:post, 'session/:session_id/element'],
  find_elements: [:post, 'session/:session_id/elements'],
  find_child_element: [:post, 'session/:session_id/element/:id/element'],
  find_child_elements: [:post, 'session/:session_id/element/:id/elements'],
  get_active_element: [:get, 'session/:session_id/element/active'],
  is_element_selected: [:get, 'session/:session_id/element/:id/selected'],
  get_element_attribute: [:get, 'session/:session_id/element/:id/attribute/:name'],
  get_element_property: [:get, 'session/:session_id/element/:id/property/:name'],
  get_element_css_value: [:get, 'session/:session_id/element/:id/css/:property_name'],
  get_element_text: [:get, 'session/:session_id/element/:id/text'],
  get_element_tag_name: [:get, 'session/:session_id/element/:id/name'],
  get_element_rect: [:get, 'session/:session_id/element/:id/rect'],
  is_element_enabled: [:get, 'session/:session_id/element/:id/enabled'],

  #
  # document handling
  #

  get_page_source: [:get, 'session/:session_id/source'],
  execute_script: [:post, 'session/:session_id/execute/sync'],
  execute_async_script: [:post, 'session/:session_id/execute/async'],

  #
  # cookies
  #

  get_all_cookies: [:get, 'session/:session_id/cookie'],
  get_cookie: [:get, 'session/:session_id/cookie/:name'],
  add_cookie: [:post, 'session/:session_id/cookie'],
  delete_cookie: [:delete, 'session/:session_id/cookie/:name'],
  delete_all_cookies: [:delete, 'session/:session_id/cookie'],

  #
  # timeouts
  #

  set_timeout: [:post, 'session/:session_id/timeouts'],

  #
  # actions
  #

  actions: [:post, 'session/:session_id/actions'],
  release_actions: [:delete, 'session/:session_id/actions'],

  #
  # Element Operations
  #

  element_click: [:post, 'session/:session_id/element/:id/click'],
  element_tap: [:post, 'session/:session_id/element/:id/tap'],
  element_clear: [:post, 'session/:session_id/element/:id/clear'],
  element_send_keys: [:post, 'session/:session_id/element/:id/value'],

  #
  # alerts
  #

  dismiss_alert: [:post, 'session/:session_id/alert/dismiss'],
  accept_alert: [:post, 'session/:session_id/alert/accept'],
  get_alert_text: [:get, 'session/:session_id/alert/text'],
  send_alert_text: [:post, 'session/:session_id/alert/text'],

  #
  # screenshot
  #

  take_screenshot: [:get, 'session/:session_id/screenshot'],
  take_element_screenshot: [:get, 'session/:session_id/element/:id/screenshot'],

  #
  # server extensions
  #

  upload_file: [:post, 'session/:session_id/se/file']
}.freeze

Constants inherited from Bridge

Bridge::PORT

Instance Attribute Summary

Attributes inherited from Bridge

#capabilities, #context, #file_detector, #http

Instance Method Summary collapse

Methods inherited from Bridge

#browser, #create_session, handshake, #session_id

Methods included from BridgeHelper

#element_id_from, #parse_cookie_string, #unwrap_script_result

Constructor Details

#initialize(capabilities, session_id, **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.

API:

  • private



35
36
37
38
39
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 35

def initialize(capabilities, session_id, **opts)
  @capabilities = capabilities
  @session_id = session_id
  super(opts)
end

Instance Method Details

#accept_alertObject

This method is 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

API:

  • private



79
80
81
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 79

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

API:

  • private



346
347
348
349
350
351
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 346

def action(async = false)
  W3CActionBuilder.new self,
                       Interactions.pointer(:mouse, name: 'mouse'),
                       Interactions.key('keyboard'),
                       async
end

#active_elementObject 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

API:

  • private



535
536
537
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 535

def active_element
  Element.new self, element_id_from(execute(:get_active_element))
end

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



322
323
324
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 322

def add_cookie(cookie)
  execute :add_cookie, {}, {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.

API:

  • private



87
88
89
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 87

def alert=(keys)
  execute :send_alert_text, {}, {value: keys.split(//), text: keys}
end

#alert_textObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



91
92
93
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 91

def alert_text
  execute :get_alert_text
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.

API:

  • private



398
399
400
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 398

def clear_element(element)
  execute :element_clear, id: element
end

#clear_local_storageObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



252
253
254
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 252

def clear_local_storage
  execute_script('localStorage.clear()')
end

#clear_session_storageObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



276
277
278
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 276

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.

API:

  • private



370
371
372
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 370

def click_element(element)
  execute :element_click, id: element
end

#closeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



160
161
162
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 160

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.

API:

  • private



45
46
47
48
49
50
51
52
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 45

def commands(command)
  case command
  when :status
    Remote::OSS::Bridge::COMMANDS[command]
  else
    COMMANDS[command]
  end
end

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



330
331
332
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 330

def cookie(name)
  execute :get_cookie, name: name
end

#cookiesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



334
335
336
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 334

def cookies
  execute :get_all_cookies
end

#delete_all_cookiesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



338
339
340
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 338

def delete_all_cookies
  execute :delete_all_cookies
end

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



326
327
328
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 326

def delete_cookie(name)
  execute :delete_cookie, name: name
end

#dialectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



41
42
43
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 41

def dialect
  :w3c
end

#dismiss_alertObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



83
84
85
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 83

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.

API:

  • private



409
410
411
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 409

def drag_element(element, right_by, down_by)
  execute :drag_element, {id: element}, {x: right_by, y: down_by}
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.

API:

  • private



474
475
476
477
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 474

def element_attribute(element, name)
  WebDriver.logger.info "Using script for :getAttribute of #{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.

Returns:

API:

  • private



522
523
524
525
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 522

def element_displayed?(element)
  WebDriver.logger.info 'Using script for :isDisplayed'
  execute_atom :isDisplayed, 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.

Returns:

API:

  • private



514
515
516
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 514

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.

API:

  • private



491
492
493
494
495
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 491

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.

API:

  • private



503
504
505
506
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 503

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.

API:

  • private



479
480
481
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 479

def element_property(element, name)
  execute :get_element_property, id: element.ref, name: name
end

#element_rect(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.

API:

  • private



497
498
499
500
501
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 497

def element_rect(element)
  data = execute :get_element_rect, id: element

  Rectangle.new data['x'], data['y'], data['width'], data['height']
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.

Returns:

API:

  • private



518
519
520
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 518

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.

API:

  • private



508
509
510
511
512
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 508

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

API:

  • private



470
471
472
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 470

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.

API:

  • private



487
488
489
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 487

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.

API:

  • private



483
484
485
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 483

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.

API:

  • private



527
528
529
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 527

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.

API:

  • private



309
310
311
312
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 309

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

API:

  • private



304
305
306
307
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 304

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.

API:

  • private



541
542
543
544
545
546
547
548
549
550
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 541

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.

API:

  • private



552
553
554
555
556
557
558
559
560
561
562
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 552

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_windowObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



204
205
206
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 204

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.

API:

  • private



58
59
60
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 58

def get(url)
  execute :get, {}, {url: url}
end

#go_backObject

This method is 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

API:

  • private



99
100
101
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 99

def go_back
  execute :back
end

#go_forwardObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



103
104
105
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 103

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.

API:

  • private



62
63
64
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 62

def implicit_wait_timeout=(milliseconds)
  timeout('implicit', milliseconds)
end

#keyboardObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

API:

  • private



358
359
360
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 358

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

API:

  • private



236
237
238
239
240
241
242
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 236

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_keysObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



248
249
250
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 248

def local_storage_keys
  execute_script('return Object.keys(localStorage)')
end

#local_storage_sizeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



256
257
258
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 256

def local_storage_size
  execute_script('return localStorage.length')
end

#locationObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

API:

  • private



284
285
286
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 284

def location
  raise Error::UnsupportedOperationError, 'The W3C standard does not currently support getting location'
end

#manageObject

This method is 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

API:

  • private



318
319
320
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 318

def manage
  @manage ||= WebDriver::W3CManager.new(self)
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.

Raises:

API:

  • private



198
199
200
201
202
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 198

def maximize_window(handle = :current)
  raise Error::UnsupportedOperationError, 'Switch to desired window before changing its size' unless handle == :current

  execute :maximize_window
end

#minimize_windowObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



194
195
196
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 194

def minimize_window
  execute :minimize_window
end

#mouseObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

API:

  • private



354
355
356
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 354

def mouse
  raise Error::UnsupportedOperationError, '#mouse is no longer supported, use #action instead'
end

#network_connectionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Raises:

API:

  • private



292
293
294
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 292

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.

Raises:

API:

  • private



296
297
298
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 296

def network_connection=(_type)
  raise Error::UnsupportedOperationError, 'The W3C standard does not currently support setting network connection'
end

#new_window(type) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create a new top-level browsing context https://w3c.github.io/webdriver/#new-window

Parameters:

  • Supports two values: 'tab' and 'window'. Use 'tab' if you'd like the new window to share an OS-level window with the current browsing context. Use 'window' otherwise

Returns:

  • Containing 'handle' with the value of the window handle and 'type' with the value of the created window type

API:

  • private



131
132
133
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 131

def new_window(type)
  execute :new_window, {}, {type: type}
end

#page_sourceObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



115
116
117
118
119
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 115

def page_source
  execute_script('var source = document.documentElement.outerHTML;' \
                    'if (!source) { source = new XMLSerializer().serializeToString(document); }' \
                    'return source;')
end

#quitObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



154
155
156
157
158
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 154

def quit
  execute :delete_session
  http.close
rescue *QUIT_ERRORS
end

#refreshObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



164
165
166
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 164

def refresh
  execute :refresh
end

#release_actionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



366
367
368
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 366

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.

API:

  • private



244
245
246
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 244

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.

API:

  • private



268
269
270
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 268

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.

API:

  • private



208
209
210
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 208

def reposition_window(x, y)
  set_window_rect(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.

Raises:

API:

  • private



180
181
182
183
184
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 180

def resize_window(width, height, handle = :current)
  raise Error::WebDriverError, 'Switch to desired window before changing its size' unless handle == :current

  set_window_rect(width: width, height: height)
end

#screen_orientationObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



462
463
464
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 462

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.

API:

  • private



458
459
460
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 458

def screen_orientation=(orientation)
  execute :set_screen_orientation, {}, {orientation: orientation}
end

#screenshotObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



228
229
230
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 228

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.

API:

  • private



66
67
68
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 66

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.

API:

  • private



362
363
364
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 362

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.

API:

  • private



374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 374

def send_keys_to_element(element, keys)
  # TODO: rework file detectors before Selenium 4.0
  if @file_detector
    local_files = keys.first.split("\n").map { |key| @file_detector.call(Array(key)) }.compact
    if local_files.any?
      keys = local_files.map { |local_file| upload(local_file) }
      keys = Array(keys.join("\n"))
    end
  end

  # Keep .split(//) for backward compatibility for now
  text = keys.join('')
  execute :element_send_keys, {id: element}, {value: text.split(//), text: text}
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.

API:

  • private



260
261
262
263
264
265
266
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 260

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_keysObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



272
273
274
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 272

def session_storage_keys
  execute_script('return Object.keys(sessionStorage)')
end

#session_storage_sizeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



280
281
282
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 280

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.

Raises:

API:

  • private



288
289
290
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 288

def set_location(_lat, _lon, _alt)
  raise Error::UnsupportedOperationError, 'The W3C standard does not currently support setting location'
end

#set_window_rect(x: nil, y: nil, width: nil, height: 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.

API:

  • private



217
218
219
220
221
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 217

def set_window_rect(x: nil, y: nil, width: nil, height: nil)
  params = {x: x, y: y, width: width, height: height}
  params.update(params) { |_k, v| Integer(v) unless v.nil? }
  execute :set_window_rect, {}, params
end

#statusObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



54
55
56
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 54

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.

API:

  • private



402
403
404
405
406
407
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 402

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_contentObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



148
149
150
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 148

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.

API:

  • private



139
140
141
142
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 139

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_frameObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



144
145
146
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 144

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.

API:

  • private



135
136
137
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 135

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.

API:

  • private



70
71
72
73
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 70

def timeout(type, milliseconds)
  type = 'pageLoad' if type == 'page load'
  execute :set_timeout, {}, {type => milliseconds}
end

#titleObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



111
112
113
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 111

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.

API:

  • private



417
418
419
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 417

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.

API:

  • private



425
426
427
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 425

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.

API:

  • private



451
452
453
454
455
456
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 451

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.

API:

  • private



447
448
449
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 447

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.

API:

  • private



421
422
423
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 421

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.

API:

  • private



433
434
435
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 433

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.

API:

  • private



437
438
439
440
441
442
443
444
445
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 437

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.

API:

  • private



413
414
415
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 413

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.

API:

  • private



429
430
431
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 429

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.

API:

  • private



389
390
391
392
393
394
395
396
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 389

def upload(local_file)
  unless File.file?(local_file)
    WebDriver.logger.debug("File detector only works with files. #{local_file.inspect} isn`t a file!")
    raise Error::WebDriverError, "You are trying to work with something that isn't a file."
  end

  execute :upload_file, {}, {file: Zipper.zip_file(local_file)}
end

#urlObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



107
108
109
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 107

def url
  execute :get_current_url
end

#window_handleObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



176
177
178
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 176

def window_handle
  execute :get_window_handle
end

#window_handlesObject

This method is 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

API:

  • private



172
173
174
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 172

def window_handles
  execute :get_window_handles
end

#window_positionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



212
213
214
215
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 212

def window_position
  data = execute :get_window_rect
  Point.new data['x'], data['y']
end

#window_rectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



223
224
225
226
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 223

def window_rect
  data = execute :get_window_rect
  Rectangle.new data['x'], data['y'], data['width'], data['height']
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.

Raises:

API:

  • private



186
187
188
189
190
191
192
# File 'lib/selenium/webdriver/remote/w3c/bridge.rb', line 186

def window_size(handle = :current)
  raise Error::UnsupportedOperationError, 'Switch to desired window before getting its size' unless handle == :current

  data = execute :get_window_rect

  Dimension.new data['width'], data['height']
end