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

Inherits:
Object
  • Object
show all
Includes:
BridgeHelper
Defined in:
lib/selenium/webdriver/remote/bridge.rb,
lib/selenium/webdriver/remote/commands.rb

Overview

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

Low level bridge to the remote server, through which the rest of the API works.

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BridgeHelper

#element_id_from, #parse_cookie_string, #unwrap_script_result

Constructor Details

#initialize(opts = {}) ⇒ Bridge

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

Initializes the bridge with the given server URL.

Parameters:

  • url (String)

    url 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



62
63
64
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/bridge.rb', line 62

def initialize(opts = {})
  opts = opts.dup

  port = opts.delete(:port) || 4444
  http_client = opts.delete(:http_client) { Http::Default.new }
  desired_capabilities = opts.delete(:desired_capabilities) { Capabilities.firefox }
  url = opts.delete(:url) { "http://#{Platform.localhost}:#{port}/wd/hub" }

  unless opts.empty?
    raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
  end

  if desired_capabilities.is_a?(Symbol)
    unless Capabilities.respond_to?(desired_capabilities)
      raise Error::WebDriverError, "invalid desired capability: #{desired_capabilities.inspect}"
    end

    desired_capabilities = Capabilities.send(desired_capabilities)
  end

  uri = url.is_a?(URI) ? url : URI.parse(url)
  uri.path += '/' unless uri.path =~ %r{\/$}

  http_client.server_url = uri

  @http = http_client
  @capabilities = create_session(desired_capabilities)

  @file_detector = nil
end

Instance Attribute Details

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



52
53
54
# File 'lib/selenium/webdriver/remote/bridge.rb', line 52

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.



51
52
53
# File 'lib/selenium/webdriver/remote/bridge.rb', line 51

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.



51
52
53
# File 'lib/selenium/webdriver/remote/bridge.rb', line 51

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.



51
52
53
# File 'lib/selenium/webdriver/remote/bridge.rb', line 51

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.

Parameters:

  • name (Symbol)

    name of the resulting method

  • url (String)

    a URL template, which can include some arguments, much like the definitions on the server. the :session_id parameter is implicitly handled, but the remainder will become required method arguments.

  • verb (Symbol)

    the appropriate http verb, such as :get, :post, or :delete



47
48
49
# File 'lib/selenium/webdriver/remote/bridge.rb', line 47

def self.command(name, verb, url)
  COMMANDS[name] = [verb, url.freeze]
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



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

def accept_alert
  execute :acceptAlert
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



590
591
592
# File 'lib/selenium/webdriver/remote/bridge.rb', line 590

def active_element
  Element.new self, element_id_from(execute(:getActiveElement))
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.

cookies



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

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



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

def alert=(keys)
  execute :setAlertValue, {}, {text: keys.to_s}
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.



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

def alert_text
  execute :getAlertText
end

#authentication(credentials) ⇒ Object

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



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

def authentication(credentials)
  execute :setAuthentication, {}, credentials
end

#available_log_typesObject

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

logs



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

def available_log_types
  types = execute :getAvailableLogTypes
  Array(types).map(&:to_sym)
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.



93
94
95
96
97
98
# File 'lib/selenium/webdriver/remote/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.



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

def clear_element(element)
  execute :clearElement, 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.



298
299
300
# File 'lib/selenium/webdriver/remote/bridge.rb', line 298

def clear_local_storage
  execute :clearLocalStorage
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.



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

def clear_session_storage
  execute :clearSessionStorage
end

#clickObject

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



394
395
396
# File 'lib/selenium/webdriver/remote/bridge.rb', line 394

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



390
391
392
# File 'lib/selenium/webdriver/remote/bridge.rb', line 390

def click_element(element)
  execute :clickElement, 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.



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

def close
  execute :close
end

#context_clickObject

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



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

def context_click
  execute :click, {}, {button: 2}
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.



378
379
380
# File 'lib/selenium/webdriver/remote/bridge.rb', line 378

def cookies
  execute :getCookies
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.



123
124
125
126
127
128
129
# File 'lib/selenium/webdriver/remote/bridge.rb', line 123

def create_session(desired_capabilities)
  resp = raw_execute :newSession, {}, {desiredCapabilities: desired_capabilities}
  @session_id = resp['sessionId']
  return Capabilities.json_create resp['value'] if @session_id

  raise Error::WebDriverError, 'no sessionId in returned payload'
end

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



382
383
384
# File 'lib/selenium/webdriver/remote/bridge.rb', line 382

def delete_all_cookies
  execute :deleteAllCookies
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.



374
375
376
# File 'lib/selenium/webdriver/remote/bridge.rb', line 374

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



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

def dismiss_alert
  execute :dismissAlert
end

#double_clickObject

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



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

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.



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

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



100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/selenium/webdriver/remote/bridge.rb', line 100

def driver_extensions
  [
    DriverExtensions::HasInputDevices,
    DriverExtensions::UploadsFiles,
    DriverExtensions::TakesScreenshot,
    DriverExtensions::HasSessionId,
    DriverExtensions::Rotatable,
    DriverExtensions::HasTouchScreen,
    DriverExtensions::HasLocation,
    DriverExtensions::HasNetworkConnection,
    DriverExtensions::HasRemoteStatus,
    DriverExtensions::HasWebStorage
  ]
end

#element_attribute(element, name) ⇒ Object

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



540
541
542
# File 'lib/selenium/webdriver/remote/bridge.rb', line 540

def element_attribute(element, name)
  execute :getElementAttribute, id: element.ref, name: name
end

#element_displayed?(element) ⇒ Boolean

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

Returns:

  • (Boolean)


578
579
580
# File 'lib/selenium/webdriver/remote/bridge.rb', line 578

def element_displayed?(element)
  execute :isElementDisplayed, 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.

Returns:

  • (Boolean)


570
571
572
# File 'lib/selenium/webdriver/remote/bridge.rb', line 570

def element_enabled?(element)
  execute :isElementEnabled, 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.



552
553
554
555
556
# File 'lib/selenium/webdriver/remote/bridge.rb', line 552

def element_location(element)
  data = execute :getElementLocation, 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.



558
559
560
561
562
# File 'lib/selenium/webdriver/remote/bridge.rb', line 558

def element_location_once_scrolled_into_view(element)
  data = execute :getElementLocationOnceScrolledIntoView, id: element

  Point.new data['x'], data['y']
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:

  • (Boolean)


574
575
576
# File 'lib/selenium/webdriver/remote/bridge.rb', line 574

def element_selected?(element)
  execute :isElementSelected, 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.



564
565
566
567
568
# File 'lib/selenium/webdriver/remote/bridge.rb', line 564

def element_size(element)
  data = execute :getElementSize, 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



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

def element_tag_name(element)
  execute :getElementTagName, 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.



548
549
550
# File 'lib/selenium/webdriver/remote/bridge.rb', line 548

def element_text(element)
  execute :getElementText, 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.



544
545
546
# File 'lib/selenium/webdriver/remote/bridge.rb', line 544

def element_value(element)
  execute :getElementValue, id: element
end

#element_value_of_css_property(element, prop) ⇒ Object

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



582
583
584
# File 'lib/selenium/webdriver/remote/bridge.rb', line 582

def element_value_of_css_property(element, prop)
  execute :getElementValueOfCssProperty, 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.



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

def execute_async_script(script, *args)
  assert_javascript_enabled

  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



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

def execute_script(script, *args)
  assert_javascript_enabled

  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.



596
597
598
599
600
601
602
603
604
# File 'lib/selenium/webdriver/remote/bridge.rb', line 596

def find_element_by(how, what, parent = nil)
  id = if parent
         execute :findChildElement, {id: parent}, {using: how, value: what}
       else
         execute :findElement, {}, {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.



606
607
608
609
610
611
612
613
614
# File 'lib/selenium/webdriver/remote/bridge.rb', line 606

def find_elements_by(how, what, parent = nil)
  ids = if parent
          execute :findChildElements, {id: parent}, {using: how, value: what}
        else
          execute :findElements, {}, {using: how, value: what}
        end

  ids.map { |id| Element.new self, element_id_from(id) }
end

#get(url) ⇒ Object

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



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

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



183
184
185
# File 'lib/selenium/webdriver/remote/bridge.rb', line 183

def go_back
  execute :goBack
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.



187
188
189
# File 'lib/selenium/webdriver/remote/bridge.rb', line 187

def go_forward
  execute :goForward
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.



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

def implicit_wait_timeout=(milliseconds)
  execute :implicitlyWait, {}, {ms: 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



282
283
284
285
286
287
288
# File 'lib/selenium/webdriver/remote/bridge.rb', line 282

def local_storage_item(key, value = nil)
  if value
    execute :setLocalStorageItem, {}, {key: key, value: value}
  else
    execute :getLocalStorageItem, key: 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.



294
295
296
# File 'lib/selenium/webdriver/remote/bridge.rb', line 294

def local_storage_keys
  execute :getLocalStorageKeys
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.



302
303
304
# File 'lib/selenium/webdriver/remote/bridge.rb', line 302

def local_storage_size
  execute :getLocalStorageSize
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.



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

def location
  obj = execute(:getLocation) || {}
  Location.new obj['latitude'], obj['longitude'], obj['altitude']
end

#log(type) ⇒ Object

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



520
521
522
523
524
525
526
527
528
529
530
# File 'lib/selenium/webdriver/remote/bridge.rb', line 520

def log(type)
  data = execute :getLog, {}, {type: type.to_s}

  Array(data).map do |l|
    begin
      LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
    rescue KeyError
      next
    end
  end
end

#maximize_window(handle = :current) ⇒ Object

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



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

def maximize_window(handle = :current)
  execute :maximizeWindow, window_handle: handle
end

#mouse_downObject

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



406
407
408
# File 'lib/selenium/webdriver/remote/bridge.rb', line 406

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.



414
415
416
417
418
419
420
421
422
423
# File 'lib/selenium/webdriver/remote/bridge.rb', line 414

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_upObject

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



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

def mouse_up
  execute :mouseUp
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.



340
341
342
# File 'lib/selenium/webdriver/remote/bridge.rb', line 340

def network_connection
  execute :getNetworkConnection
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.



344
345
346
# File 'lib/selenium/webdriver/remote/bridge.rb', line 344

def network_connection=(type)
  execute :setNetworkConnection, {}, {parameters: {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.



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

def page_source
  execute :getPageSource
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.



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

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



231
232
233
# File 'lib/selenium/webdriver/remote/bridge.rb', line 231

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.



290
291
292
# File 'lib/selenium/webdriver/remote/bridge.rb', line 290

def remove_local_storage_item(key)
  execute :removeLocalStorageItem, key: key
end

#remove_session_storage_item(key) ⇒ Object

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



314
315
316
# File 'lib/selenium/webdriver/remote/bridge.rb', line 314

def remove_session_storage_item(key)
  execute :removeSessionStorageItem, key: key
end

#reposition_window(x, y, handle = :current) ⇒ Object

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



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

def reposition_window(x, y, handle = :current)
  execute :setWindowPosition, {window_handle: handle},
          {x: x, y: y}
end

#resize_window(width, height, handle = :current) ⇒ Object

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



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

def resize_window(width, height, handle = :current)
  execute :setWindowSize, {window_handle: handle},
          {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.



507
508
509
# File 'lib/selenium/webdriver/remote/bridge.rb', line 507

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.



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

def screen_orientation=(orientation)
  execute :setScreenOrientation, {}, {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.



274
275
276
# File 'lib/selenium/webdriver/remote/bridge.rb', line 274

def screenshot
  execute :screenshot
end

#script_timeout=(milliseconds) ⇒ Object

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



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

def script_timeout=(milliseconds)
  execute :setScriptTimeout, {}, {ms: milliseconds}
end

#send_keys_to_active_element(key) ⇒ Object

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



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

def send_keys_to_active_element(key)
  execute :sendKeysToActiveElement, {}, {value: key}
end

#send_keys_to_element(element, keys) ⇒ Object

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



429
430
431
432
433
434
435
436
# File 'lib/selenium/webdriver/remote/bridge.rb', line 429

def send_keys_to_element(element, keys)
  if @file_detector
    local_file = @file_detector.call(keys)
    keys = upload(local_file) if local_file
  end

  execute :sendKeysToElement, {id: element}, {value: Array(keys)}
end

#session_capabilitiesObject

This method is 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/bridge.rb', line 139

def session_capabilities
  Capabilities.json_create execute(:getCapabilities)
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.



119
120
121
# File 'lib/selenium/webdriver/remote/bridge.rb', line 119

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.



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

def session_storage_item(key, value = nil)
  if value
    execute :setSessionStorageItem, {}, {key: key, value: value}
  else
    execute :getSessionStorageItem, key: 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.



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

def session_storage_keys
  execute :getSessionStorageKeys
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.



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

def session_storage_size
  execute :getSessionStorageSize
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.



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

def set_location(lat, lon, alt)
  loc = {latitude: lat, longitude: lon, altitude: alt}
  execute :setLocation, {}, {location: loc}
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.



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

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.



450
451
452
# File 'lib/selenium/webdriver/remote/bridge.rb', line 450

def submit_element(element)
  execute :submitElement, id: element
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.



215
216
217
# File 'lib/selenium/webdriver/remote/bridge.rb', line 215

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.



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

def switch_to_frame(id)
  execute :switchToFrame, {}, {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.



211
212
213
# File 'lib/selenium/webdriver/remote/bridge.rb', line 211

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.



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

def switch_to_window(name)
  execute :switchToWindow, {}, {name: name}
end

#timeout(type, milliseconds) ⇒ Object

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



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

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



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

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.



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

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.



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

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.



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

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.



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

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.



466
467
468
# File 'lib/selenium/webdriver/remote/bridge.rb', line 466

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.



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

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.



482
483
484
485
486
487
488
489
490
# File 'lib/selenium/webdriver/remote/bridge.rb', line 482

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.



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

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.



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

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



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

def upload(local_file)
  unless File.file?(local_file)
    raise Error::WebDriverError, "you may only upload files: #{local_file.inspect}"
  end

  execute :uploadFile, {}, {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.



191
192
193
# File 'lib/selenium/webdriver/remote/bridge.rb', line 191

def url
  execute :getCurrentUrl
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.



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

def window_handle
  execute :getCurrentWindowHandle
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



239
240
241
# File 'lib/selenium/webdriver/remote/bridge.rb', line 239

def window_handles
  execute :getWindowHandles
end

#window_position(handle = :current) ⇒ Object

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



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

def window_position(handle = :current)
  data = execute :getWindowPosition, window_handle: handle

  Point.new data['x'], data['y']
end

#window_size(handle = :current) ⇒ Object

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



257
258
259
260
261
# File 'lib/selenium/webdriver/remote/bridge.rb', line 257

def window_size(handle = :current)
  data = execute :getWindowSize, window_handle: handle

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