selenium-webdriver 2.53.4 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/CHANGES +24 -18
  2. data/README.md +2 -3
  3. data/lib/selenium/server.rb +64 -68
  4. data/lib/selenium/webdriver.rb +5 -9
  5. data/lib/selenium/webdriver/chrome.rb +18 -3
  6. data/lib/selenium/webdriver/chrome/bridge.rb +13 -16
  7. data/lib/selenium/webdriver/chrome/profile.rb +7 -9
  8. data/lib/selenium/webdriver/chrome/service.rb +8 -84
  9. data/lib/selenium/webdriver/common.rb +1 -2
  10. data/lib/selenium/webdriver/common/action_builder.rb +28 -38
  11. data/lib/selenium/webdriver/common/alert.rb +7 -10
  12. data/lib/selenium/webdriver/common/bridge_helper.rb +10 -15
  13. data/lib/selenium/webdriver/common/driver.rb +19 -28
  14. data/lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb +0 -3
  15. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +4 -6
  16. data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +4 -5
  17. data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +0 -2
  18. data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +0 -2
  19. data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +0 -2
  20. data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +0 -3
  21. data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +3 -6
  22. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +2 -5
  23. data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +2 -5
  24. data/lib/selenium/webdriver/common/element.rb +27 -29
  25. data/lib/selenium/webdriver/common/error.rb +17 -20
  26. data/lib/selenium/webdriver/common/file_reaper.rb +3 -9
  27. data/lib/selenium/webdriver/common/html5/local_storage.rb +6 -8
  28. data/lib/selenium/webdriver/common/html5/session_storage.rb +6 -8
  29. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +6 -15
  30. data/lib/selenium/webdriver/common/keyboard.rb +7 -12
  31. data/lib/selenium/webdriver/common/keys.rb +67 -69
  32. data/lib/selenium/webdriver/common/log_entry.rb +3 -4
  33. data/lib/selenium/webdriver/common/logs.rb +2 -4
  34. data/lib/selenium/webdriver/common/mouse.rb +9 -12
  35. data/lib/selenium/webdriver/common/navigation.rb +2 -4
  36. data/lib/selenium/webdriver/common/options.rb +16 -19
  37. data/lib/selenium/webdriver/common/platform.rb +61 -90
  38. data/lib/selenium/webdriver/common/port_prober.rb +1 -2
  39. data/lib/selenium/webdriver/common/profile_helper.rb +5 -8
  40. data/lib/selenium/webdriver/common/proxy.rb +58 -70
  41. data/lib/selenium/webdriver/common/search_context.rb +15 -19
  42. data/lib/selenium/webdriver/common/service.rb +127 -0
  43. data/lib/selenium/webdriver/common/socket_lock.rb +5 -11
  44. data/lib/selenium/webdriver/common/socket_poller.rb +4 -9
  45. data/lib/selenium/webdriver/common/target_locator.rb +11 -13
  46. data/lib/selenium/webdriver/common/timeouts.rb +4 -6
  47. data/lib/selenium/webdriver/common/touch_action_builder.rb +2 -4
  48. data/lib/selenium/webdriver/common/touch_screen.rb +15 -18
  49. data/lib/selenium/webdriver/common/w3c_error.rb +3 -6
  50. data/lib/selenium/webdriver/common/wait.rb +6 -11
  51. data/lib/selenium/webdriver/common/window.rb +12 -15
  52. data/lib/selenium/webdriver/common/zipper.rb +6 -8
  53. data/lib/selenium/webdriver/edge.rb +18 -3
  54. data/lib/selenium/webdriver/edge/bridge.rb +11 -16
  55. data/lib/selenium/webdriver/edge/legacy_support.rb +38 -39
  56. data/lib/selenium/webdriver/edge/service.rb +8 -82
  57. data/lib/selenium/webdriver/firefox.rb +25 -6
  58. data/lib/selenium/webdriver/firefox/binary.rb +37 -53
  59. data/lib/selenium/webdriver/firefox/bridge.rb +3 -6
  60. data/lib/selenium/webdriver/firefox/extension.rb +4 -6
  61. data/lib/selenium/webdriver/firefox/extension/prefs.json +1 -10
  62. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  63. data/lib/selenium/webdriver/firefox/launcher.rb +8 -11
  64. data/lib/selenium/webdriver/firefox/profile.rb +40 -42
  65. data/lib/selenium/webdriver/firefox/profiles_ini.rb +8 -15
  66. data/lib/selenium/webdriver/firefox/service.rb +23 -79
  67. data/lib/selenium/webdriver/firefox/util.rb +0 -2
  68. data/lib/selenium/webdriver/firefox/w3c_bridge.rb +2 -4
  69. data/lib/selenium/webdriver/ie.rb +16 -7
  70. data/lib/selenium/webdriver/ie/bridge.rb +16 -23
  71. data/lib/selenium/webdriver/{iphone.rb → ie/service.rb} +26 -4
  72. data/lib/selenium/webdriver/phantomjs.rb +8 -3
  73. data/lib/selenium/webdriver/phantomjs/bridge.rb +9 -11
  74. data/lib/selenium/webdriver/phantomjs/service.rb +17 -81
  75. data/lib/selenium/webdriver/remote.rb +0 -2
  76. data/lib/selenium/webdriver/remote/bridge.rb +193 -191
  77. data/lib/selenium/webdriver/remote/capabilities.rb +60 -90
  78. data/lib/selenium/webdriver/remote/commands.rb +197 -192
  79. data/lib/selenium/webdriver/remote/http/common.rb +15 -13
  80. data/lib/selenium/webdriver/remote/http/curb.rb +5 -9
  81. data/lib/selenium/webdriver/remote/http/default.rb +32 -37
  82. data/lib/selenium/webdriver/remote/http/persistent.rb +4 -6
  83. data/lib/selenium/webdriver/remote/response.rb +13 -21
  84. data/lib/selenium/webdriver/remote/server_error.rb +1 -3
  85. data/lib/selenium/webdriver/remote/w3c_bridge.rb +200 -195
  86. data/lib/selenium/webdriver/remote/w3c_capabilities.rb +38 -46
  87. data/lib/selenium/webdriver/remote/w3c_commands.rb +116 -113
  88. data/lib/selenium/webdriver/safari.rb +23 -7
  89. data/lib/selenium/{client/javascript_frameworks/jquery.rb → webdriver/safari/apple_bridge.rb} +28 -9
  90. data/lib/selenium/webdriver/safari/browser.rb +0 -2
  91. data/lib/selenium/webdriver/safari/{bridge.rb → legacy_bridge.rb} +12 -9
  92. data/lib/selenium/webdriver/safari/options.rb +3 -4
  93. data/lib/selenium/webdriver/safari/resources/client.js +56 -7255
  94. data/lib/selenium/webdriver/safari/server.rb +18 -24
  95. data/lib/selenium/{client/javascript_frameworks/prototype.rb → webdriver/safari/service.rb} +27 -9
  96. data/lib/selenium/webdriver/support.rb +1 -0
  97. data/lib/selenium/webdriver/support/abstract_event_listener.rb +17 -2
  98. data/lib/selenium/webdriver/support/block_event_listener.rb +1 -3
  99. data/lib/selenium/webdriver/support/color.rb +55 -38
  100. data/lib/selenium/webdriver/{android.rb → support/escaper.rb} +19 -4
  101. data/lib/selenium/webdriver/support/event_firing_bridge.rb +36 -38
  102. data/lib/selenium/webdriver/support/select.rb +33 -84
  103. data/selenium-webdriver.gemspec +23 -23
  104. metadata +19 -30
  105. data/lib/selenium-client.rb +0 -21
  106. data/lib/selenium/client.rb +0 -57
  107. data/lib/selenium/client/base.rb +0 -151
  108. data/lib/selenium/client/driver.rb +0 -29
  109. data/lib/selenium/client/errors.rb +0 -28
  110. data/lib/selenium/client/extensions.rb +0 -132
  111. data/lib/selenium/client/idiomatic.rb +0 -507
  112. data/lib/selenium/client/javascript_expression_builder.rb +0 -135
  113. data/lib/selenium/client/legacy_driver.rb +0 -1722
  114. data/lib/selenium/client/protocol.rb +0 -123
  115. data/lib/selenium/client/selenium_helper.rb +0 -49
  116. data/lib/selenium/rake/server_task.rb +0 -176
  117. data/lib/selenium/webdriver/android/bridge.rb +0 -68
  118. data/lib/selenium/webdriver/common/core_ext/base64.rb +0 -28
  119. data/lib/selenium/webdriver/common/core_ext/dir.rb +0 -61
  120. data/lib/selenium/webdriver/common/html5/location.rb +0 -19
  121. data/lib/selenium/webdriver/ie/server.rb +0 -133
  122. data/lib/selenium/webdriver/iphone/bridge.rb +0 -64
@@ -25,25 +25,24 @@ module Selenium
25
25
  # server is being asked to create.
26
26
  #
27
27
  class W3CCapabilities
28
-
29
28
  DEFAULTS = {
30
- :browser_name => '',
31
- :browser_version => :any,
32
- :platform_name => :any,
33
- :platform_version => :any,
34
- :accept_ssl_certs => false,
35
- :page_load_strategy => 'normal',
36
- :proxy => nil
37
- }
29
+ browser_name: '',
30
+ browser_version: :any,
31
+ platform_name: :any,
32
+ platform_version: :any,
33
+ accept_ssl_certs: false,
34
+ page_load_strategy: 'normal',
35
+ proxy: nil
36
+ }.freeze
38
37
 
39
38
  KNOWN = [
40
- :remote_session_id,
41
- :xul_app_id,
42
- :raise_accessibility_exceptions,
43
- :rotatable,
44
- :app_build_id,
45
- :device
46
- ]
39
+ :remote_session_id,
40
+ :xul_app_id,
41
+ :raise_accessibility_exceptions,
42
+ :rotatable,
43
+ :app_build_id,
44
+ :device
45
+ ].freeze
47
46
 
48
47
  (DEFAULTS.keys + KNOWN).each do |key|
49
48
  define_method key do
@@ -69,28 +68,24 @@ module Selenium
69
68
  #
70
69
 
71
70
  class << self
72
-
73
71
  def edge(opts = {})
74
72
  new({
75
- :browser_name => "MicrosoftEdge",
76
- :platform => :windows,
77
- }.merge(opts))
73
+ browser_name: 'MicrosoftEdge',
74
+ platform: :windows
75
+ }.merge(opts))
78
76
  end
79
77
 
80
78
  def firefox(opts = {})
81
79
  opts[:browser_version] = opts.delete :version
82
80
  opts[:platform_name] = opts.delete :platform
83
81
 
84
- new({
85
- :browser_name => "firefox",
86
- :marionette => true
87
- }.merge(opts))
82
+ new({browser_name: 'firefox'}.merge(opts))
88
83
  end
89
84
 
90
85
  alias_method :ff, :firefox
91
86
 
92
87
  def w3c?(opts = {})
93
- opts[:desired_capabilities].is_a?(W3CCapabilities) || opts[:marionette]
88
+ !opts[:desired_capabilities].is_a?(Capabilities)
94
89
  end
95
90
 
96
91
  #
@@ -101,16 +96,16 @@ module Selenium
101
96
  data = data.dup
102
97
 
103
98
  # Convert due to Remote Driver implementation
104
- data["browserVersion"] = data.delete("version") if data.key? "version"
105
- data["platformName"] = data.delete("platform") if data.key? "platform"
99
+ data['browserVersion'] = data.delete('version') if data.key? 'version'
100
+ data['platformName'] = data.delete('platform') if data.key? 'platform'
106
101
 
107
102
  caps = new
108
- caps.browser_name = data.delete("browserName") if data.key? "browserName"
109
- caps.browser_version = data.delete("browserVersion") if data.key? "browserVersion"
110
- caps.platform_name = data.delete("platformName") if data.key? "platformName"
111
- caps.platform_version = data.delete("platformVersion") if data.key? "platformVersion"
112
- caps.accept_ssl_certs = data.delete("acceptSslCerts") if data.key? "acceptSslCerts"
113
- caps.page_load_strategy = data.delete("pageLoadStrategy") if data.key? "pageloadStrategy"
103
+ caps.browser_name = data.delete('browserName')
104
+ caps.browser_version = data.delete('browserVersion')
105
+ caps.platform_name = data.delete('platformName')
106
+ caps.platform_version = data.delete('platformVersion')
107
+ caps.accept_ssl_certs = data.delete('acceptSslCerts')
108
+ caps.page_load_strategy = data.delete('pageLoadStrategy')
114
109
  proxy = data.delete('proxy')
115
110
  caps.proxy = Proxy.json_create(proxy) unless proxy.nil? || proxy.empty?
116
111
 
@@ -118,11 +113,11 @@ module Selenium
118
113
  caps[:remote_session_id] = data.delete('webdriver.remote.sessionid')
119
114
 
120
115
  # Obsolete capabilities returned by Remote Server
121
- data.delete("javascriptEnabled")
116
+ data.delete('javascriptEnabled')
122
117
  data.delete('cssSelectorsEnabled')
123
118
 
124
119
  # Marionette Specific
125
- caps[:xul_app_id] = data.delete("XULappId")
120
+ caps[:xul_app_id] = data.delete('XULappId')
126
121
  caps[:raise_accessibility_exceptions] = data.delete('raisesAccessibilityExceptions')
127
122
  caps[:rotatable] = data.delete('rotatable')
128
123
  caps[:app_build_id] = data.delete('appBuildId')
@@ -163,12 +158,12 @@ module Selenium
163
158
  end
164
159
 
165
160
  def merge!(other)
166
- if other.respond_to?(:capabilities, true) && other.capabilities.kind_of?(Hash)
161
+ if other.respond_to?(:capabilities, true) && other.capabilities.is_a?(Hash)
167
162
  @capabilities.merge! other.capabilities
168
- elsif other.kind_of? Hash
163
+ elsif other.is_a? Hash
169
164
  @capabilities.merge! other
170
165
  else
171
- raise ArgumentError, "argument should be a Hash or implement #capabilities"
166
+ raise ArgumentError, 'argument should be a Hash or implement #capabilities'
172
167
  end
173
168
  end
174
169
 
@@ -186,7 +181,7 @@ module Selenium
186
181
  # @api private
187
182
  #
188
183
 
189
- def as_json(opts = nil)
184
+ def as_json(*)
190
185
  hash = {}
191
186
 
192
187
  @capabilities.each do |key, value|
@@ -207,12 +202,12 @@ module Selenium
207
202
  hash
208
203
  end
209
204
 
210
- def to_json(*args)
205
+ def to_json(*)
211
206
  JSON.generate as_json
212
207
  end
213
208
 
214
209
  def ==(other)
215
- return false unless other.kind_of? self.class
210
+ return false unless other.is_a? self.class
216
211
  as_json == other.as_json
217
212
  end
218
213
 
@@ -220,16 +215,13 @@ module Selenium
220
215
 
221
216
  protected
222
217
 
223
- def capabilities
224
- @capabilities
225
- end
218
+ attr_reader :capabilities
226
219
 
227
220
  private
228
221
 
229
222
  def camel_case(str)
230
- str.gsub(/_([a-z])/) { $1.upcase }
223
+ str.gsub(/_([a-z])/) { Regexp.last_match(1).upcase }
231
224
  end
232
-
233
225
  end # W3CCapabilities
234
226
  end # Remote
235
227
  end # WebDriver
@@ -17,116 +17,119 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
- class Selenium::WebDriver::Remote::W3CBridge
21
-
22
- #
23
- # http://www.w3.org/TR/2015/WD-webdriver-20150918/#list-of-endpoints
24
- #
25
-
26
- #
27
- # session handling
28
- #
29
-
30
- command :newSession, :post, "session"
31
- command :deleteSession, :delete, "session/:session_id"
32
-
33
-
34
- #
35
- # basic driver
36
- #
37
-
38
- command :get, :post, "session/:session_id/url"
39
- command :getCurrentUrl, :get, "session/:session_id/url"
40
- command :back, :post, "session/:session_id/back"
41
- command :forward, :post, "session/:session_id/forward"
42
- command :refresh, :post, "session/:session_id/refresh"
43
- command :getTitle, :get, "session/:session_id/title"
44
-
45
- #
46
- # window and Frame handling
47
- #
48
-
49
- command :getWindowHandle, :get, "session/:session_id/window"
50
- command :closeWindow, :delete, "session/:session_id/window"
51
- command :switchToWindow, :post, "session/:session_id/window"
52
- command :getWindowHandles, :get, "session/:session_id/window/handles"
53
- command :fullscreenWindow, :post, "session/:session_id/window/fullscreen"
54
- command :maximizeWindow, :post, "session/:session_id/window/maximize"
55
- command :setWindowSize, :post, "session/:session_id/window/size"
56
- command :getWindowSize, :get, "session/:session_id/window/size"
57
- command :switchToFrame, :post, "session/:session_id/frame"
58
- command :switchToParentFrame, :post, "session/:session_id/frame/parent"
59
-
60
- #
61
- # element
62
- #
63
-
64
- command :findElement, :post, "session/:session_id/element"
65
- command :findElements, :post, "session/:session_id/elements"
66
- command :findChildElement, :post, "session/:session_id/element/:id/element"
67
- command :findChildElements, :post, "session/:session_id/element/:id/elements"
68
- command :getActiveElement, :get, "session/:session_id/element/active"
69
- command :isElementSelected, :get, "session/:session_id/element/:id/selected"
70
- command :getElementAttribute, :get, "session/:session_id/element/:id/attribute/:name"
71
- command :getElementProperty, :get, "session/:session_id/element/:id/property/:name"
72
- command :getElementCssValue, :get, "session/:session_id/element/:id/css/:property_name"
73
- command :getElementText, :get, "session/:session_id/element/:id/text"
74
- command :getElementTagName, :get, "session/:session_id/element/:id/name"
75
- command :getElementRect, :get, "session/:session_id/element/:id/rect"
76
- command :isElementEnabled, :get, "session/:session_id/element/:id/enabled"
77
-
78
- #
79
- # script execution
80
- #
81
-
82
- command :executeScript, :post, "session/:session_id/execute/sync"
83
- command :executeAsyncScript, :post, "session/:session_id/execute/async"
84
-
85
- #
86
- # cookies
87
- #
88
-
89
- command :getAllCookies, :get, "session/:session_id/cookie"
90
- command :getCookie, :get, "session/:session_id/cookie/:name"
91
- command :addCookie, :post, "session/:session_id/cookie"
92
- command :deleteCookie, :delete, "session/:session_id/cookie/:name"
93
-
94
- #
95
- # timeouts
96
- #
97
-
98
- command :setTimeout, :post, "session/:session_id/timeouts"
99
-
100
- #
101
- # actions
102
- #
103
-
104
- command :actions, :post, "session/:session_id/actions"
105
-
106
-
107
- #
108
- # Element Operations
109
- #
110
-
111
- command :elementClick, :post, "session/:session_id/element/:id/click"
112
- command :elementTap, :post, "session/:session_id/element/:id/tap"
113
- command :elementClear, :post, "session/:session_id/element/:id/clear"
114
- command :elementSendKeys, :post, "session/:session_id/element/:id/value"
115
-
116
- #
117
- # alerts
118
- #
119
-
120
- command :dismissAlert, :post, "session/:session_id/alert/dismiss"
121
- command :acceptAlert, :post, "session/:session_id/alert/accept"
122
- command :getAlertText, :get, "session/:session_id/alert/text"
123
- command :sendAlertText, :post, "session/:session_id/alert/text"
124
-
125
- #
126
- # screenshot
127
- #
128
-
129
- command :takeScreenshot, :get, "session/:session_id/screenshot"
130
- command :takeElementScreenshot, :get, "session/:session_id/element/:id/screenshot"
131
-
132
- end
20
+ module Selenium
21
+ module WebDriver
22
+ module Remote
23
+ class W3CBridge
24
+ #
25
+ # http://www.w3.org/TR/2015/WD-webdriver-20150918/#list-of-endpoints
26
+ #
27
+
28
+ #
29
+ # session handling
30
+ #
31
+
32
+ command :newSession, :post, 'session'
33
+ command :deleteSession, :delete, 'session/:session_id'
34
+
35
+ #
36
+ # basic driver
37
+ #
38
+
39
+ command :get, :post, 'session/:session_id/url'
40
+ command :getCurrentUrl, :get, 'session/:session_id/url'
41
+ command :back, :post, 'session/:session_id/back'
42
+ command :forward, :post, 'session/:session_id/forward'
43
+ command :refresh, :post, 'session/:session_id/refresh'
44
+ command :getTitle, :get, 'session/:session_id/title'
45
+
46
+ #
47
+ # window and Frame handling
48
+ #
49
+
50
+ command :getWindowHandle, :get, 'session/:session_id/window'
51
+ command :closeWindow, :delete, 'session/:session_id/window'
52
+ command :switchToWindow, :post, 'session/:session_id/window'
53
+ command :getWindowHandles, :get, 'session/:session_id/window/handles'
54
+ command :fullscreenWindow, :post, 'session/:session_id/window/fullscreen'
55
+ command :maximizeWindow, :post, 'session/:session_id/window/maximize'
56
+ command :setWindowSize, :post, 'session/:session_id/window/size'
57
+ command :getWindowSize, :get, 'session/:session_id/window/size'
58
+ command :switchToFrame, :post, 'session/:session_id/frame'
59
+ command :switchToParentFrame, :post, 'session/:session_id/frame/parent'
60
+
61
+ #
62
+ # element
63
+ #
64
+
65
+ command :findElement, :post, 'session/:session_id/element'
66
+ command :findElements, :post, 'session/:session_id/elements'
67
+ command :findChildElement, :post, 'session/:session_id/element/:id/element'
68
+ command :findChildElements, :post, 'session/:session_id/element/:id/elements'
69
+ command :getActiveElement, :get, 'session/:session_id/element/active'
70
+ command :isElementSelected, :get, 'session/:session_id/element/:id/selected'
71
+ command :getElementAttribute, :get, 'session/:session_id/element/:id/attribute/:name'
72
+ command :getElementProperty, :get, 'session/:session_id/element/:id/property/:name'
73
+ command :getElementCssValue, :get, 'session/:session_id/element/:id/css/:property_name'
74
+ command :getElementText, :get, 'session/:session_id/element/:id/text'
75
+ command :getElementTagName, :get, 'session/:session_id/element/:id/name'
76
+ command :getElementRect, :get, 'session/:session_id/element/:id/rect'
77
+ command :isElementEnabled, :get, 'session/:session_id/element/:id/enabled'
78
+
79
+ #
80
+ # document handling
81
+ #
82
+
83
+ command :getPageSource, :get, '/session/:session_id/source'
84
+ command :executeScript, :post, 'session/:session_id/execute/sync'
85
+ command :executeAsyncScript, :post, 'session/:session_id/execute/async'
86
+
87
+ #
88
+ # cookies
89
+ #
90
+
91
+ command :getAllCookies, :get, 'session/:session_id/cookie'
92
+ command :getCookie, :get, 'session/:session_id/cookie/:name'
93
+ command :addCookie, :post, 'session/:session_id/cookie'
94
+ command :deleteCookie, :delete, 'session/:session_id/cookie/:name'
95
+
96
+ #
97
+ # timeouts
98
+ #
99
+
100
+ command :setTimeout, :post, 'session/:session_id/timeouts'
101
+
102
+ #
103
+ # actions
104
+ #
105
+
106
+ command :actions, :post, 'session/:session_id/actions'
107
+
108
+ #
109
+ # Element Operations
110
+ #
111
+
112
+ command :elementClick, :post, 'session/:session_id/element/:id/click'
113
+ command :elementTap, :post, 'session/:session_id/element/:id/tap'
114
+ command :elementClear, :post, 'session/:session_id/element/:id/clear'
115
+ command :elementSendKeys, :post, 'session/:session_id/element/:id/value'
116
+
117
+ #
118
+ # alerts
119
+ #
120
+
121
+ command :dismissAlert, :post, 'session/:session_id/alert/dismiss'
122
+ command :acceptAlert, :post, 'session/:session_id/alert/accept'
123
+ command :getAlertText, :get, 'session/:session_id/alert/text'
124
+ command :sendAlertText, :post, 'session/:session_id/alert/text'
125
+
126
+ #
127
+ # screenshot
128
+ #
129
+
130
+ command :takeScreenshot, :get, 'session/:session_id/screenshot'
131
+ command :takeElementScreenshot, :get, 'session/:session_id/element/:id/screenshot'
132
+ end
133
+ end # Remote
134
+ end # WebDriver
135
+ end # Selenium
@@ -23,6 +23,11 @@ require 'pathname'
23
23
  module Selenium
24
24
  module WebDriver
25
25
  module Safari
26
+ MISSING_TEXT = <<-ERROR.tr("\n", '').freeze
27
+ Unable to find safari extension. Please download the file from
28
+ http://www.seleniumhq.org/download/ and place it
29
+ somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/SafariDriver.
30
+ ERROR
26
31
 
27
32
  class << self
28
33
  def path=(path)
@@ -34,15 +39,15 @@ module Selenium
34
39
  @path ||= (
35
40
  path = case Platform.os
36
41
  when :windows
37
- Platform.find_in_program_files("Safari\\Safari.exe")
42
+ Platform.find_in_program_files('Safari\\Safari.exe')
38
43
  when :macosx
39
- "/Applications/Safari.app/Contents/MacOS/Safari"
44
+ '/Applications/Safari.app/Contents/MacOS/Safari'
40
45
  else
41
- Platform.find_binary("Safari")
46
+ Platform.find_binary('Safari')
42
47
  end
43
48
 
44
49
  unless File.file?(path) && File.executable?(path)
45
- raise Error::WebDriverError, "unable to find the Safari executable, please set Selenium::WebDriver::Safari.path= or add it to your PATH."
50
+ raise Error::WebDriverError, MISSING_TEXT
46
51
  end
47
52
 
48
53
  path
@@ -50,10 +55,18 @@ module Selenium
50
55
  end
51
56
 
52
57
  def resource_path
53
- @resource_path ||= Pathname.new(File.expand_path("../safari/resources", __FILE__))
58
+ @resource_path ||= Pathname.new(File.expand_path('../safari/resources', __FILE__))
59
+ end
60
+
61
+ def driver_path=(path)
62
+ Platform.assert_executable path
63
+ @driver_path = path
54
64
  end
55
- end
56
65
 
66
+ def driver_path
67
+ @driver_path || '/usr/bin/safaridriver'
68
+ end
69
+ end
57
70
  end # Safari
58
71
  end # WebDriver
59
72
  end # Selenium
@@ -61,5 +74,8 @@ end # Selenium
61
74
  require 'selenium/webdriver/safari/browser'
62
75
  require 'selenium/webdriver/safari/server'
63
76
  require 'selenium/webdriver/safari/options'
64
- require 'selenium/webdriver/safari/bridge'
77
+ require 'selenium/webdriver/safari/legacy_bridge'
78
+ require 'selenium/webdriver/safari/apple_bridge'
79
+ require 'selenium/webdriver/safari/service'
65
80
 
81
+ Selenium::WebDriver::Safari::Bridge = Selenium::WebDriver::Safari::LegacyBridge