Class: Selenium::WebDriver::Remote::Capabilities Private

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/webdriver/remote/capabilities.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.

Specification of the desired and/or actual capabilities of the browser that the server is being asked to create.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Capabilities

Returns a new instance of Capabilities.

Parameters:

  • :browser_name (Hash)

    a customizable set of options

  • :version (Hash)

    a customizable set of options

  • :platform (Hash)

    a customizable set of options

  • :javascript_enabled (Hash)

    a customizable set of options

  • :css_selectors_enabled (Hash)

    a customizable set of options

  • :takes_screenshot (Hash)

    a customizable set of options

  • :native_events (Hash)

    a customizable set of options

  • :proxy (Hash)

    a customizable set of options



114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 114

def initialize(opts = {})
  @browser_name          = opts[:browser_name]          || ""
  @version               = opts[:version]               || ""
  @platform              = opts[:platform]              || :any
  @javascript_enabled    = opts[:javascript_enabled]    || false
  @css_selectors_enabled = opts[:css_selectors_enabled] || false
  @takes_screenshot      = opts[:takes_screenshot]      || false
  @native_events         = opts[:native_events]         || false
  @rotatable             = opts[:rotatable]             || false

  self.proxy             = opts[:proxy]
end

Instance Attribute Details

#browser_nameObject

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



12
13
14
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 12

def browser_name
  @browser_name
end

#css_selectors_enabledObject Also known as: css_selectors_enabled?

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



12
13
14
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 12

def css_selectors_enabled
  @css_selectors_enabled
end

#javascript_enabledObject Also known as: javascript_enabled?

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



12
13
14
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 12

def javascript_enabled
  @javascript_enabled
end

#native_eventsObject Also known as: native_events?

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



12
13
14
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 12

def native_events
  @native_events
end

#platformObject

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



12
13
14
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 12

def platform
  @platform
end

#proxyObject

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



10
11
12
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 10

def proxy
  @proxy
end

#rotatableObject Also known as: rotatable?

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



12
13
14
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 12

def rotatable
  @rotatable
end

#takes_screenshotObject Also known as: takes_screenshot?

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



12
13
14
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 12

def takes_screenshot
  @takes_screenshot
end

#versionObject

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



12
13
14
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 12

def version
  @version
end

Class Method Details

.android(opts = {}) ⇒ Object

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



74
75
76
77
78
79
80
81
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 74

def android(opts = {})
  new({
    :browser_name     => "android",
    :platform         => :android,
    :rotatable        => true,
    :takes_screenshot => true
  }.merge(opts))
end

.chrome(opts = {}) ⇒ Object

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



67
68
69
70
71
72
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 67

def chrome(opts = {})
  new({
    :browser_name       => "chrome",
    :javascript_enabled => true
  }.merge(opts))
end

.firefox(opts = {}) ⇒ Object

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



32
33
34
35
36
37
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 32

def firefox(opts = {})
  new({
    :browser_name => "firefox",
    :javascript_enabled => true
  }.merge(opts))
end

.htmlunit(opts = {}) ⇒ Object

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



46
47
48
49
50
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 46

def htmlunit(opts = {})
  new({
    :browser_name => "htmlunit"
  }.merge(opts))
end

.internet_explorer(opts = {}) ⇒ Object

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



39
40
41
42
43
44
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 39

def internet_explorer(opts = {})
  new({
    :browser_name => "internet explorer",
    :platform     => :windows
  }.merge(opts))
end

.iphone(opts = {}) ⇒ Object

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



59
60
61
62
63
64
65
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 59

def iphone(opts = {})
  new({
    :browser_name       => "iphone",
    :platform           => :mac,
    :javascript_enabled => true
  }.merge(opts))
end

.json_create(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.



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

def json_create(data)
  new(
    :browser_name          => data["browserName"],
    :version               => data["version"],
    :platform              => data["platform"].downcase.to_sym,
    :javascript_enabled    => data["javascriptEnabled"],
    :css_selectors_enabled => data["cssSelectorsEnabled"],
    :takes_screenshot      => data["takesScreenshot"],
    :native_events         => data["nativeEvents"],
    :rotatable             => data["rotatable"],
    :proxy                 => (Proxy.json_create(data['proxy']) if data['proxy'])
  )
end

.safari(opts = {}) ⇒ Object

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



52
53
54
55
56
57
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 52

def safari(opts = {})
  new({
    :browser_name => "safari",
    :platform     => :mac
  }.merge(opts))
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?

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



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

def ==(other)
  return false unless other.kind_of? self.class
  as_json == other.as_json
end

#as_json(opts = 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.



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 141

def as_json(opts = nil)
  hash = {
    "browserName"         => browser_name,
    "version"             => version,
    "platform"            => platform.to_s.upcase,
    "javascriptEnabled"   => javascript_enabled?,
    "cssSelectorsEnabled" => css_selectors_enabled?,
    "takesScreenshot"     => takes_screenshot?,
    "nativeEvents"        => native_events?,
    "rotatable"           => rotatable?
  }

  hash["proxy"] = proxy.as_json if proxy

  hash
end

#to_json(*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.



158
159
160
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 158

def to_json(*args)
  as_json.to_json(*args)
end