bbc-selenium-webdriver 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. data/CHANGES +473 -0
  2. data/README +31 -0
  3. data/lib/selenium-client.rb +2 -0
  4. data/lib/selenium-webdriver.rb +1 -0
  5. data/lib/selenium/client.rb +37 -0
  6. data/lib/selenium/client/base.rb +118 -0
  7. data/lib/selenium/client/driver.rb +10 -0
  8. data/lib/selenium/client/errors.rb +9 -0
  9. data/lib/selenium/client/extensions.rb +118 -0
  10. data/lib/selenium/client/idiomatic.rb +488 -0
  11. data/lib/selenium/client/javascript_expression_builder.rb +116 -0
  12. data/lib/selenium/client/javascript_frameworks/jquery.rb +13 -0
  13. data/lib/selenium/client/javascript_frameworks/prototype.rb +13 -0
  14. data/lib/selenium/client/legacy_driver.rb +1720 -0
  15. data/lib/selenium/client/protocol.rb +104 -0
  16. data/lib/selenium/client/selenium_helper.rb +34 -0
  17. data/lib/selenium/rake/server_task.rb +157 -0
  18. data/lib/selenium/server.rb +223 -0
  19. data/lib/selenium/webdriver.rb +64 -0
  20. data/lib/selenium/webdriver/android.rb +9 -0
  21. data/lib/selenium/webdriver/android/bridge.rb +51 -0
  22. data/lib/selenium/webdriver/chrome.rb +26 -0
  23. data/lib/selenium/webdriver/chrome/bridge.rb +106 -0
  24. data/lib/selenium/webdriver/chrome/profile.rb +83 -0
  25. data/lib/selenium/webdriver/chrome/service.rb +74 -0
  26. data/lib/selenium/webdriver/common.rb +30 -0
  27. data/lib/selenium/webdriver/common/action_builder.rb +352 -0
  28. data/lib/selenium/webdriver/common/alert.rb +26 -0
  29. data/lib/selenium/webdriver/common/bridge_helper.rb +67 -0
  30. data/lib/selenium/webdriver/common/core_ext/base64.rb +9 -0
  31. data/lib/selenium/webdriver/common/core_ext/dir.rb +42 -0
  32. data/lib/selenium/webdriver/common/core_ext/string.rb +5 -0
  33. data/lib/selenium/webdriver/common/driver.rb +301 -0
  34. data/lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb +39 -0
  35. data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +44 -0
  36. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +43 -0
  37. data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +46 -0
  38. data/lib/selenium/webdriver/common/element.rb +262 -0
  39. data/lib/selenium/webdriver/common/error.rb +212 -0
  40. data/lib/selenium/webdriver/common/file_reaper.rb +47 -0
  41. data/lib/selenium/webdriver/common/keyboard.rb +52 -0
  42. data/lib/selenium/webdriver/common/keys.rb +109 -0
  43. data/lib/selenium/webdriver/common/mouse.rb +65 -0
  44. data/lib/selenium/webdriver/common/navigation.rb +43 -0
  45. data/lib/selenium/webdriver/common/options.rb +128 -0
  46. data/lib/selenium/webdriver/common/platform.rb +166 -0
  47. data/lib/selenium/webdriver/common/port_prober.rb +25 -0
  48. data/lib/selenium/webdriver/common/profile_helper.rb +67 -0
  49. data/lib/selenium/webdriver/common/proxy.rb +120 -0
  50. data/lib/selenium/webdriver/common/search_context.rb +92 -0
  51. data/lib/selenium/webdriver/common/socket_poller.rb +100 -0
  52. data/lib/selenium/webdriver/common/target_locator.rb +81 -0
  53. data/lib/selenium/webdriver/common/timeouts.rb +29 -0
  54. data/lib/selenium/webdriver/common/wait.rb +60 -0
  55. data/lib/selenium/webdriver/common/window.rb +96 -0
  56. data/lib/selenium/webdriver/common/zipper.rb +82 -0
  57. data/lib/selenium/webdriver/firefox.rb +37 -0
  58. data/lib/selenium/webdriver/firefox/binary.rb +161 -0
  59. data/lib/selenium/webdriver/firefox/bridge.rb +58 -0
  60. data/lib/selenium/webdriver/firefox/extension.rb +52 -0
  61. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  62. data/lib/selenium/webdriver/firefox/launcher.rb +104 -0
  63. data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
  64. data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
  65. data/lib/selenium/webdriver/firefox/profile.rb +315 -0
  66. data/lib/selenium/webdriver/firefox/profiles_ini.rb +62 -0
  67. data/lib/selenium/webdriver/firefox/socket_lock.rb +61 -0
  68. data/lib/selenium/webdriver/firefox/util.rb +29 -0
  69. data/lib/selenium/webdriver/ie.rb +19 -0
  70. data/lib/selenium/webdriver/ie/bridge.rb +60 -0
  71. data/lib/selenium/webdriver/ie/native/win32/IEDriver.dll +0 -0
  72. data/lib/selenium/webdriver/ie/native/x64/IEDriver.dll +0 -0
  73. data/lib/selenium/webdriver/ie/server.rb +64 -0
  74. data/lib/selenium/webdriver/iphone.rb +9 -0
  75. data/lib/selenium/webdriver/iphone/bridge.rb +50 -0
  76. data/lib/selenium/webdriver/opera.rb +24 -0
  77. data/lib/selenium/webdriver/opera/bridge.rb +113 -0
  78. data/lib/selenium/webdriver/opera/service.rb +49 -0
  79. data/lib/selenium/webdriver/remote.rb +21 -0
  80. data/lib/selenium/webdriver/remote/bridge.rb +473 -0
  81. data/lib/selenium/webdriver/remote/capabilities.rb +241 -0
  82. data/lib/selenium/webdriver/remote/commands.rb +181 -0
  83. data/lib/selenium/webdriver/remote/http/common.rb +74 -0
  84. data/lib/selenium/webdriver/remote/http/curb.rb +79 -0
  85. data/lib/selenium/webdriver/remote/http/default.rb +102 -0
  86. data/lib/selenium/webdriver/remote/http/persistent.rb +38 -0
  87. data/lib/selenium/webdriver/remote/response.rb +99 -0
  88. data/lib/selenium/webdriver/remote/server_error.rb +17 -0
  89. data/lib/selenium/webdriver/support.rb +4 -0
  90. data/lib/selenium/webdriver/support/abstract_event_listener.rb +28 -0
  91. data/lib/selenium/webdriver/support/block_event_listener.rb +17 -0
  92. data/lib/selenium/webdriver/support/event_firing_bridge.rb +112 -0
  93. data/lib/selenium/webdriver/support/select.rb +293 -0
  94. data/spec/integration/selenium/client/api/backward_compatible_api_spec.rb +22 -0
  95. data/spec/integration/selenium/client/api/browser_xpath_library_spec.rb +17 -0
  96. data/spec/integration/selenium/client/api/click_spec.rb +39 -0
  97. data/spec/integration/selenium/client/api/cookie_spec.rb +39 -0
  98. data/spec/integration/selenium/client/api/element_spec.rb +14 -0
  99. data/spec/integration/selenium/client/api/highlight_located_element_spec.rb +19 -0
  100. data/spec/integration/selenium/client/api/retrieve_last_remote_control_logs_spec.rb +33 -0
  101. data/spec/integration/selenium/client/api/screenshot_spec.rb +29 -0
  102. data/spec/integration/selenium/client/api/select_window_spec.rb +46 -0
  103. data/spec/integration/selenium/client/api/start_stop_spec.rb +9 -0
  104. data/spec/integration/selenium/client/api/wait_for_ajax_spec.rb +27 -0
  105. data/spec/integration/selenium/client/api/wait_for_element_spec.rb +56 -0
  106. data/spec/integration/selenium/client/api/wait_for_field_value_spec.rb +52 -0
  107. data/spec/integration/selenium/client/api/wait_for_text_spec.rb +98 -0
  108. data/spec/integration/selenium/client/sample-app/public/jquery-1.3.2.js +4376 -0
  109. data/spec/integration/selenium/client/sample-app/public/jquery.html +55 -0
  110. data/spec/integration/selenium/client/sample-app/public/prototype-1.6.0.3.js +4320 -0
  111. data/spec/integration/selenium/client/sample-app/public/prototype.html +59 -0
  112. data/spec/integration/selenium/client/sample-app/sample_app.rb +32 -0
  113. data/spec/integration/selenium/client/spec_helper.rb +125 -0
  114. data/spec/integration/selenium/webdriver/chrome/driver_spec.rb +28 -0
  115. data/spec/integration/selenium/webdriver/chrome/profile_spec.rb +42 -0
  116. data/spec/integration/selenium/webdriver/driver_spec.rb +253 -0
  117. data/spec/integration/selenium/webdriver/element_spec.rb +185 -0
  118. data/spec/integration/selenium/webdriver/error_spec.rb +30 -0
  119. data/spec/integration/selenium/webdriver/firefox/driver_spec.rb +21 -0
  120. data/spec/integration/selenium/webdriver/firefox/profile_spec.rb +141 -0
  121. data/spec/integration/selenium/webdriver/keyboard_spec.rb +57 -0
  122. data/spec/integration/selenium/webdriver/mouse_spec.rb +55 -0
  123. data/spec/integration/selenium/webdriver/navigation_spec.rb +44 -0
  124. data/spec/integration/selenium/webdriver/opera/driver_spec.rb +47 -0
  125. data/spec/integration/selenium/webdriver/options_spec.rb +49 -0
  126. data/spec/integration/selenium/webdriver/remote/element_spec.rb +24 -0
  127. data/spec/integration/selenium/webdriver/spec_helper.rb +44 -0
  128. data/spec/integration/selenium/webdriver/spec_support.rb +13 -0
  129. data/spec/integration/selenium/webdriver/spec_support/guards.rb +86 -0
  130. data/spec/integration/selenium/webdriver/spec_support/helpers.rb +46 -0
  131. data/spec/integration/selenium/webdriver/spec_support/jruby_test_environment.rb +29 -0
  132. data/spec/integration/selenium/webdriver/spec_support/rack_server.rb +123 -0
  133. data/spec/integration/selenium/webdriver/spec_support/test_environment.rb +199 -0
  134. data/spec/integration/selenium/webdriver/target_locator_spec.rb +170 -0
  135. data/spec/integration/selenium/webdriver/timeout_spec.rb +56 -0
  136. data/spec/integration/selenium/webdriver/window_spec.rb +56 -0
  137. data/spec/integration/selenium/webdriver/zipper_spec.rb +66 -0
  138. data/spec/unit/selenium/client/base_spec.rb +239 -0
  139. data/spec/unit/selenium/client/extensions_spec.rb +174 -0
  140. data/spec/unit/selenium/client/idiomatic_spec.rb +500 -0
  141. data/spec/unit/selenium/client/javascript_expression_builder_spec.rb +79 -0
  142. data/spec/unit/selenium/client/javascript_frameworks/jquery_spec.rb +10 -0
  143. data/spec/unit/selenium/client/javascript_frameworks/prototype_spec.rb +10 -0
  144. data/spec/unit/selenium/client/protocol_spec.rb +124 -0
  145. data/spec/unit/selenium/client/selenium_helper_spec.rb +56 -0
  146. data/spec/unit/selenium/client/spec_helper.rb +24 -0
  147. data/spec/unit/selenium/rake/task_spec.rb +79 -0
  148. data/spec/unit/selenium/server_spec.rb +131 -0
  149. data/spec/unit/selenium/webdriver/action_builder_spec.rb +90 -0
  150. data/spec/unit/selenium/webdriver/android/bridge_spec.rb +31 -0
  151. data/spec/unit/selenium/webdriver/chrome/bridge_spec.rb +94 -0
  152. data/spec/unit/selenium/webdriver/chrome/profile_spec.rb +57 -0
  153. data/spec/unit/selenium/webdriver/chrome/service_spec.rb +44 -0
  154. data/spec/unit/selenium/webdriver/error_spec.rb +41 -0
  155. data/spec/unit/selenium/webdriver/firefox/bridge_spec.rb +17 -0
  156. data/spec/unit/selenium/webdriver/iphone/bridge_spec.rb +30 -0
  157. data/spec/unit/selenium/webdriver/proxy_spec.rb +87 -0
  158. data/spec/unit/selenium/webdriver/remote/bridge_spec.rb +16 -0
  159. data/spec/unit/selenium/webdriver/remote/capabilities_spec.rb +111 -0
  160. data/spec/unit/selenium/webdriver/remote/http/common_spec.rb +24 -0
  161. data/spec/unit/selenium/webdriver/remote/http/default_spec.rb +46 -0
  162. data/spec/unit/selenium/webdriver/search_context_spec.rb +61 -0
  163. data/spec/unit/selenium/webdriver/socket_poller_spec.rb +68 -0
  164. data/spec/unit/selenium/webdriver/spec_helper.rb +6 -0
  165. data/spec/unit/selenium/webdriver/support/event_firing_spec.rb +111 -0
  166. data/spec/unit/selenium/webdriver/support/select_spec.rb +290 -0
  167. data/spec/unit/selenium/webdriver/wait_spec.rb +40 -0
  168. metadata +215 -0
@@ -0,0 +1,46 @@
1
+ module Selenium
2
+ module WebDriver
3
+
4
+ #
5
+ # @api private
6
+ #
7
+
8
+ module DriverExtensions
9
+ module UploadsFiles
10
+
11
+ #
12
+ # Set the file detector to pass local files to a remote WebDriver.
13
+ #
14
+ # The detector is an object that responds to #call, and when called
15
+ # will determine if the given string represents a file. If it does,
16
+ # the path to the file on the local file system should be returned,
17
+ # otherwise nil or false.
18
+ #
19
+ # Example:
20
+ #
21
+ # driver = Selenium::WebDriver.for :remote
22
+ # driver.file_detector = lambda do |args|
23
+ # # args => ["/path/to/file"]
24
+ # str = args.first.to_s
25
+ # str if File.exist?(str)
26
+ # end
27
+ #
28
+ # driver.find_element(:id => "upload").send_keys "/path/to/file"
29
+ #
30
+ # By default, no file detection is performed.
31
+ #
32
+ # @api public
33
+ #
34
+
35
+ def file_detector=(detector)
36
+ unless detector.nil? or detector.respond_to? :call
37
+ raise ArgumentError, "detector must respond to #call"
38
+ end
39
+
40
+ bridge.file_detector = detector
41
+ end
42
+
43
+ end # UploadsFiles
44
+ end # DriverExtensions
45
+ end # WebDriver
46
+ end # Selenium
@@ -0,0 +1,262 @@
1
+ module Selenium
2
+ module WebDriver
3
+ class Element
4
+ include SearchContext
5
+
6
+ #
7
+ # Creates a new Element
8
+ #
9
+ # @api private
10
+ #
11
+
12
+ def initialize(bridge, id)
13
+ @bridge, @id = bridge, id
14
+ end
15
+
16
+ def inspect
17
+ '#<%s:0x%x id=%s>' % [self.class, hash*2, @id.inspect]
18
+ end
19
+
20
+ def ==(other)
21
+ other.kind_of?(self.class) && bridge.elementEquals(self, other)
22
+ end
23
+ alias_method :eql?, :==
24
+
25
+ def hash
26
+ @id.hash ^ @bridge.hash
27
+ end
28
+
29
+ #
30
+ # Click the element
31
+ #
32
+
33
+ def click
34
+ bridge.clickElement @id
35
+ end
36
+
37
+ #
38
+ # Get the tag name of this element
39
+ #
40
+ # @return [String]
41
+ #
42
+
43
+ def tag_name
44
+ bridge.getElementTagName @id
45
+ end
46
+
47
+ #
48
+ # Get the value of a the given attribute of the element. Will return the current value, even if
49
+ # this has been modified after the page has been loaded. More exactly, this method will return
50
+ # the value of the given attribute, unless that attribute is not present, in which case the
51
+ # value of the property with the same name is returned. If neither value is set, nil is
52
+ # returned. The "style" attribute is converted as best can be to a text representation with a
53
+ # trailing semi-colon. The following are deemed to be "boolean" attributes, and will
54
+ # return either "true" or "false":
55
+ #
56
+ # async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked,
57
+ # defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate,
58
+ # iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate,
59
+ # nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, seeking,
60
+ # selected, spellcheck, truespeed, willvalidate
61
+ #
62
+ # Finally, the following commonly mis-capitalized attribute/property names are evaluated as
63
+ # expected:
64
+ #
65
+ # class, readonly
66
+ #
67
+ # @param [String]
68
+ # attribute name
69
+ # @return [String,nil]
70
+ # attribute value
71
+ #
72
+
73
+ def attribute(name)
74
+ bridge.getElementAttribute @id, name
75
+ end
76
+
77
+ #
78
+ # Get the text content of this element
79
+ #
80
+ # @return [String]
81
+ #
82
+
83
+ def text
84
+ bridge.getElementText @id
85
+ end
86
+
87
+ #
88
+ # Send keystrokes to this element
89
+ #
90
+ # @param [String, Symbol, Array]
91
+ #
92
+ # Examples:
93
+ #
94
+ # element.send_keys "foo" #=> value: 'foo'
95
+ # element.send_keys "tet", :arrow_left, "s" #=> value: 'test'
96
+ # element.send_keys [:control, 'a'], :space #=> value: ' '
97
+ #
98
+ # @see Keys::KEYS
99
+ #
100
+
101
+ def send_keys(*args)
102
+ bridge.sendKeysToElement @id, Keys.encode(args)
103
+ end
104
+ alias_method :send_key, :send_keys
105
+
106
+ #
107
+ # Clear this element
108
+ #
109
+
110
+ def clear
111
+ bridge.clearElement @id
112
+ end
113
+
114
+ #
115
+ # Is the element enabled?
116
+ #
117
+ # @return [Boolean]
118
+ #
119
+
120
+ def enabled?
121
+ bridge.isElementEnabled @id
122
+ end
123
+
124
+ #
125
+ # Is the element selected?
126
+ #
127
+ # @return [Boolean]
128
+ #
129
+
130
+ def selected?
131
+ bridge.isElementSelected @id
132
+ end
133
+
134
+ #
135
+ # Is the element displayed?
136
+ #
137
+ # @return [Boolean]
138
+ #
139
+
140
+ def displayed?
141
+ bridge.isElementDisplayed @id
142
+ end
143
+
144
+ #
145
+ # Submit this element
146
+ #
147
+
148
+ def submit
149
+ bridge.submitElement @id
150
+ end
151
+
152
+ #
153
+ # Get the value of the given CSS property
154
+ #
155
+ # Note that shorthand CSS properties (e.g. background, font, border, border-top, margin,
156
+ # margin-top, padding, padding-top, list-style, outline, pause, cue) are not returned,
157
+ # in accordance with the DOM CSS2 specification - you should directly access the longhand
158
+ # properties (e.g. background-color) to access the desired values.
159
+ #
160
+ # @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration
161
+ #
162
+
163
+ def style(prop)
164
+ bridge.getElementValueOfCssProperty @id, prop
165
+ end
166
+
167
+ #
168
+ # Get the location of this element.
169
+ #
170
+ # @return [WebDriver::Point]
171
+ #
172
+
173
+ def location
174
+ bridge.getElementLocation @id
175
+ end
176
+
177
+ #
178
+ # Determine an element's location on the screen once it has been scrolled into view.
179
+ #
180
+ # @return [WebDriver::Point]
181
+ #
182
+
183
+ def location_once_scrolled_into_view
184
+ bridge.getElementLocationOnceScrolledIntoView @id
185
+ end
186
+
187
+ #
188
+ # Get the size of this element
189
+ #
190
+ # @return [WebDriver::Dimension]
191
+ #
192
+
193
+ def size
194
+ bridge.getElementSize @id
195
+ end
196
+
197
+ #-------------------------------- sugar --------------------------------
198
+
199
+ #
200
+ # element.first(:id, 'foo')
201
+ #
202
+
203
+ alias_method :first, :find_element
204
+
205
+ #
206
+ # element.all(:class, 'bar')
207
+ #
208
+
209
+ alias_method :all, :find_elements
210
+
211
+ #
212
+ # element['class'] or element[:class] #=> "someclass"
213
+ #
214
+ alias_method :[], :attribute
215
+
216
+ #
217
+ # for SearchContext and execute_script
218
+ #
219
+ # @api private
220
+ #
221
+
222
+ def ref
223
+ @id
224
+ end
225
+
226
+ #
227
+ # Convert to a WebElement JSON Object for transmission over the wire.
228
+ # @see http://code.google.com/p/selenium/wiki/JsonWireProtocol#Basic_Concepts_And_Terms
229
+ #
230
+ # @api private
231
+ #
232
+
233
+ def to_json(*args)
234
+ MultiJson.encode as_json
235
+ end
236
+
237
+ #
238
+ # For Rails 3 - http://jonathanjulian.com/2010/04/rails-to_json-or-as_json/
239
+ #
240
+ # @api private
241
+ #
242
+
243
+ def as_json(opts = nil)
244
+ { :ELEMENT => @id }
245
+ end
246
+
247
+ private
248
+
249
+ def bridge
250
+ @bridge
251
+ end
252
+
253
+ def selectable?
254
+ tn = tag_name.downcase
255
+ type = attribute(:type).to_s.downcase
256
+
257
+ tn == "option" || (tn == "input" && %w[radio checkbox].include?(type))
258
+ end
259
+
260
+ end # Element
261
+ end # WebDriver
262
+ end # Selenium
@@ -0,0 +1,212 @@
1
+ module Selenium
2
+ module WebDriver
3
+ module Error
4
+
5
+ class WebDriverError < StandardError; end
6
+ class UnsupportedOperationError < WebDriverError; end
7
+
8
+ class IndexOutOfBoundsError < WebDriverError; end # 1
9
+ class NoCollectionError < WebDriverError; end # 2
10
+ class NoStringError < WebDriverError; end # 3
11
+ class NoStringLengthError < WebDriverError; end # 4
12
+ class NoStringWrapperError < WebDriverError; end # 5
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
+
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
+
27
+ class NoSuchFrameError < WebDriverError; end # 8
28
+ class UnknownCommandError < WebDriverError; end # 9
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
+
50
+ class InvalidElementStateError < WebDriverError; end # 12
51
+
52
+ #
53
+ # An unknown server-side error occurred while processing the command.
54
+ #
55
+
56
+ class UnknownError < WebDriverError; end # 13
57
+ class ExpectedError < WebDriverError; end # 14
58
+
59
+ #
60
+ # An attempt was made to select an element that cannot be selected.
61
+ #
62
+
63
+ class ElementNotSelectableError < WebDriverError; end # 15
64
+ class NoSuchDocumentError < WebDriverError; end # 16
65
+
66
+ #
67
+ # An error occurred while executing user supplied JavaScript.
68
+ #
69
+
70
+ class JavascriptError < WebDriverError; end # 17
71
+ class NoScriptResultError < WebDriverError; end # 18
72
+
73
+ #
74
+ # An error occurred while searching for an element by XPath.
75
+ #
76
+
77
+ class XPathLookupError < WebDriverError; end # 19
78
+ class NoSuchCollectionError < WebDriverError; end # 20
79
+
80
+ #
81
+ # Raised when a command does not complete in enough time.
82
+ #
83
+
84
+ class TimeOutError < WebDriverError; end # 21
85
+ class NullPointerError < WebDriverError; end # 22
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
+
93
+ class InvalidCookieDomainError < WebDriverError; end # 24
94
+
95
+ #
96
+ # Raised when a driver fails to set a cookie.
97
+ #
98
+
99
+ class UnableToSetCookieError < WebDriverError; end # 25
100
+ class UnexpectedAlertError < WebDriverError; end # 26
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
+
112
+ class ScriptTimeOutError < WebDriverError; end # 28
113
+
114
+ #
115
+ # The coordinates provided to an interactions operation are invalid.
116
+ #
117
+
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
+
126
+ class IMENotAvailableError < WebDriverError; end # 30
127
+
128
+ #
129
+ # Indicates that activating an IME engine has failed.
130
+ #
131
+
132
+ class IMEEngineActivationFailedError < WebDriverError; end # 31
133
+
134
+ #
135
+ # Argument was an invalid selector (e.g. XPath/CSS).
136
+ #
137
+
138
+ class InvalidSelectorError < WebDriverError; end # 32
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
+
146
+ class MoveTargetOutOfBoundsError < WebDriverError; end # 34
147
+
148
+ # @api private
149
+ Errors = [
150
+ IndexOutOfBoundsError, # 1
151
+ NoCollectionError, # 2
152
+ NoStringError, # 3
153
+ NoStringLengthError, # 4
154
+ NoStringWrapperError, # 5
155
+ NoSuchDriverError, # 6
156
+ NoSuchElementError, # 7
157
+ NoSuchFrameError, # 8
158
+ UnknownCommandError, # 9
159
+ StaleElementReferenceError, # 10
160
+ ElementNotVisibleError, # 11
161
+ InvalidElementStateError, # 12
162
+ UnknownError, # 13
163
+ ExpectedError, # 14
164
+ ElementNotSelectableError, # 15
165
+ NoSuchDocumentError, # 16
166
+ JavascriptError, # 17
167
+ NoScriptResultError, # 18
168
+ XPathLookupError, # 19
169
+ NoSuchCollectionError, # 20
170
+ TimeOutError, # 21
171
+ NullPointerError, # 22
172
+ NoSuchWindowError, # 23
173
+ InvalidCookieDomainError, # 24
174
+ UnableToSetCookieError, # 25
175
+ UnexpectedAlertError, # 26
176
+ NoAlertPresentError, # 27
177
+ ScriptTimeOutError, # 28
178
+ InvalidElementCoordinatesError, # 29
179
+ IMENotAvailableError, # 30
180
+ IMEEngineActivationFailedError, # 31
181
+ InvalidSelectorError, # 32
182
+ nil, # 33
183
+ MoveTargetOutOfBoundsError # 34
184
+ ]
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
+
201
+ class << self
202
+ def for_code(code)
203
+ return if code == 0
204
+ return WebDriverError if code.nil?
205
+
206
+ Errors[code - 1] || WebDriverError
207
+ end
208
+ end
209
+
210
+ end # Error
211
+ end # WebDriver
212
+ end # Selenium