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
@@ -20,7 +20,6 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Chrome
23
-
24
23
  #
25
24
  # @private
26
25
  #
@@ -53,17 +52,17 @@ module Selenium
53
52
  #
54
53
 
55
54
  def []=(key, value)
56
- parts = key.split(".")
57
- parts[0..-2].inject(prefs) { |pr, k| pr[k] ||= {} }[parts.last] = value
55
+ parts = key.split('.')
56
+ parts[0..-2].inject(prefs) { |a, e| a[e] ||= {} }[parts.last] = value
58
57
  end
59
58
 
60
59
  def [](key)
61
- parts = key.split(".")
62
- parts.inject(prefs) { |pr, k| pr.fetch(k) }
60
+ parts = key.split('.')
61
+ parts.inject(prefs) { |a, e| a.fetch(e) }
63
62
  end
64
63
 
65
64
  def layout_on_disk
66
- dir = @model ? create_tmp_copy(@model) : Dir.mktmpdir("webdriver-chrome-profile")
65
+ dir = @model ? create_tmp_copy(@model) : Dir.mktmpdir('webdriver-chrome-profile')
67
66
  FileReaper << dir
68
67
 
69
68
  write_prefs_to dir
@@ -73,7 +72,7 @@ module Selenium
73
72
 
74
73
  def as_json(opts = nil)
75
74
  extensions = @extensions.map do |crx_path|
76
- File.open(crx_path, "rb") { |crx_file| Base64.strict_encode64 crx_file.read }
75
+ File.open(crx_path, 'rb') { |crx_file| Base64.strict_encode64 crx_file.read }
77
76
  end
78
77
 
79
78
  extensions.concat(@encoded_extensions)
@@ -87,7 +86,7 @@ module Selenium
87
86
  prefs_file = prefs_file_for(dir)
88
87
 
89
88
  FileUtils.mkdir_p File.dirname(prefs_file)
90
- File.open(prefs_file, "w") { |file| file << JSON.generate(prefs) }
89
+ File.open(prefs_file, 'w') { |file| file << JSON.generate(prefs) }
91
90
  end
92
91
 
93
92
  def prefs
@@ -103,7 +102,6 @@ module Selenium
103
102
  File.join dir, 'Default', 'Preferences'
104
103
  end
105
104
  end # Profile
106
-
107
105
  end # Chrome
108
106
  end # WebDriver
109
107
  end # Selenium
@@ -20,107 +20,31 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Chrome
23
-
24
23
  #
25
24
  # @api private
26
25
  #
27
26
 
28
- class Service
29
- START_TIMEOUT = 20
30
- SOCKET_LOCK_TIMEOUT = 45
31
- STOP_TIMEOUT = 5
32
- DEFAULT_PORT = 9515
33
- MISSING_TEXT = "Unable to find the chromedriver executable. Please download the server from http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver."
34
-
35
- def self.executable_path
36
- @executable_path ||= (
37
- path = Platform.find_binary "chromedriver"
38
- path or raise Error::WebDriverError, MISSING_TEXT
39
- Platform.assert_executable path
40
-
41
- path
42
- )
43
- end
44
-
45
- def self.executable_path=(path)
46
- Platform.assert_executable path
47
- @executable_path = path
48
- end
49
-
50
- def self.default_service(*extra_args)
51
- new executable_path, DEFAULT_PORT, *extra_args
52
- end
53
-
54
- def initialize(executable_path, port, *extra_args)
55
- @executable_path = executable_path
56
- @host = Platform.localhost
57
- @port = Integer(port)
58
-
59
- raise Error::WebDriverError, "invalid port: #{@port}" if @port < 1
60
-
61
- @extra_args = extra_args
62
- end
63
-
64
- def start
65
- Platform.exit_hook { stop } # make sure we don't leave the server running
66
-
67
- socket_lock.locked do
68
- find_free_port
69
- start_process
70
- connect_until_stable
71
- end
72
- end
73
-
74
- def stop
75
- return if @process.nil? || @process.exited?
76
-
77
- Net::HTTP.start(@host, @port) do |http|
78
- http.open_timeout = STOP_TIMEOUT / 2
79
- http.read_timeout = STOP_TIMEOUT / 2
80
-
81
- http.get("/shutdown")
82
- end
83
- ensure
84
- stop_process
85
- end
86
-
87
- def uri
88
- URI.parse "http://#{@host}:#{@port}"
89
- end
27
+ class Service < WebDriver::Service
28
+ DEFAULT_PORT = 9515
90
29
 
91
30
  private
92
31
 
93
- def find_free_port
94
- @port = PortProber.above @port
95
- end
96
-
97
32
  def start_process
98
33
  server_command = [@executable_path, "--port=#{@port}", *@extra_args]
99
34
  @process = ChildProcess.build(*server_command)
100
35
 
101
- @process.io.inherit! if $DEBUG == true
36
+ @process.io.inherit! if $DEBUG
102
37
  @process.start
103
38
  end
104
39
 
105
- def stop_process
106
- @process.poll_for_exit STOP_TIMEOUT
107
- rescue ChildProcess::TimeoutError
108
- @process.stop STOP_TIMEOUT
109
- end
110
-
111
- def connect_until_stable
112
- socket_poller = SocketPoller.new @host, @port, START_TIMEOUT
113
-
114
- unless socket_poller.connected?
115
- raise Error::WebDriverError, "unable to connect to chromedriver #{@host}:#{@port}"
116
- end
40
+ def stop_server
41
+ connect_to_server { |http| http.get('/shutdown') }
117
42
  end
118
43
 
119
- def socket_lock
120
- @socket_lock ||= SocketLock.new(@port - 1, SOCKET_LOCK_TIMEOUT)
44
+ def cannot_connect_error_text
45
+ "unable to connect to chromedriver #{@host}:#{@port}"
121
46
  end
122
-
123
47
  end # Service
124
48
  end # Chrome
125
49
  end # WebDriver
126
- end # Service
50
+ end # Selenium
@@ -17,14 +17,13 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
- require 'selenium/webdriver/common/core_ext/dir'
21
- require 'selenium/webdriver/common/core_ext/base64'
22
20
  require 'selenium/webdriver/common/w3c_error'
23
21
  require 'selenium/webdriver/common/error'
24
22
  require 'selenium/webdriver/common/platform'
25
23
  require 'selenium/webdriver/common/proxy'
26
24
  require 'selenium/webdriver/common/log_entry'
27
25
  require 'selenium/webdriver/common/file_reaper'
26
+ require 'selenium/webdriver/common/service'
28
27
  require 'selenium/webdriver/common/socket_lock'
29
28
  require 'selenium/webdriver/common/socket_poller'
30
29
  require 'selenium/webdriver/common/port_prober'
@@ -19,7 +19,6 @@
19
19
 
20
20
  module Selenium
21
21
  module WebDriver
22
-
23
22
  #
24
23
  # The ActionBuilder provides the user a way to set up and perform
25
24
  # complex user interactions.
@@ -39,18 +38,17 @@ module Selenium
39
38
  #
40
39
 
41
40
  class ActionBuilder
42
-
43
41
  #
44
42
  # @api private
45
43
  #
46
44
 
47
45
  def initialize(mouse, keyboard)
48
- @devices = {
49
- :mouse => mouse,
50
- :keyboard => keyboard
46
+ @devices = {
47
+ mouse: mouse,
48
+ keyboard: keyboard
51
49
  }
52
50
 
53
- @actions = []
51
+ @actions = []
54
52
  end
55
53
 
56
54
  #
@@ -70,7 +68,7 @@ module Selenium
70
68
  #
71
69
  # @example Press a key on an element
72
70
  #
73
- # el = driver.find_element(:id, "some_id")
71
+ # el = driver.find_element(id: "some_id")
74
72
  # driver.action.key_down(el, :shift).perform
75
73
  #
76
74
  # @param [:shift, :alt, :control, :command, :meta] The key to press.
@@ -80,9 +78,7 @@ module Selenium
80
78
  #
81
79
 
82
80
  def key_down(*args)
83
- if args.first.kind_of? Element
84
- @actions << [:mouse, :click, [args.shift]]
85
- end
81
+ @actions << [:mouse, :click, [args.shift]] if args.first.is_a? Element
86
82
 
87
83
  @actions << [:keyboard, :press, args]
88
84
  self
@@ -98,7 +94,7 @@ module Selenium
98
94
  #
99
95
  # @example Release a key from an element
100
96
  #
101
- # el = driver.find_element(:id, "some_id")
97
+ # el = driver.find_element(id: "some_id")
102
98
  # driver.action.key_up(el, :alt).perform
103
99
  #
104
100
  # @param [:shift, :alt, :control, :command, :meta] The modifier key to release.
@@ -108,9 +104,7 @@ module Selenium
108
104
  #
109
105
 
110
106
  def key_up(*args)
111
- if args.first.kind_of? Element
112
- @actions << [:mouse, :click, [args.shift]]
113
- end
107
+ @actions << [:mouse, :click, [args.shift]] if args.first.is_a? Element
114
108
 
115
109
  @actions << [:keyboard, :release, args]
116
110
  self
@@ -125,7 +119,7 @@ module Selenium
125
119
  #
126
120
  # @example Send the text "help" to an element
127
121
  #
128
- # el = driver.find_element(:id, "some_id")
122
+ # el = driver.find_element(id: "some_id")
129
123
  # driver.action.send_keys(el, "help").perform
130
124
  #
131
125
  # @example Send the text "help" to the currently focused element
@@ -138,9 +132,7 @@ module Selenium
138
132
  #
139
133
 
140
134
  def send_keys(*args)
141
- if args.first.kind_of? Element
142
- @actions << [:mouse, :click, [args.shift]]
143
- end
135
+ @actions << [:mouse, :click, [args.shift]] if args.first.is_a? Element
144
136
 
145
137
  @actions << [:keyboard, :send_keys, args]
146
138
  self
@@ -154,7 +146,7 @@ module Selenium
154
146
  #
155
147
  # @example Clicking and holding on some element
156
148
  #
157
- # el = driver.find_element(:id, "some_id")
149
+ # el = driver.find_element(id: "some_id")
158
150
  # driver.action.click_and_hold(el).perform
159
151
  #
160
152
  # @param [Selenium::WebDriver::Element] element the element to move to and click.
@@ -171,7 +163,7 @@ module Selenium
171
163
  #
172
164
  # @example Releasing an element after clicking and holding it
173
165
  #
174
- # el = driver.find_element(:id, "some_id")
166
+ # el = driver.find_element(id: "some_id")
175
167
  # driver.action.click_and_hold(el).release.perform
176
168
  #
177
169
  # @return [ActionBuilder] A self reference.
@@ -191,7 +183,7 @@ module Selenium
191
183
  #
192
184
  # @example Clicking on an element
193
185
  #
194
- # el = driver.find_element(:id, "some_id")
186
+ # el = driver.find_element(id: "some_id")
195
187
  # driver.action.click(el).perform
196
188
  #
197
189
  # @example Clicking at the current mouse position
@@ -214,7 +206,7 @@ module Selenium
214
206
  #
215
207
  # @example Double click an element
216
208
  #
217
- # el = driver.find_element(:id, "some_id")
209
+ # el = driver.find_element(id: "some_id")
218
210
  # driver.action.double_click(el).perform
219
211
  #
220
212
  # @param [Selenium::WebDriver::Element] element An optional element to move to.
@@ -235,12 +227,12 @@ module Selenium
235
227
  #
236
228
  # @example Scroll element into view and move the mouse to it
237
229
  #
238
- # el = driver.find_element(:id, "some_id")
230
+ # el = driver.find_element(id: "some_id")
239
231
  # driver.action.move_to(el).perform
240
232
  #
241
233
  # @example
242
234
  #
243
- # el = driver.find_element(:id, "some_id")
235
+ # el = driver.find_element(id: "some_id")
244
236
  # driver.action.move_to(el, 100, 100).perform
245
237
  #
246
238
  # @param [Selenium::WebDriver::Element] element to move to.
@@ -252,11 +244,11 @@ module Selenium
252
244
  #
253
245
 
254
246
  def move_to(element, right_by = nil, down_by = nil)
255
- if right_by && down_by
256
- @actions << [:mouse, :move_to, [element, right_by, down_by]]
257
- else
258
- @actions << [:mouse, :move_to, [element]]
259
- end
247
+ @actions << if right_by && down_by
248
+ [:mouse, :move_to, [element, Integer(right_by), Integer(down_by)]]
249
+ else
250
+ [:mouse, :move_to, [element]]
251
+ end
260
252
 
261
253
  self
262
254
  end
@@ -281,7 +273,7 @@ module Selenium
281
273
  #
282
274
 
283
275
  def move_by(right_by, down_by)
284
- @actions << [:mouse, :move_by, [right_by, down_by]]
276
+ @actions << [:mouse, :move_by, [Integer(right_by), Integer(down_by)]]
285
277
  self
286
278
  end
287
279
 
@@ -291,7 +283,7 @@ module Selenium
291
283
  #
292
284
  # @example Context-click at middle of given element
293
285
  #
294
- # el = driver.find_element(:id, "some_id")
286
+ # el = driver.find_element(id: "some_id")
295
287
  # driver.action.context_click(el).perform
296
288
  #
297
289
  # @param [Selenium::WebDriver::Element] element An element to context click.
@@ -310,8 +302,8 @@ module Selenium
310
302
  #
311
303
  # @example Drag and drop one element onto another
312
304
  #
313
- # el1 = driver.find_element(:id, "some_id1")
314
- # el2 = driver.find_element(:id, "some_id2")
305
+ # el1 = driver.find_element(id: "some_id1")
306
+ # el2 = driver.find_element(id: "some_id2")
315
307
  # driver.action.drag_and_drop(el1, el2).perform
316
308
  #
317
309
  # @param [Selenium::WebDriver::Element] source element to emulate button down at.
@@ -334,7 +326,7 @@ module Selenium
334
326
  #
335
327
  # @example Drag and drop an element by offset
336
328
  #
337
- # el = driver.find_element(:id, "some_id1")
329
+ # el = driver.find_element(id: "some_id1")
338
330
  # driver.action.drag_and_drop_by(el, 100, 100).perform
339
331
  #
340
332
  # @param [Selenium::WebDriver::Element] source Element to emulate button down at.
@@ -353,19 +345,17 @@ module Selenium
353
345
  self
354
346
  end
355
347
 
356
-
357
348
  #
358
349
  # Executes the actions added to the builder.
359
350
  #
360
351
 
361
352
  def perform
362
- @actions.each { |receiver, method, args|
353
+ @actions.each do |receiver, method, args|
363
354
  @devices.fetch(receiver).__send__(method, *args)
364
- }
355
+ end
365
356
 
366
357
  nil
367
358
  end
368
-
369
359
  end # ActionBuilder
370
360
  end # WebDriver
371
361
  end # Selenium
@@ -20,36 +20,33 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  class Alert
23
-
24
23
  def initialize(bridge)
25
24
  @bridge = bridge
26
25
 
27
26
  # fail fast if the alert doesn't exist
28
- bridge.getAlertText
27
+ bridge.alert_text
29
28
  end
30
29
 
31
30
  def accept
32
- @bridge.acceptAlert
31
+ @bridge.accept_alert
33
32
  end
34
33
 
35
34
  def dismiss
36
- @bridge.dismissAlert
35
+ @bridge.dismiss_alert
37
36
  end
38
37
 
39
38
  def send_keys(keys)
40
- @bridge.setAlertValue keys
39
+ @bridge.alert = keys
41
40
  end
42
41
 
43
42
  def text
44
- @bridge.getAlertText
43
+ @bridge.alert_text
45
44
  end
46
-
45
+
47
46
  def authenticate(username, password)
48
- @bridge.setAuthentication username: username, password: password
47
+ @bridge.authentication(username: username, password: password)
49
48
  accept
50
49
  end
51
-
52
50
  end # Alert
53
51
  end # WebDriver
54
52
  end # Selenium
55
-
@@ -19,7 +19,6 @@
19
19
 
20
20
  module Selenium
21
21
  module WebDriver
22
-
23
22
  #
24
23
  # Shared across bridges
25
24
  #
@@ -27,24 +26,21 @@ module Selenium
27
26
  #
28
27
 
29
28
  module BridgeHelper
30
-
31
29
  def unwrap_script_result(arg)
32
30
  case arg
33
31
  when Array
34
32
  arg.map { |e| unwrap_script_result(e) }
35
33
  when Hash
36
- if id = element_id_from(arg)
37
- Element.new self, id
38
- else
39
- arg.each { |k, v| arg[k] = unwrap_script_result(v) }
40
- end
34
+ id = element_id_from(arg)
35
+ return Element.new(self, id) if id
36
+ arg.each { |k, v| arg[k] = unwrap_script_result(v) }
41
37
  else
42
38
  arg
43
39
  end
44
40
  end
45
41
 
46
42
  def element_id_from(id)
47
- id['ELEMENT'] or id['element-6066-11e4-a52e-4f735466cecf']
43
+ id['ELEMENT'] || id['element-6066-11e4-a52e-4f735466cecf']
48
44
  end
49
45
 
50
46
  def parse_cookie_string(str)
@@ -57,22 +53,22 @@ module Selenium
57
53
  'secure' => false
58
54
  }
59
55
 
60
- str.split(";").each do |attribute|
61
- if attribute.include? "="
62
- key, value = attribute.strip.split("=", 2)
56
+ str.split(';').each do |attribute|
57
+ if attribute.include? '='
58
+ key, value = attribute.strip.split('=', 2)
63
59
  if result['name'].empty?
64
60
  result['name'] = key
65
61
  result['value'] = value
66
62
  elsif key == 'domain' && value.strip =~ /^\.(.+)/
67
- result['domain'] = $1
63
+ result['domain'] = Regexp.last_match(1)
68
64
  elsif key && value
69
65
  result[key] = value
70
66
  end
71
- elsif attribute == "secure"
67
+ elsif attribute == 'secure'
72
68
  result['secure'] = true
73
69
  end
74
70
 
75
- unless [nil, "", "0"].include?(result['expires'])
71
+ unless [nil, '', '0'].include?(result['expires'])
76
72
  # firefox stores expiry as number of seconds
77
73
  result['expires'] = Time.at(result['expires'].to_i)
78
74
  end
@@ -80,7 +76,6 @@ module Selenium
80
76
 
81
77
  result
82
78
  end
83
-
84
79
  end # BridgeHelper
85
80
  end # WebDriver
86
81
  end # Selenium