selenium-webdriver 2.18.0.rc2 → 2.18.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,6 +10,7 @@ module Selenium
10
10
  module WebDriver
11
11
  Point = Struct.new(:x, :y)
12
12
  Dimension = Struct.new(:width, :height)
13
+ Location = Struct.new(:latitude, :longitude, :altitude)
13
14
 
14
15
  autoload :Android, 'selenium/webdriver/android'
15
16
  autoload :Chrome, 'selenium/webdriver/chrome'
@@ -29,7 +29,10 @@ module Selenium
29
29
  [
30
30
  DriverExtensions::TakesScreenshot,
31
31
  DriverExtensions::Rotatable,
32
- DriverExtensions::HasInputDevices
32
+ DriverExtensions::HasInputDevices,
33
+ DriverExtensions::HasWebStorage,
34
+ DriverExtensions::HasLocation,
35
+ DriverExtensions::HasBrowserConnection
33
36
  ]
34
37
  end
35
38
 
@@ -48,4 +51,4 @@ module Selenium
48
51
  end # Bridge
49
52
  end # Android
50
53
  end # WebDriver
51
- end # Selenium
54
+ end # Selenium
@@ -19,9 +19,15 @@ require 'selenium/webdriver/common/window'
19
19
  require 'selenium/webdriver/common/options'
20
20
  require 'selenium/webdriver/common/search_context'
21
21
  require 'selenium/webdriver/common/action_builder'
22
+ require 'selenium/webdriver/common/html5/shared_web_storage'
23
+ require 'selenium/webdriver/common/html5/local_storage'
24
+ require 'selenium/webdriver/common/html5/session_storage'
22
25
  require 'selenium/webdriver/common/driver_extensions/takes_screenshot'
23
26
  require 'selenium/webdriver/common/driver_extensions/rotatable'
27
+ require 'selenium/webdriver/common/driver_extensions/has_browser_connection'
24
28
  require 'selenium/webdriver/common/driver_extensions/has_input_devices'
29
+ require 'selenium/webdriver/common/driver_extensions/has_web_storage'
30
+ require 'selenium/webdriver/common/driver_extensions/has_location'
25
31
  require 'selenium/webdriver/common/driver_extensions/uploads_files'
26
32
  require 'selenium/webdriver/common/keys'
27
33
  require 'selenium/webdriver/common/bridge_helper'
@@ -0,0 +1,17 @@
1
+ module Selenium
2
+ module WebDriver
3
+ module DriverExtensions
4
+
5
+ module HasBrowserConnection
6
+ def online?
7
+ @bridge.isBrowserOnline
8
+ end
9
+
10
+ def online=(bool)
11
+ @bridge.setBrowserOnline bool
12
+ end
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ module Selenium
2
+ module WebDriver
3
+ module DriverExtensions
4
+
5
+ module HasLocation
6
+ def location
7
+ @bridge.getLocation
8
+ end
9
+
10
+ def location=(loc)
11
+ unless loc.kind_of?(Location)
12
+ raise TypeError, "expected #{Location}, got #{loc.inspect}:#{loc.class}"
13
+ end
14
+
15
+ @bridge.setLocation loc.latitude, loc.longitude, loc.altitude
16
+ end
17
+
18
+ def set_location(lat, lon, alt)
19
+ self.location = Location.new(Float(lat), Float(lon), Float(alt))
20
+ end
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,22 @@
1
+ module Selenium
2
+ module WebDriver
3
+
4
+ #
5
+ # @api private
6
+ #
7
+
8
+ module DriverExtensions
9
+ module HasWebStorage
10
+
11
+ def local_storage
12
+ HTML5::LocalStorage.new @bridge
13
+ end
14
+
15
+ def session_storage
16
+ HTML5::SessionStorage.new @bridge
17
+ end
18
+
19
+ end # HasWebStorage
20
+ end # DriverExtensions
21
+ end # WebDriver
22
+ end # Selenium
@@ -0,0 +1,42 @@
1
+ module Selenium
2
+ module WebDriver
3
+ module HTML5
4
+
5
+ class LocalStorage
6
+ include SharedWebStorage
7
+
8
+ #
9
+ # @api private
10
+ #
11
+ def initialize(bridge)
12
+ @bridge = bridge
13
+ end
14
+
15
+ def [](key)
16
+ @bridge.getLocalStorageItem key
17
+ end
18
+
19
+ def []=(key, value)
20
+ @bridge.setLocalStorageItem key, value
21
+ end
22
+
23
+ def delete(key)
24
+ @bridge.removeLocalStorageItem key
25
+ end
26
+
27
+ def clear
28
+ @bridge.clearLocalStorage
29
+ end
30
+
31
+ def size
32
+ @bridge.getLocalStorageSize
33
+ end
34
+
35
+ def keys
36
+ @bridge.getLocalStorageKeys.reverse
37
+ end
38
+ end
39
+
40
+ end
41
+ end
42
+ end
File without changes
@@ -0,0 +1,44 @@
1
+ module Selenium
2
+ module WebDriver
3
+ module HTML5
4
+
5
+ class SessionStorage
6
+ include Enumerable
7
+ include SharedWebStorage
8
+
9
+ def [](key)
10
+ @bridge.getSessionStorageItem key
11
+ end
12
+
13
+ def []=(key, value)
14
+ @bridge.setSessionStorageItem key, value
15
+ end
16
+
17
+ def delete(key)
18
+ @bridge.removeSessionStorageItem key
19
+ end
20
+
21
+ def clear
22
+ @bridge.clearSessionStorage
23
+ end
24
+
25
+ def size
26
+ @bridge.getSessionStorageSize
27
+ end
28
+
29
+ def keys
30
+ @bridge.getSessionStorageKeys.reverse
31
+ end
32
+
33
+ #
34
+ # @api private
35
+ #
36
+
37
+ def initialize(bridge)
38
+ @bridge = bridge
39
+ end
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,42 @@
1
+ module Selenium
2
+ module WebDriver
3
+ module HTML5
4
+
5
+ module SharedWebStorage
6
+ include Enumerable
7
+
8
+ def key?(key)
9
+ keys.include? key
10
+ end
11
+ alias_method :member?, :key?
12
+ alias_method :has_key?, :key?
13
+
14
+ def fetch(key, &blk)
15
+ if self.key? key
16
+ return self[key]
17
+ end
18
+
19
+ if block_given?
20
+ yield key
21
+ else
22
+ # should be KeyError, but it's 1.9-specific
23
+ raise IndexError, "missing key #{key.inspect}"
24
+ end
25
+ end
26
+
27
+ def empty?
28
+ size == 0
29
+ end
30
+
31
+ def each(&blk)
32
+ return enum_for(:each) unless block_given?
33
+
34
+ keys.each do |k|
35
+ yield k, self[k]
36
+ end
37
+ end
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -149,6 +149,10 @@ module Selenium
149
149
  info[0][3]
150
150
  end
151
151
 
152
+ def ip
153
+ IPSocket.getaddress(Socket.gethostname)
154
+ end
155
+
152
156
  end # Platform
153
157
  end # WebDriver
154
158
  end # Selenium
@@ -162,5 +166,6 @@ if __FILE__ == $0
162
166
  :windows? => Selenium::WebDriver::Platform.windows?,
163
167
  :home => Selenium::WebDriver::Platform.home,
164
168
  :bitsize => Selenium::WebDriver::Platform.bitsize,
165
- :localhost => Selenium::WebDriver::Platform.localhost
169
+ :localhost => Selenium::WebDriver::Platform.localhost,
170
+ :ip => Selenium::WebDriver::Platform.ip
166
171
  end
@@ -7,7 +7,7 @@ module Selenium
7
7
 
8
8
  class Bridge < Remote::Bridge
9
9
 
10
- DEFAULT_URL = "http://#{Platform.localhost}:3001/hub/"
10
+ DEFAULT_URL = "http://#{Platform.localhost}:3001/wd/hub/"
11
11
 
12
12
  def initialize(opts = {})
13
13
  remote_opts = {
@@ -27,7 +27,9 @@ module Selenium
27
27
  def driver_extensions
28
28
  [
29
29
  DriverExtensions::TakesScreenshot,
30
- DriverExtensions::HasInputDevices
30
+ DriverExtensions::HasInputDevices,
31
+ DriverExtensions::HasWebStorage,
32
+ DriverExtensions::HasLocation
31
33
  ]
32
34
  end
33
35
 
@@ -195,6 +195,10 @@ module Selenium
195
195
  execute :refresh
196
196
  end
197
197
 
198
+ #
199
+ # window handling
200
+ #
201
+
198
202
  def getWindowHandles
199
203
  execute :getWindowHandles
200
204
  end
@@ -230,6 +234,80 @@ module Selenium
230
234
  execute :screenshot
231
235
  end
232
236
 
237
+ #
238
+ # HTML 5
239
+ #
240
+
241
+ def getLocalStorageItem(key)
242
+ execute :getLocalStorageItem, :key => key
243
+ end
244
+
245
+ def removeLocalStorageItem(key)
246
+ execute :removeLocalStorageItem, :key => key
247
+ end
248
+
249
+ def getLocalStorageKeys
250
+ execute :getLocalStorageKeys
251
+ end
252
+
253
+ def setLocalStorageItem(key, value)
254
+ execute :setLocalStorageItem, {}, :key => key, :value => value
255
+ end
256
+
257
+ def clearLocalStorage
258
+ execute :clearLocalStorage
259
+ end
260
+
261
+ def getLocalStorageSize
262
+ execute :getLocalStorageSize
263
+ end
264
+
265
+ def getSessionStorageItem(key)
266
+ execute :getSessionStorageItem, :key => key
267
+ end
268
+
269
+ def removeSessionStorageItem(key)
270
+ execute :removeSessionStorageItem, :key => key
271
+ end
272
+
273
+ def getSessionStorageKeys
274
+ execute :getSessionStorageKeys
275
+ end
276
+
277
+ def setSessionStorageItem(key, value)
278
+ execute :setSessionStorageItem, {}, :key => key, :value => value
279
+ end
280
+
281
+ def clearSessionStorage
282
+ execute :clearSessionStorage
283
+ end
284
+
285
+ def getSessionStorageSize
286
+ execute :getSessionStorageSize
287
+ end
288
+
289
+ def getLocation
290
+ obj = execute(:getLocation) || {} # android returns null
291
+ Location.new obj['latitude'], obj['longitude'], obj['altitude']
292
+ end
293
+
294
+ def setLocation(lat, lon, alt)
295
+ loc = {:latitude => lat, :longitude => lon, :altitude => alt}
296
+ execute :setLocation, {}, :location => loc
297
+ end
298
+
299
+ def isBrowserOnline
300
+ execute :isBrowserOnline
301
+ end
302
+
303
+ def setBrowserOnline(bool)
304
+ execute :setBrowserOnline, {}, :state => bool
305
+ end
306
+
307
+ #
308
+ # javascript execution
309
+ #
310
+
233
311
  def executeScript(script, *args)
234
312
  assert_javascript_enabled
235
313
 
@@ -244,6 +322,10 @@ module Selenium
244
322
  unwrap_script_result result
245
323
  end
246
324
 
325
+ #
326
+ # cookies
327
+ #
328
+
247
329
  def addCookie(cookie)
248
330
  execute :addCookie, {}, :cookie => cookie
249
331
  end
@@ -260,6 +342,10 @@ module Selenium
260
342
  execute :deleteAllCookies
261
343
  end
262
344
 
345
+ #
346
+ # actions
347
+ #
348
+
263
349
  def clickElement(element)
264
350
  execute :clickElement, :id => element
265
351
  end
@@ -298,6 +384,39 @@ module Selenium
298
384
  execute :sendKeysToActiveElement, {}, :value => key
299
385
  end
300
386
 
387
+ def sendKeysToElement(element, keys)
388
+ if @file_detector && local_file = @file_detector.call(keys)
389
+ keys = upload(local_file)
390
+ end
391
+
392
+ execute :sendKeysToElement, {:id => element}, {:value => Array(keys)}
393
+ end
394
+
395
+ def upload(local_file)
396
+ unless File.file?(local_file)
397
+ raise WebDriverError::Error, "you may only upload files: #{local_file.inspect}"
398
+ end
399
+
400
+ execute :uploadFile, {}, :file => Zipper.zip_file(local_file)
401
+ end
402
+
403
+ def clearElement(element)
404
+ execute :clearElement, :id => element
405
+ end
406
+
407
+
408
+ def submitElement(element)
409
+ execute :submitElement, :id => element
410
+ end
411
+
412
+ def dragElement(element, right_by, down_by)
413
+ execute :dragElement, {:id => element}, :x => right_by, :y => down_by
414
+ end
415
+
416
+ #
417
+ # element properties
418
+ #
419
+
301
420
  def getElementTagName(element)
302
421
  execute :getElementTagName, :id => element
303
422
  end
@@ -332,26 +451,6 @@ module Selenium
332
451
  Dimension.new data['width'], data['height']
333
452
  end
334
453
 
335
- def sendKeysToElement(element, keys)
336
- if @file_detector && local_file = @file_detector.call(keys)
337
- keys = upload(local_file)
338
- end
339
-
340
- execute :sendKeysToElement, {:id => element}, {:value => Array(keys)}
341
- end
342
-
343
- def upload(local_file)
344
- unless File.file?(local_file)
345
- raise WebDriverError::Error, "you may only upload files: #{local_file.inspect}"
346
- end
347
-
348
- execute :uploadFile, {}, :file => Zipper.zip_file(local_file)
349
- end
350
-
351
- def clearElement(element)
352
- execute :clearElement, :id => element
353
- end
354
-
355
454
  def isElementEnabled(element)
356
455
  execute :isElementEnabled, :id => element
357
456
  end
@@ -363,28 +462,10 @@ module Selenium
363
462
  def isElementDisplayed(element)
364
463
  execute :isElementDisplayed, :id => element
365
464
  end
366
-
367
- def submitElement(element)
368
- execute :submitElement, :id => element
369
- end
370
-
371
- def setElementSelected(element)
372
- execute :setElementSelected, :id => element
373
- end
374
-
375
465
  def getElementValueOfCssProperty(element, prop)
376
466
  execute :getElementValueOfCssProperty, :id => element, :property_name => prop
377
467
  end
378
468
 
379
- def getActiveElement
380
- Element.new self, element_id_from(execute(:getActiveElement))
381
- end
382
- alias_method :switchToActiveElement, :getActiveElement
383
-
384
- def dragElement(element, right_by, down_by)
385
- execute :dragElement, {:id => element}, :x => right_by, :y => down_by
386
- end
387
-
388
469
  def elementEquals(element, other)
389
470
  if element.ref == other.ref
390
471
  true
@@ -393,6 +474,15 @@ module Selenium
393
474
  end
394
475
  end
395
476
 
477
+ #
478
+ # finding elements
479
+ #
480
+
481
+ def getActiveElement
482
+ Element.new self, element_id_from(execute(:getActiveElement))
483
+ end
484
+ alias_method :switchToActiveElement, :getActiveElement
485
+
396
486
  def find_element_by(how, what, parent = nil)
397
487
  if parent
398
488
  id = execute :findChildElement, {:id => parent}, {:using => how, :value => what}
@@ -98,7 +98,6 @@ class Selenium::WebDriver::Remote::Bridge
98
98
  command :getElementTagName, :get, "session/:session_id/element/:id/name"
99
99
  command :clearElement, :post, "session/:session_id/element/:id/clear"
100
100
  command :isElementSelected, :get, "session/:session_id/element/:id/selected"
101
- command :setElementSelected, :post, "session/:session_id/element/:id/selected"
102
101
  command :isElementEnabled, :get, "session/:session_id/element/:id/enabled"
103
102
  command :getElementAttribute, :get, "session/:session_id/element/:id/attribute/:name"
104
103
  command :elementEquals, :get, "session/:session_id/element/:id/equals/:other"
@@ -134,11 +133,14 @@ class Selenium::WebDriver::Remote::Bridge
134
133
  #
135
134
 
136
135
  command :executeSql, :post, "session/:session_id/execute_sql"
136
+
137
137
  command :getLocation, :get, "session/:session_id/location"
138
138
  command :setLocation, :post, "session/:session_id/location"
139
+
139
140
  command :getAppCache, :get, "session/:session_id/application_cache"
140
141
  command :getAppCacheStatus, :get, "session/:session_id/application_cache/status"
141
142
  command :clearAppCache, :delete, "session/:session_id/application_cache/clear"
143
+
142
144
  command :isBrowserOnline, :get, "session/:session_id/browser_connection"
143
145
  command :setBrowserOnline, :post, "session/:session_id/browser_connection"
144
146
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: selenium-webdriver
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 7
5
- version: 2.18.0.rc2
5
+ version: 2.18.0.rc3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jari Bakken
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-01-24 00:00:00 +01:00
13
+ date: 2012-01-27 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -166,10 +166,17 @@ files:
166
166
  - lib/selenium/webdriver/common/core_ext/base64.rb
167
167
  - lib/selenium/webdriver/common/core_ext/dir.rb
168
168
  - lib/selenium/webdriver/common/core_ext/string.rb
169
+ - lib/selenium/webdriver/common/driver_extensions/has_browser_connection.rb
169
170
  - lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb
171
+ - lib/selenium/webdriver/common/driver_extensions/has_location.rb
172
+ - lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb
170
173
  - lib/selenium/webdriver/common/driver_extensions/rotatable.rb
171
174
  - lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb
172
175
  - lib/selenium/webdriver/common/driver_extensions/uploads_files.rb
176
+ - lib/selenium/webdriver/common/html5/local_storage.rb
177
+ - lib/selenium/webdriver/common/html5/location.rb
178
+ - lib/selenium/webdriver/common/html5/session_storage.rb
179
+ - lib/selenium/webdriver/common/html5/shared_web_storage.rb
173
180
  - lib/selenium/webdriver/firefox/binary.rb
174
181
  - lib/selenium/webdriver/firefox/bridge.rb
175
182
  - lib/selenium/webdriver/firefox/extension.rb