selenium-webdriver 2.10.0 → 2.12.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,19 @@
1
+ 2.12.0 (2011-11-10)
2
+ ===================
3
+
4
+ * Loosened the ffi dependency now that Windows support is back (#2755).
5
+ * Fix shutdown issues when using net-http-persistent against remote servers.
6
+ * Added beta window control API (see Selenium::WebDriver::Options#window).
7
+ * Firefox
8
+ * Support for Firefox 8.
9
+ * Better reporting of page size when attempting to move out of bounds.
10
+ * Beta implementation of window control.
11
+
12
+ 2.11.0
13
+ ======
14
+
15
+ (release skipped since it included only server-side changes)
16
+
1
17
  2.10.0 (2011-10-27)
2
18
  ===================
3
19
 
@@ -12,8 +28,6 @@
12
28
  * IE:
13
29
  * Improve handling of #clear on disabled or readonly elements.
14
30
 
15
-
16
-
17
31
  2.9.1 (2011-10-24)
18
32
  ==================
19
33
 
@@ -55,7 +55,13 @@ module Selenium
55
55
  def stop
56
56
  return if @process.nil? || @process.exited?
57
57
 
58
- Net::HTTP.get uri.host, '/shutdown', uri.port
58
+ Net::HTTP.start(uri.host, uri.port) do |http|
59
+ http.open_timeout = STOP_TIMEOUT / 2
60
+ http.read_timeout = STOP_TIMEOUT / 2
61
+
62
+ http.head("/shutdown")
63
+ end
64
+
59
65
  @process.poll_for_exit STOP_TIMEOUT
60
66
  rescue ChildProcess::TimeoutError
61
67
  # ok, force quit
@@ -15,6 +15,7 @@ require 'selenium/webdriver/common/keyboard'
15
15
  require 'selenium/webdriver/common/target_locator'
16
16
  require 'selenium/webdriver/common/navigation'
17
17
  require 'selenium/webdriver/common/timeouts'
18
+ require 'selenium/webdriver/common/window'
18
19
  require 'selenium/webdriver/common/options'
19
20
  require 'selenium/webdriver/common/search_context'
20
21
  require 'selenium/webdriver/common/action_builder'
@@ -89,6 +89,14 @@ module Selenium
89
89
  def timeouts
90
90
  @timeouts ||= Timeouts.new(@bridge)
91
91
  end
92
+
93
+ #
94
+ # @api beta This API may be changed or removed in a future release.
95
+ #
96
+
97
+ def window
98
+ @window ||= Window.new(@bridge)
99
+ end
92
100
 
93
101
  private
94
102
 
@@ -0,0 +1,59 @@
1
+ module Selenium
2
+ module WebDriver
3
+
4
+ #
5
+ # @api beta This API may be changed or removed in a future release.
6
+ #
7
+
8
+ class Window
9
+
10
+ def initialize(bridge)
11
+ @bridge = bridge
12
+ end
13
+
14
+ def size=(dimension)
15
+ unless dimension.respond_to?(:width) && dimension.respond_to?(:height)
16
+ raise ArgumentError, "expected #{dimension.inspect}:#{dimension.class}" +
17
+ " to respond to #width and #height"
18
+ end
19
+
20
+ @bridge.setWindowSize dimension.width, dimension.height
21
+ end
22
+
23
+ def size
24
+ @bridge.getWindowSize
25
+ end
26
+
27
+ def position=(point)
28
+ unless point.respond_to?(:x) && point.respond_to?(:y)
29
+ raise ArgumentError, "expected #{point.inspect}:#{point.class}" +
30
+ " to respond to #x and #y"
31
+ end
32
+
33
+ @bridge.setWindowPosition point.x, point.y
34
+ end
35
+
36
+ def position
37
+ @bridge.getWindowPosition
38
+ end
39
+
40
+ #
41
+ # equivalent to #size=, but accepts width and height arguments
42
+ #
43
+
44
+ def resize_to(width, height)
45
+ @bridge.setWindowSize Integer(width), Integer(height)
46
+ end
47
+
48
+ #
49
+ # equivalent to #position=, but accepts x and y arguments
50
+ #
51
+
52
+ def move_to(x, y)
53
+ @bridge.setWindowPosition Integer(x), Integer(y)
54
+ end
55
+
56
+
57
+ end
58
+ end
59
+ end
@@ -77,6 +77,8 @@ module Selenium
77
77
 
78
78
  #
79
79
  # Set a preference for this particular profile.
80
+ #
81
+ # @see http://kb.mozillazine.org/About:config_entries
80
82
  # @see http://preferential.mozdev.org/preferences.html
81
83
  #
82
84
 
@@ -90,7 +90,7 @@ module Selenium
90
90
 
91
91
  def create_session(desired_capabilities)
92
92
  resp = raw_execute :newSession, {}, :desiredCapabilities => desired_capabilities
93
- @session_id = resp['sessionId'] || raise(Error::WebDriverError, 'no sessionId in returned payload')
93
+ @session_id = resp['sessionId'] or raise Error::WebDriverError, 'no sessionId in returned payload'
94
94
 
95
95
  Capabilities.json_create resp['value']
96
96
  end
@@ -183,6 +183,7 @@ module Selenium
183
183
 
184
184
  def quit
185
185
  execute :quit
186
+ http.close
186
187
  rescue *QUIT_ERRORS
187
188
  end
188
189
 
@@ -202,6 +203,29 @@ module Selenium
202
203
  execute :getCurrentWindowHandle
203
204
  end
204
205
 
206
+ def setWindowSize(width, height, handle = :current)
207
+ execute :setWindowSize, {:window_handle => handle},
208
+ :width => width,
209
+ :height => height
210
+ end
211
+
212
+ def getWindowSize(handle = :current)
213
+ data = execute :getWindowSize, :window_handle => handle
214
+
215
+ Dimension.new data['width'], data['height']
216
+ end
217
+
218
+ def setWindowPosition(x, y, handle = :current)
219
+ execute :setWindowPosition, {:window_handle => handle},
220
+ :x => x, :y => y
221
+ end
222
+
223
+ def getWindowPosition(handle = :current)
224
+ data = execute :getWindowPosition, :window_handle => handle
225
+
226
+ Point.new data['x'], data['y']
227
+ end
228
+
205
229
  def getScreenshot
206
230
  execute :screenshot
207
231
  end
@@ -264,7 +288,7 @@ module Selenium
264
288
  params = { :element => element }
265
289
 
266
290
  if x && y
267
- params.merge!(:xoffset => x, :yoffset => y)
291
+ params.merge! :xoffset => x, :yoffset => y
268
292
  end
269
293
 
270
294
  execute :mouseMoveTo, {}, params
@@ -411,13 +435,13 @@ module Selenium
411
435
  #
412
436
 
413
437
  def raw_execute(command, opts = {}, command_hash = nil)
414
- verb, path = COMMANDS[command] || raise("unknown command #{command.inspect}")
438
+ verb, path = COMMANDS[command] || raise(ArgumentError, "unknown command: #{command.inspect}")
415
439
  path = path.dup
416
440
 
417
441
  path[':session_id'] = @session_id if path.include?(":session_id")
418
442
 
419
443
  begin
420
- opts.each { |key, value| path[key.inspect] = escaper.escape(value.to_s)}
444
+ opts.each { |key, value| path[key.inspect] = escaper.escape(value.to_s) }
421
445
  rescue IndexError
422
446
  raise ArgumentError, "#{opts.inspect} invalid for #{command.inspect}"
423
447
  end
@@ -7,34 +7,86 @@ class Selenium::WebDriver::Remote::Bridge
7
7
 
8
8
  command :newSession, :post, "session"
9
9
  command :getCapabilities, :get, "session/:session_id"
10
- command :quit, :delete, "session/:session_id"
11
- command :setImplicitWaitTimeout, :post, "session/:session_id/timeouts/implicit_wait"
12
- command :setScriptTimeout, :post, "session/:session_id/timeouts/async_script"
13
- command :getCurrentWindowHandle, :get, "session/:session_id/window_handle"
14
- command :getWindowHandles, :get, "session/:session_id/window_handles"
10
+
11
+ #
12
+ # basic driver
13
+ #
14
+
15
15
  command :getCurrentUrl, :get, "session/:session_id/url"
16
16
  command :get, :post, "session/:session_id/url"
17
- command :dismissAlert, :post, "session/:session_id/dismiss_alert"
18
- command :acceptAlert, :post, "session/:session_id/accept_alert"
19
- command :getAlertText, :get, "session/:session_id/alert_text"
20
- command :setAlertValue, :post, "session/:session_id/alert_text"
21
17
  command :goForward, :post, "session/:session_id/forward"
22
18
  command :goBack, :post, "session/:session_id/back"
23
19
  command :refresh, :post, "session/:session_id/refresh"
20
+ command :quit, :delete, "session/:session_id"
21
+ command :close, :delete, "session/:session_id/window"
22
+ command :getVisible, :get, "session/:session_id/visible"
23
+ command :setVisible, :post, "session/:session_id/visible"
24
+ command :getPageSource, :get, "session/:session_id/source"
25
+ command :getTitle, :get, "session/:session_id/title"
26
+ command :findElement, :post, "session/:session_id/element"
27
+ command :findElements, :post, "session/:session_id/elements"
28
+ command :getActiveElement, :post, "session/:session_id/element/active"
29
+
30
+ #
31
+ # window handling
32
+ #
33
+
34
+ command :getCurrentWindowHandle, :get, "session/:session_id/window_handle"
35
+ command :getWindowHandles, :get, "session/:session_id/window_handles"
36
+ command :setWindowSize, :post, "session/:session_id/window/:window_handle/size"
37
+ command :setWindowPosition, :post, "session/:session_id/window/:window_handle/position"
38
+ command :getWindowSize, :get, "session/:session_id/window/:window_handle/size"
39
+ command :getWindowPosition, :get, "session/:session_id/window/:window_handle/position"
40
+
41
+ #
42
+ # script execution
43
+ #
44
+
24
45
  command :executeScript, :post, "session/:session_id/execute"
25
46
  command :executeAsyncScript, :post, "session/:session_id/execute_async"
47
+
48
+ #
49
+ # screenshot
50
+ #
51
+
26
52
  command :screenshot, :get, "session/:session_id/screenshot"
53
+
54
+ #
55
+ # alerts
56
+ #
57
+
58
+ command :dismissAlert, :post, "session/:session_id/dismiss_alert"
59
+ command :acceptAlert, :post, "session/:session_id/accept_alert"
60
+ command :getAlertText, :get, "session/:session_id/alert_text"
61
+ command :setAlertValue, :post, "session/:session_id/alert_text"
62
+
63
+ #
64
+ # target locator
65
+ #
66
+
27
67
  command :switchToFrame, :post, "session/:session_id/frame"
28
68
  command :switchToWindow, :post, "session/:session_id/window"
69
+
70
+ #
71
+ # options
72
+ #
73
+
29
74
  command :getAllCookies, :get, "session/:session_id/cookie"
30
75
  command :addCookie, :post, "session/:session_id/cookie"
31
76
  command :deleteAllCookies, :delete, "session/:session_id/cookie"
32
77
  command :deleteCookieNamed, :delete, "session/:session_id/cookie/:name"
33
- command :getPageSource, :get, "session/:session_id/source"
34
- command :getTitle, :get, "session/:session_id/title"
35
- command :findElement, :post, "session/:session_id/element"
36
- command :findElements, :post, "session/:session_id/elements"
37
- command :getActiveElement, :post, "session/:session_id/element/active"
78
+
79
+ #
80
+ # timeouts
81
+ #
82
+
83
+ command :setImplicitWaitTimeout, :post, "session/:session_id/timeouts/implicit_wait"
84
+ command :setScriptTimeout, :post, "session/:session_id/timeouts/async_script"
85
+
86
+ #
87
+ # element
88
+ #
89
+
38
90
  command :describeElement, :get, "session/:session_id/element/:id"
39
91
  command :findChildElement, :post, "session/:session_id/element/:id/element"
40
92
  command :findChildElements, :post, "session/:session_id/element/:id/elements"
@@ -42,6 +94,7 @@ class Selenium::WebDriver::Remote::Bridge
42
94
  command :submitElement, :post, "session/:session_id/element/:id/submit"
43
95
  command :getElementValue, :get, "session/:session_id/element/:id/value"
44
96
  command :sendKeysToElement, :post, "session/:session_id/element/:id/value"
97
+ command :uploadFile, :post, "session/:session_id/file"
45
98
  command :getElementTagName, :get, "session/:session_id/element/:id/name"
46
99
  command :clearElement, :post, "session/:session_id/element/:id/clear"
47
100
  command :isElementSelected, :get, "session/:session_id/element/:id/selected"
@@ -55,15 +108,19 @@ class Selenium::WebDriver::Remote::Bridge
55
108
  command :getElementSize, :get, "session/:session_id/element/:id/size"
56
109
  command :dragElement, :post, "session/:session_id/element/:id/drag"
57
110
  command :getElementValueOfCssProperty, :get, "session/:session_id/element/:id/css/:property_name"
58
- command :close, :delete, "session/:session_id/window"
59
111
  command :getElementText, :get, "session/:session_id/element/:id/text"
60
- command :getVisible, :get, "session/:session_id/visible"
61
- command :setVisible, :post, "session/:session_id/visible"
112
+
113
+ #
114
+ # rotatable
115
+ #
116
+
62
117
  command :getScreenOrientation, :get, "session/:session_id/orientation"
63
118
  command :setScreenOrientation, :post, "session/:session_id/orientation"
64
- command :uploadFile, :post, "session/:session_id/file"
65
119
 
120
+ #
66
121
  # interactions API
122
+ #
123
+
67
124
  command :click, :post, "session/:session_id/click"
68
125
  command :doubleClick, :post, "session/:session_id/doubleclick"
69
126
  command :mouseDown, :post, "session/:session_id/buttondown"
@@ -72,4 +129,53 @@ class Selenium::WebDriver::Remote::Bridge
72
129
  command :sendModifierKeyToActiveElement, :post, "session/:session_id/modifier"
73
130
  command :sendKeysToActiveElement, :post, "session/:session_id/keys"
74
131
 
132
+ #
133
+ # html 5
134
+ #
135
+
136
+ command :executeSql, :post, "session/:session_id/execute_sql"
137
+ command :getLocation, :get, "session/:session_id/location"
138
+ command :setLocation, :post, "session/:session_id/location"
139
+ command :getAppCache, :get, "session/:session_id/application_cache"
140
+ command :getAppCacheStatus, :get, "session/:session_id/application_cache/status"
141
+ command :clearAppCache, :delete, "session/:session_id/application_cache/clear"
142
+ command :isBrowserOnline, :get, "session/:session_id/browser_connection"
143
+ command :setBrowserOnline, :post, "session/:session_id/browser_connection"
144
+
145
+ command :getLocalStorageItem, :get, "session/:session_id/local_storage/key/:key"
146
+ command :removeLocalStorageItem, :delete, "session/:session_id/local_storage/key/:key"
147
+ command :getLocalStorageKeys, :get, "session/:session_id/local_storage"
148
+ command :setLocalStorageItem, :post, "session/:session_id/local_storage"
149
+ command :clearLocalStorage, :delete, "session/:session_id/local_storage"
150
+ command :getLocalStorageSize, :get, "session/:session_id/local_storage/size"
151
+
152
+ command :getSessionStorageItem, :get, "session/:session_id/session_storage/key/:key"
153
+ command :removeSessionStorageItem, :delete, "session/:session_id/session_storage/key/:key"
154
+ command :getSessionStorageKeys, :get, "session/:session_id/session_storage"
155
+ command :setSessionStorageItem, :post, "session/:session_id/session_storage"
156
+ command :clearSessionStorage, :delete, "session/:session_id/session_storage"
157
+ command :getSessionStorageSize, :get, "session/:session_id/session_storage/size"
158
+
159
+ #
160
+ # ime
161
+ #
162
+
163
+ command :imeGetAvailableEngines, :get, "session/:session_id/ime/available_engines"
164
+ command :imeGetActiveEngine, :get, "session/:session_id/ime/active_engine"
165
+ command :imeIsActivated, :get, "session/:session_id/ime/activated"
166
+ command :imeDeactivate, :post, "session/:session_id/ime/deactivate"
167
+ command :imeActivateEngine, :post, "session/:session_id/ime/activate"
168
+
169
+ #
170
+ # touch
171
+ #
172
+
173
+ command :touchSingleTap, :post, "session/:session_id/touch/click"
174
+ command :touchDoubleTap, :post, "session/:session_id/touch/doubleclick"
175
+ command :touchLongPress, :post, "session/:session_id/touch/longclick"
176
+ command :touchDown, :post, "session/:session_id/touch/down"
177
+ command :touchUp, :post, "session/:session_id/touch/up"
178
+ command :touchMove, :post, "session/:session_id/touch/move"
179
+ command :touchScroll, :post, "session/:session_id/touch/scroll"
180
+ command :touchFlick, :post, "session/:session_id/touch/flick"
75
181
  end
@@ -14,6 +14,10 @@ module Selenium
14
14
  @timeout = nil
15
15
  end
16
16
 
17
+ def close
18
+ # hook for subclasses - will be called on Driver#quit
19
+ end
20
+
17
21
  def call(verb, url, command_hash)
18
22
  url = server_url.merge(url) unless url.kind_of?(URI)
19
23
  headers = DEFAULT_HEADERS.dup
@@ -8,6 +8,10 @@ module Selenium
8
8
  # @api private
9
9
  class Persistent < Default
10
10
 
11
+ def close
12
+ @http.shutdown if @http
13
+ end
14
+
11
15
  private
12
16
 
13
17
  def new_http_client
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: selenium-webdriver
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.10.0
5
+ version: 2.12.0
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: 2011-10-27 00:00:00 -07:00
13
+ date: 2011-11-10 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -52,7 +52,7 @@ dependencies:
52
52
  requirement: &id004 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
- - - "="
55
+ - - ~>
56
56
  - !ruby/object:Gem::Version
57
57
  version: 1.0.9
58
58
  type: :runtime
@@ -161,6 +161,7 @@ files:
161
161
  - lib/selenium/webdriver/common/target_locator.rb
162
162
  - lib/selenium/webdriver/common/timeouts.rb
163
163
  - lib/selenium/webdriver/common/wait.rb
164
+ - lib/selenium/webdriver/common/window.rb
164
165
  - lib/selenium/webdriver/common/zipper.rb
165
166
  - lib/selenium/webdriver/common/core_ext/base64.rb
166
167
  - lib/selenium/webdriver/common/core_ext/dir.rb