Class: Selenium::WebDriver::Remote::W3CBridge Private

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

Edge::Bridge, Firefox::W3CBridge

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.

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

{

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

Instance Method Summary collapse

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

Options Hash (opts):

  • :url (String)

    url for the remote server

  • :port (Integer)

    port number for the remote server

  • :http_client (Object)

    an HTTP client instance that implements the same protocol as Http::Default

  • :desired_capabilities (Capabilities)

    an instance of Remote::Capabilities describing the capabilities you want



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 47

def initialize(opts = {})

  opts = opts.dup

  if opts.key?(:port)
    WebDriver.logger.warn "    [DEPRECATION] `:port` is deprecated. Use full url desired.\n    DEPRECATE\n  end\n  port = opts.delete(:port) || 4444\n\n  http_client = opts.delete(:http_client) { Http::Default.new }\n  desired_capabilities = opts.delete(:desired_capabilities) { W3CCapabilities.firefox }\n  url = opts.delete(:url) { \"http://\#{Platform.localhost}:\#{port}/wd/hub\" }\n\n  desired_capabilities = W3CCapabilities.send(desired_capabilities) if desired_capabilities.is_a? Symbol\n\n  desired_capabilities[:marionette] = opts.delete(:marionette) unless opts[:marionette].nil?\n\n  unless opts.empty?\n    raise ArgumentError, \"unknown option\#{'s' if opts.size != 1}: \#{opts.inspect}\"\n  end\n\n  uri = url.is_a?(URI) ? url : URI.parse(url)\n  uri.path += '/' unless uri.path =~ %r{\\/$}\n\n  http_client.server_url = uri\n\n  @http = http_client\n  @capabilities = create_session(desired_capabilities)\n  @file_detector = nil\nend\n".gsub(/\n +| {2,}/, ' ').freeze

Instance Attribute Details

#capabilitiesObject (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

#contextObject

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

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

#httpObject

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



147
148
149
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 147

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



389
390
391
392
393
394
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 389

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



551
552
553
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 551

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.



365
366
367
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 365

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.



155
156
157
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 155

def alert=(keys)
  execute :send_alert_text, {}, {value: keys.split(//)}
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.



159
160
161
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 159

def alert_text
  execute :get_alert_text
end

#browserObject

This method is 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
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 80

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.



422
423
424
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 422

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.



295
296
297
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 295

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.



319
320
321
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 319

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.



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

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.



214
215
216
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 214

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.



98
99
100
101
102
103
104
105
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 98

def commands(command)
  case command
  when :status, :is_element_displayed
    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.



373
374
375
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 373

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.



377
378
379
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 377

def cookies
  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.



115
116
117
118
119
120
121
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 115

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



381
382
383
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 381

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.



369
370
371
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 369

def delete_cookie(name)
  execute :delete_cookie, name: name
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.



151
152
153
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 151

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.



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

def drag_element(element, right_by, down_by)
  execute :drag_element, {id: element}, {x: right_by, y: down_by}
end

#driver_extensionsObject

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



87
88
89
90
91
92
93
94
95
96
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 87

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.



498
499
500
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 498

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.



539
540
541
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 539

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.



531
532
533
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 531

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.



514
515
516
517
518
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 514

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.



520
521
522
523
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 520

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.



502
503
504
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 502

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.



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

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.



525
526
527
528
529
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 525

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



494
495
496
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 494

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.



510
511
512
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 510

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.



506
507
508
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 506

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.



543
544
545
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 543

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.



352
353
354
355
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 352

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



347
348
349
350
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 347

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.



557
558
559
560
561
562
563
564
565
566
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 557

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.



568
569
570
571
572
573
574
575
576
577
578
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 568

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.



249
250
251
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 249

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.



127
128
129
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 127

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



167
168
169
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 167

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.



171
172
173
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 171

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.



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

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.



401
402
403
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 401

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



279
280
281
282
283
284
285
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 279

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.



291
292
293
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 291

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.



299
300
301
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 299

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.



327
328
329
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 327

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.



242
243
244
245
246
247
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 242

def maximize_window(handle = :current)
  unless handle == :current
    raise Error::UnsupportedOperationError, 'Switch to desired window before changing its size'
  end
  execute :maximize_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.



397
398
399
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 397

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.



335
336
337
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 335

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.



339
340
341
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 339

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

#optionsObject

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



361
362
363
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 361

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



183
184
185
186
187
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 183

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.



208
209
210
211
212
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 208

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.



218
219
220
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 218

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.



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

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.



287
288
289
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 287

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.



311
312
313
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 311

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.



262
263
264
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 262

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.



234
235
236
237
238
239
240
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 234

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



486
487
488
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 486

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.



482
483
484
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 482

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.



271
272
273
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 271

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.



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

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.



405
406
407
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 405

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



418
419
420
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 418

def send_keys_to_element(element, keys)
  execute :element_send_keys, {id: element}, {value: keys.join('').split(//)}
end

#session_idObject

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



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

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.



303
304
305
306
307
308
309
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 303

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.



315
316
317
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 315

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.



323
324
325
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 323

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.



331
332
333
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 331

def set_location(_lat, _lon, _alt)
  raise Error::UnsupportedOperationError, 'The W3C standard does not currently support setting location'
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.



123
124
125
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 123

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.



426
427
428
429
430
431
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 426

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.



202
203
204
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 202

def switch_to_default_content
  switch_to_frame nil
end

#switch_to_frame(id) ⇒ Object

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



193
194
195
196
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 193

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.



198
199
200
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 198

def switch_to_parent_frame
  execute :switch_to_parent_frame
end

#switch_to_window(name) ⇒ Object

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



189
190
191
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 189

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.



139
140
141
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 139

def timeout(type, milliseconds)
  execute :set_timeout, {}, {type: type, ms: 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.



179
180
181
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 179

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.



441
442
443
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 441

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.



449
450
451
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 449

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.



475
476
477
478
479
480
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 475

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.



471
472
473
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 471

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.



445
446
447
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 445

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.



457
458
459
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 457

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.



461
462
463
464
465
466
467
468
469
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 461

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.



437
438
439
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 437

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.



453
454
455
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 453

def touch_up(x, y)
  execute :touch_up, {}, {x: x, y: y}
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.



175
176
177
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 175

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.



230
231
232
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 230

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



226
227
228
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 226

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.



266
267
268
269
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 266

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.



253
254
255
256
257
258
259
260
# File 'lib/selenium/webdriver/remote/w3c_bridge.rb', line 253

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