selenium-webdriver 2.13.0 → 2.14.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,23 @@
1
+ 2.14.0 (???)
2
+ ===================
3
+
4
+ * Add Selenium::WebDriver::Support::Select class to ease working with select lists.
5
+ * Add Capabilities.ipad and Capabilities.iphone (#2895)
6
+ * Replace json_pure dependency with multi_json. (#2901)
7
+ * Don't leave sockets hanging in SYN_SENT state while polling.
8
+ * Allow selecting option elements even if the enclosing select has zero opacity.
9
+ * Exception renames (old names aliased and will still work in rescues):
10
+ * ObsoleteElementError -> StaleElementReferenceError
11
+ * UnhandledError -> UnknownError
12
+ * UnexpectedJavascriptError -> JavascriptError
13
+ * NoAlertOpenError -> NoAlertPresentError
14
+ * ElementNotDisplayedError -> ElementNotVisibleError
15
+ * Firefox:
16
+ * Fixed issue with scrolling on small viewports with native events.
17
+ * Fix CSS selector support in Firefox 3.0
18
+ * IE:
19
+ * Implement the window control API
20
+
1
21
  2.13.0 (2011-11-18)
2
22
  ===================
3
23
 
@@ -3,28 +3,7 @@ require 'tmpdir'
3
3
  require 'fileutils'
4
4
  require 'date'
5
5
 
6
- have_lib = lambda { |lib|
7
- begin
8
- require lib
9
- true
10
- rescue LoadError
11
- false
12
- end
13
- }
14
-
15
- unless have_lib['yajl/json_gem'] || have_lib['json']
16
- raise LoadError, <<-END
17
-
18
- You need to require rubygems or install one of these gems:
19
-
20
- yajl-ruby (best on MRI)
21
- json
22
- json-jruby (native JRuby)
23
- json_pure (any platform)
24
-
25
- END
26
- end
27
-
6
+ require 'multi_json'
28
7
  require 'selenium/webdriver/common'
29
8
 
30
9
  module Selenium
@@ -1,6 +1,11 @@
1
1
  module Selenium
2
2
  module WebDriver
3
3
  module Android
4
+
5
+ #
6
+ # @api private
7
+ #
8
+
4
9
  class Bridge < Remote::Bridge
5
10
 
6
11
  DEFAULT_URL = "http://#{Platform.localhost}:8080/wd/hub/"
@@ -78,6 +78,8 @@ module Selenium
78
78
  caps.merge! 'chrome.nativeEvents' => true if native_events
79
79
  caps.merge! 'chrome.verbose' => true if verbose
80
80
  caps.merge! 'chrome.detach' => detach.nil? || !!detach
81
+
82
+ caps
81
83
  end
82
84
 
83
85
  end # Bridge
@@ -61,7 +61,7 @@ module Selenium
61
61
  prefs_file = prefs_file_for(dir)
62
62
 
63
63
  FileUtils.mkdir_p File.dirname(prefs_file)
64
- File.open(prefs_file, "w") { |file| file << prefs.to_json }
64
+ File.open(prefs_file, "w") { |file| file << MultiJson.encode(prefs) }
65
65
  end
66
66
 
67
67
  def prefs
@@ -70,7 +70,7 @@ module Selenium
70
70
 
71
71
  def read_model_prefs
72
72
  return {} unless @model
73
- JSON.parse File.read(prefs_file_for(@model))
73
+ MultiJson.decode File.read(prefs_file_for(@model))
74
74
  end
75
75
 
76
76
  def prefs_file_for(dir)
@@ -20,6 +20,8 @@ module Selenium
20
20
  #
21
21
  # @see Selenium::WebDriver.for
22
22
  #
23
+ # @return [Driver]
24
+ #
23
25
 
24
26
  def for(browser, opts = {})
25
27
  listener = opts.delete(:listener)
@@ -28,6 +28,8 @@ module Selenium
28
28
  #
29
29
  # By default, no file detection is performed.
30
30
  #
31
+ # @api public
32
+ #
31
33
 
32
34
  def file_detector=(detector)
33
35
  unless detector.nil? or detector.respond_to? :call
@@ -224,7 +224,7 @@ module Selenium
224
224
  #
225
225
 
226
226
  def to_json(*args)
227
- as_json.to_json(*args)
227
+ MultiJson.encode as_json
228
228
  end
229
229
 
230
230
  #
@@ -3,43 +3,149 @@ module Selenium
3
3
  module Error
4
4
 
5
5
  class WebDriverError < StandardError; end
6
+ class UnsupportedOperationError < WebDriverError; end
7
+
6
8
  class IndexOutOfBoundsError < WebDriverError; end # 1
7
9
  class NoCollectionError < WebDriverError; end # 2
8
10
  class NoStringError < WebDriverError; end # 3
9
11
  class NoStringLengthError < WebDriverError; end # 4
10
12
  class NoStringWrapperError < WebDriverError; end # 5
11
13
  class NoSuchDriverError < WebDriverError; end # 6
14
+
15
+ #
16
+ # An element could not be located on the page using the given search
17
+ # parameters.
18
+ #
19
+
12
20
  class NoSuchElementError < WebDriverError; end # 7
21
+
22
+ #
23
+ # A request to switch to a frame could not be satisfied because the
24
+ # frame could not be found.
25
+ #
26
+
13
27
  class NoSuchFrameError < WebDriverError; end # 8
14
28
  class UnknownCommandError < WebDriverError; end # 9
15
- class ObsoleteElementError < WebDriverError; end # 10
16
- class ElementNotDisplayedError < WebDriverError; end # 11
29
+
30
+
31
+ #
32
+ # Indicates that a reference to an element is now "stale" - the element
33
+ # no longer appears in the DOM of the page.
34
+ #
35
+
36
+ class StaleElementReferenceError < WebDriverError; end # 10
37
+
38
+ #
39
+ # Raised to indicate that although an element is present on the DOM,
40
+ # it is not visible, and so is not able to be interacted with.
41
+ #
42
+
43
+ class ElementNotVisibleError < WebDriverError; end # 11
44
+
45
+ #
46
+ # Raised when an interaction could not be performed because the element
47
+ # is in an invalid state (e.g. attempting to click a disabled element).
48
+ #
49
+
17
50
  class InvalidElementStateError < WebDriverError; end # 12
18
- class UnhandledError < WebDriverError; end # 13
51
+
52
+ #
53
+ # An unknown server-side error occurred while processing the command.
54
+ #
55
+
56
+ class UnknownError < WebDriverError; end # 13
19
57
  class ExpectedError < WebDriverError; end # 14
58
+
59
+ #
60
+ # An attempt was made to select an element that cannot be selected.
61
+ #
62
+
20
63
  class ElementNotSelectableError < WebDriverError; end # 15
21
64
  class NoSuchDocumentError < WebDriverError; end # 16
22
- class UnexpectedJavascriptError < WebDriverError; end # 17
65
+
66
+ #
67
+ # An error occurred while executing user supplied JavaScript.
68
+ #
69
+
70
+ class JavascriptError < WebDriverError; end # 17
23
71
  class NoScriptResultError < WebDriverError; end # 18
72
+
73
+ #
74
+ # An error occurred while searching for an element by XPath.
75
+ #
76
+
24
77
  class XPathLookupError < WebDriverError; end # 19
25
78
  class NoSuchCollectionError < WebDriverError; end # 20
79
+
80
+ #
81
+ # Raised when a command does not complete in enough time.
82
+ #
83
+
26
84
  class TimeOutError < WebDriverError; end # 21
27
85
  class NullPointerError < WebDriverError; end # 22
28
86
  class NoSuchWindowError < WebDriverError; end # 23
87
+
88
+ #
89
+ # Raised when attempting to add a cookie under a different domain than
90
+ # the current URL.
91
+ #
92
+
29
93
  class InvalidCookieDomainError < WebDriverError; end # 24
94
+
95
+ #
96
+ # Raised when a driver fails to set a cookie.
97
+ #
98
+
30
99
  class UnableToSetCookieError < WebDriverError; end # 25
31
100
  class UnexpectedAlertError < WebDriverError; end # 26
32
- class NoAlertOpenError < WebDriverError; end # 27
101
+
102
+ #
103
+ # Indicates that a user has tried to access an alert when one is not present.
104
+ #
105
+
106
+ class NoAlertPresentError < WebDriverError; end # 27
107
+
108
+ #
109
+ # A script did not complete before its timeout expired.
110
+ #
111
+
33
112
  class ScriptTimeOutError < WebDriverError; end # 28
113
+
114
+ #
115
+ # The coordinates provided to an interactions operation are invalid.
116
+ #
117
+
34
118
  class InvalidElementCoordinatesError < WebDriverError; end # 29
119
+
120
+ #
121
+ # Indicates that IME support is not available. This exception is rasied
122
+ # for every IME-related method call if IME support is not available on
123
+ # the machine.
124
+ #
125
+
35
126
  class IMENotAvailableError < WebDriverError; end # 30
127
+
128
+ #
129
+ # Indicates that activating an IME engine has failed.
130
+ #
131
+
36
132
  class IMEEngineActivationFailedError < WebDriverError; end # 31
133
+
134
+ #
135
+ # Argument was an invalid selector (e.g. XPath/CSS).
136
+ #
137
+
37
138
  class InvalidSelectorError < WebDriverError; end # 32
38
139
  # 33
140
+
141
+ #
142
+ # Indicates that the target provided to the actions #move method is
143
+ # invalid, e.g. outside of the bounds of the window.
144
+ #
145
+
39
146
  class MoveTargetOutOfBoundsError < WebDriverError; end # 34
40
-
41
- class UnsupportedOperationError < WebDriverError; end
42
147
 
148
+ # @api private
43
149
  Errors = [
44
150
  IndexOutOfBoundsError, # 1
45
151
  NoCollectionError, # 2
@@ -50,14 +156,14 @@ module Selenium
50
156
  NoSuchElementError, # 7
51
157
  NoSuchFrameError, # 8
52
158
  UnknownCommandError, # 9
53
- ObsoleteElementError, # 10
54
- ElementNotDisplayedError, # 11
159
+ StaleElementReferenceError, # 10
160
+ ElementNotVisibleError, # 11
55
161
  InvalidElementStateError, # 12
56
- UnhandledError, # 13
162
+ UnknownError, # 13
57
163
  ExpectedError, # 14
58
164
  ElementNotSelectableError, # 15
59
165
  NoSuchDocumentError, # 16
60
- UnexpectedJavascriptError, # 17
166
+ JavascriptError, # 17
61
167
  NoScriptResultError, # 18
62
168
  XPathLookupError, # 19
63
169
  NoSuchCollectionError, # 20
@@ -67,7 +173,7 @@ module Selenium
67
173
  InvalidCookieDomainError, # 24
68
174
  UnableToSetCookieError, # 25
69
175
  UnexpectedAlertError, # 26
70
- NoAlertOpenError, # 27
176
+ NoAlertPresentError, # 27
71
177
  ScriptTimeOutError, # 28
72
178
  InvalidElementCoordinatesError, # 29
73
179
  IMENotAvailableError, # 30
@@ -77,6 +183,21 @@ module Selenium
77
183
  MoveTargetOutOfBoundsError # 34
78
184
  ]
79
185
 
186
+ # aliased for backwards compatibility
187
+ ObsoleteElementError = StaleElementReferenceError
188
+
189
+ # aliased for backwards compatibility
190
+ UnhandledError = UnknownError
191
+
192
+ # aliased for backwards compatibility
193
+ UnexpectedJavascriptError = JavascriptError
194
+
195
+ # aliased for backwards compatibility
196
+ NoAlertOpenError = NoAlertPresentError
197
+
198
+ # aliased for backwards compatibility
199
+ ElementNotDisplayedError = ElementNotVisibleError
200
+
80
201
  class << self
81
202
  def for_code(code)
82
203
  return if code == 0
@@ -1,5 +1,10 @@
1
1
  module Selenium
2
2
  module WebDriver
3
+
4
+ #
5
+ # @api private
6
+ #
7
+
3
8
  module FileReaper
4
9
 
5
10
  class << self
@@ -30,7 +30,7 @@ module Selenium
30
30
  opts[:path] ||= "/"
31
31
  opts[:secure] ||= false
32
32
 
33
- if obj = opts[:expires]
33
+ if obj = opts.delete(:expires)
34
34
  opts[:expiry] = seconds_from(obj)
35
35
  end
36
36
 
@@ -89,10 +89,10 @@ module Selenium
89
89
  def timeouts
90
90
  @timeouts ||= Timeouts.new(@bridge)
91
91
  end
92
-
92
+
93
93
  #
94
94
  # @api beta This API may be changed or removed in a future release.
95
- #
95
+ #
96
96
 
97
97
  def window
98
98
  @window ||= Window.new(@bridge)
@@ -2,7 +2,7 @@ module Selenium
2
2
  module WebDriver
3
3
 
4
4
  #
5
- # @private
5
+ # @api private
6
6
  #
7
7
  # Common methods for Chrome::Profile and Firefox::Profile
8
8
  # Includers must implement #layout_on_disk
@@ -19,7 +19,7 @@ module Selenium
19
19
  end
20
20
 
21
21
  def to_json(*args)
22
- as_json.to_json(*args)
22
+ MultiJson.encode as_json
23
23
  end
24
24
 
25
25
  private
@@ -46,7 +46,7 @@ module Selenium
46
46
 
47
47
  module ClassMethods
48
48
  def from_json(json)
49
- data = JSON.parse(json).fetch('zip')
49
+ data = MultiJson.decode(json).fetch('zip')
50
50
 
51
51
  # can't use Tempfile here since it doesn't support File::BINARY mode on 1.8
52
52
  # can't use Dir.mktmpdir(&blk) because of http://jira.codehaus.org/browse/JRUBY-4082
@@ -95,6 +95,10 @@ module Selenium
95
95
  json_result if json_result.length > 1
96
96
  end
97
97
 
98
+ def to_json(*args)
99
+ MultiJson.encode as_json
100
+ end
101
+
98
102
  class << self
99
103
  def json_create(data)
100
104
  proxy = new
@@ -2,6 +2,7 @@ module Selenium
2
2
  module WebDriver
3
3
  module SearchContext
4
4
 
5
+ # @api private
5
6
  FINDERS = {
6
7
  :class => 'class name',
7
8
  :class_name => 'class name',
@@ -25,9 +26,9 @@ module Selenium
25
26
  #
26
27
  # @param [:class, :class_name, :css, :id, :link_text, :link, :partial_link_text, :name, :tag_name, :xpath] how
27
28
  # @param [String] what
28
- # @return [WebDriver::Element]
29
+ # @return [Element]
29
30
  #
30
- # @raise [NoSuchElementError] if the element doesn't exist
31
+ # @raise [Error::NoSuchElementError] if the element doesn't exist
31
32
  #
32
33
  #
33
34
 
@@ -48,7 +49,7 @@ module Selenium
48
49
  #
49
50
  # @param [:class, :class_name, :css, :id, :link_text, :link, :partial_link_text, :name, :tag_name, :xpath] how
50
51
  # @param [String] what
51
- # @return [Array<WebDriver::Element>]
52
+ # @return [Array<Element>]
52
53
  #
53
54
 
54
55
  def find_elements(*args)
@@ -74,6 +74,7 @@ module Selenium
74
74
  sock.close
75
75
  true
76
76
  rescue *NOT_CONNECTED_ERRORS
77
+ sock.close if sock
77
78
  $stderr.puts [@host, @port].inspect if $DEBUG
78
79
  false
79
80
  end
@@ -4,6 +4,10 @@ require 'find'
4
4
 
5
5
  module Selenium
6
6
  module WebDriver
7
+ #
8
+ # @api private
9
+ #
10
+
7
11
  module Zipper
8
12
 
9
13
  EXTENSIONS = %w[.zip .xpi]