Class: Selenium::WebDriver::Chrome::Bridge Private

Inherits:
Remote::Bridge show all
Defined in:
lib/selenium/webdriver/chrome/bridge.rb

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.

Constant Summary

Constants inherited from Remote::Bridge

Remote::Bridge::QUIT_ERRORS

Instance Attribute Summary

Attributes inherited from Remote::Bridge

#context, #http

Instance Method Summary collapse

Methods inherited from Remote::Bridge

#acceptAlert, #addCookie, #clearElement, #click, #clickElement, #close, command, #contextClick, #create_session, #deleteAllCookies, #deleteCookie, #dismissAlert, #doubleClick, #dragElement, #elementEquals, #executeAsyncScript, #executeScript, #find_element_by, #find_elements_by, #get, #getActiveElement, #getAlertText, #getAllCookies, #getCapabilities, #getCurrentUrl, #getCurrentWindowHandle, #getElementAttribute, #getElementLocation, #getElementLocationOnceScrolledIntoView, #getElementSize, #getElementTagName, #getElementText, #getElementValue, #getElementValueOfCssProperty, #getPageSource, #getScreenshot, #getTitle, #getVisible, #getWindowHandles, #goBack, #goForward, #isElementDisplayed, #isElementEnabled, #isElementSelected, #mouseDown, #mouseMoveTo, #mouseUp, #refresh, #sendKeysToElement, #sendModifierKeyToActiveElement, #session_id, #setAlertValue, #setElementSelected, #setImplicitWaitTimeout, #setScriptTimeout, #setVisible, #submitElement, #switchToDefaultContent, #switchToFrame, #switchToWindow

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.

Returns a new instance of Bridge.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/selenium/webdriver/chrome/bridge.rb', line 8

def initialize(opts = {})
  http_client   = opts.delete(:http_client)
  switches      = opts.delete(:switches)
  native_events = opts.delete(:native_events)
  verbose       = opts.delete(:verbose)

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

  caps = Remote::Capabilities.chrome

  if switches
    unless switches.kind_of? Array
      raise ArgumentError, ":switches must be an Array of Strings"
    end

    caps.merge! 'chrome.switches' => switches.map { |e| e.to_s }
  end

  caps.merge! 'chrome.binary'       => Chrome.path if Chrome.path
  caps.merge! 'chrome.nativeEvents' => true if native_events
  caps.merge! 'chrome.verbose'      => true if verbose

  @service = Service.default_service
  @service.start

  remote_opts = {
    :url                  => @service.uri,
    :desired_capabilities => caps
  }

  remote_opts.merge!(:http_client => http_client) if http_client

  super(remote_opts)
end

Instance Method Details

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



45
46
47
# File 'lib/selenium/webdriver/chrome/bridge.rb', line 45

def browser
  :chrome
end

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



56
57
58
# File 'lib/selenium/webdriver/chrome/bridge.rb', line 56

def capabilities
  @capabilities ||= Remote::Capabilities.chrome
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.



49
50
51
52
53
54
# File 'lib/selenium/webdriver/chrome/bridge.rb', line 49

def driver_extensions
  [
    DriverExtensions::TakesScreenshot,
    DriverExtensions::HasInputDevices
  ]
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.



60
61
62
63
64
# File 'lib/selenium/webdriver/chrome/bridge.rb', line 60

def quit
  super
ensure
  @service.stop
end