bbc-selenium-webdriver 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,293 @@
1
+ module Selenium
2
+ module WebDriver
3
+ module Support
4
+ class Select
5
+
6
+ #
7
+ # @param [Element] element The select element to use
8
+ #
9
+
10
+ def initialize(element)
11
+ tag_name = element.tag_name
12
+
13
+ unless tag_name.downcase == "select"
14
+ raise ArgumentError, "unexpected tag name #{tag_name.inspect}"
15
+ end
16
+
17
+ @element = element
18
+ @multi = ![nil, "false"].include?(element.attribute(:multiple))
19
+ end
20
+
21
+ #
22
+ # Does this select element support selecting multiple options?
23
+ #
24
+ # @return [Boolean]
25
+ #
26
+
27
+ def multiple?
28
+ @multi
29
+ end
30
+
31
+ #
32
+ # Get all options for this select element
33
+ #
34
+ # @return [Array<Element>]
35
+ #
36
+
37
+ def options
38
+ @element.find_elements :tag_name, 'option'
39
+ end
40
+
41
+ #
42
+ # Get all selected options for this select element
43
+ #
44
+ # @return [Array<Element>]
45
+ #
46
+
47
+ def selected_options
48
+ options.select { |e| e.selected? }
49
+ end
50
+
51
+ #
52
+ # Get the first selected option in this select element
53
+ #
54
+ # @raise [Error::NoSuchElementError] if no options are selected
55
+ # @return [Element]
56
+ #
57
+
58
+ def first_selected_option
59
+ option = options.find { |e| e.selected? }
60
+ option or raise Error::NoSuchElementError, 'no options are selected'
61
+ end
62
+
63
+ #
64
+ # Select options by visible text, index or value.
65
+ #
66
+ # When selecting by :text, selects options that display text matching the argument. That is, when given "Bar" this
67
+ # would select an option like:
68
+ #
69
+ # <option value="foo">Bar</option>
70
+ #
71
+ # When slecting by :value, selects all options that have a value matching the argument. That is, when given "foo" this
72
+ # would select an option like:
73
+ #
74
+ # <option value="foo">Bar</option>
75
+ #
76
+ # When selecting by :index, selects the option at the given index. This is done by examining the "index" attribute of an
77
+ # element, and not merely by counting.
78
+ #
79
+ # @param [:text, :index, :value] how How to find the option
80
+ # @param [String] what What value to find the option by.
81
+ #
82
+
83
+ def select_by(how, what)
84
+ case how
85
+ when :text
86
+ select_by_text what
87
+ when :index
88
+ select_by_index what
89
+ when :value
90
+ select_by_value what
91
+ else
92
+ raise ArgumentError, "can't select options by #{how.inspect}"
93
+ end
94
+ end
95
+
96
+ #
97
+ # Deselect options by visible text, index or value.
98
+ #
99
+ # @param [:text, :index, :value] how How to find the option
100
+ # @param [String] what What value to find the option by.
101
+ #
102
+ # @see Select#select_by
103
+ #
104
+
105
+ def deselect_by(how, what)
106
+ case how
107
+ when :text
108
+ deselect_by_text what
109
+ when :value
110
+ deselect_by_value what
111
+ when :index
112
+ deselect_by_index what
113
+ else
114
+ raise ArgumentError, "can't deselect options by #{how.inspect}"
115
+ end
116
+ end
117
+
118
+ #
119
+ # Select all unselected options. Only valid if the element supports multiple selections.
120
+ #
121
+ # @raise [Error::UnsupportedOperationError] if the element does not support multiple selections.
122
+ #
123
+
124
+ def select_all
125
+ unless multiple?
126
+ raise Error::UnsupportedOperationError, 'you may only select all options of a multi-select'
127
+ end
128
+
129
+ options.each { |e| select_option e }
130
+ end
131
+
132
+ #
133
+ # Deselect all selected options. Only valid if the element supports multiple selections.
134
+ #
135
+ # @raise [Error::UnsupportedOperationError] if the element does not support multiple selections.
136
+ #
137
+
138
+ def deselect_all
139
+ unless multiple?
140
+ raise Error::UnsupportedOperationError, 'you may only deselect all options of a multi-select'
141
+ end
142
+
143
+ options.each { |e| deselect_option e }
144
+ end
145
+
146
+ private
147
+
148
+ def select_by_text(text)
149
+ opts = find_by_text text
150
+
151
+ if opts.empty?
152
+ raise Error::NoSuchElementError, "cannot locate element with text: #{text.inspect}"
153
+ end
154
+
155
+ select_options opts
156
+ end
157
+
158
+ def select_by_index(index)
159
+ opts = find_by_index index
160
+
161
+ if opts.empty?
162
+ raise Error::NoSuchElementError, "cannot locate element with index: #{index.inspect}"
163
+ end
164
+
165
+ select_options opts
166
+ end
167
+
168
+ def select_by_value(value)
169
+ opts = find_by_value value
170
+
171
+ if opts.empty?
172
+ raise Error::NoSuchElementError, "cannot locate option with value: #{value.inspect}"
173
+ end
174
+
175
+ select_options opts
176
+ end
177
+
178
+ def deselect_by_text(text)
179
+ opts = find_by_text text
180
+
181
+ if opts.empty?
182
+ raise Error::NoSuchElementError, "cannot locate element with text: #{text.inspect}"
183
+ end
184
+
185
+ deselect_options opts
186
+ end
187
+
188
+ def deselect_by_value(value)
189
+ opts = find_by_value value
190
+
191
+ if opts.empty?
192
+ raise Error::NoSuchElementError, "cannot locate option with value: #{value.inspect}"
193
+ end
194
+
195
+ deselect_options opts
196
+ end
197
+
198
+ def deselect_by_index(index)
199
+ opts = find_by_index index
200
+
201
+ if opts.empty?
202
+ raise Error::NoSuchElementError, "cannot locate option with index: #{index}"
203
+ end
204
+
205
+ deselect_options opts
206
+ end
207
+
208
+ private
209
+
210
+ def select_option(option)
211
+ option.click unless option.selected?
212
+ end
213
+
214
+ def deselect_option(option)
215
+ option.click if option.selected?
216
+ end
217
+
218
+ def select_options(opts)
219
+ if multiple?
220
+ opts.each { |o| select_option o }
221
+ else
222
+ select_option opts.first
223
+ end
224
+ end
225
+
226
+ def deselect_options(opts)
227
+ if multiple?
228
+ opts.each { |o| deselect_option o }
229
+ else
230
+ deselect_option opts.first
231
+ end
232
+ end
233
+
234
+ def find_by_text(text)
235
+ xpath = ".//option[normalize-space(.) = #{Escaper.escape text}]"
236
+ opts = @element.find_elements(:xpath, xpath)
237
+
238
+ if opts.empty? && text =~ /\s+/
239
+ longest_word = text.split(/\s+/).max_by { |item| item.length }
240
+
241
+ if longest_word.empty?
242
+ candidates = options
243
+ else
244
+ xpath = ".//option[contains(., #{Escaper.escape longest_word})]"
245
+ candidates = @element.find_elements(:xpath, xpath)
246
+ end
247
+
248
+ if multiple?
249
+ candidates.select { |option| text == option.text }
250
+ else
251
+ Array(candidates.find { |option| text == option.text })
252
+ end
253
+ else
254
+ opts
255
+ end
256
+ end
257
+
258
+ def find_by_index(index)
259
+ index = index.to_s
260
+ options.select { |option| option.attribute(:index) == index }
261
+ end
262
+
263
+ def find_by_value(value)
264
+ @element.find_elements(:xpath, ".//option[@value = #{Escaper.escape value}]")
265
+ end
266
+
267
+ #
268
+ # @api private
269
+ #
270
+
271
+ module Escaper
272
+ def self.escape(str)
273
+ if str.include?('"') && str.include?("'")
274
+ parts = str.split('"', -1).map { |part| %{"#{part}"} }
275
+
276
+ quoted = parts.join(%{, '"', }).
277
+ gsub(/^"", |, ""$/, '')
278
+
279
+ "concat(#{quoted})"
280
+ elsif str.include?('"')
281
+ # escape string with just a quote into being single quoted: f"oo -> 'f"oo'
282
+ "'#{str}'"
283
+ else
284
+ # otherwise return the quoted string
285
+ %{"#{str}"}
286
+ end
287
+ end
288
+ end # Escaper
289
+
290
+ end # Select
291
+ end
292
+ end
293
+ end
@@ -0,0 +1,22 @@
1
+ require File.expand_path(__FILE__ + '/../../spec_helper')
2
+
3
+ describe "Backward Compatible API" do
4
+ it "provides legacy driver methods" do
5
+ page.open "http://localhost:4444/selenium-server/tests/html/test_click_page1.html"
6
+
7
+ page.get_title.should eql("Click Page 1")
8
+ page.get_text("link").index("Click here for next page").should_not be_nil
9
+
10
+ links = page.get_all_links
11
+ links.length.should > 3
12
+ links[3].should eql("linkToAnchorOnThisPage")
13
+
14
+ page.click "link"
15
+ page.wait_for_page_to_load 5000
16
+ page.get_location.should =~ %r"/selenium-server/tests/html/test_click_page2.html"
17
+
18
+ page.click "previousPage"
19
+ page.wait_for_page_to_load 5000
20
+ page.get_location.should =~ %r"/selenium-server/tests/html/test_click_page1.html"
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ require File.expand_path(__FILE__ + '/../../spec_helper')
2
+
3
+ describe "Browser XPath Library" do
4
+
5
+ it "can be set to default" do
6
+ page.browser_xpath_library = :default
7
+ end
8
+
9
+ it "can be set to ajaxslt" do
10
+ page.browser_xpath_library = :ajaxslt
11
+ end
12
+
13
+ it "can be set to javascript-xpath" do
14
+ page.browser_xpath_library = :'javascript-xpath'
15
+ end
16
+
17
+ end
@@ -0,0 +1,39 @@
1
+ require File.expand_path(__FILE__ + '/../../spec_helper')
2
+
3
+ describe "Click Instrumentation" do
4
+ it "clicks" do
5
+ page.open "http://localhost:4444/selenium-server/tests/html/test_click_page1.html"
6
+ page.text_content("link").should eql("Click here for next page")
7
+
8
+ page.click "link", :wait_for => :page
9
+ page.title.should eql("Click Page Target")
10
+
11
+ page.click "previousPage", :wait_for => :page
12
+ page.title.should eql("Click Page 1")
13
+
14
+ page.click "linkWithEnclosedImage", :wait_for => :page
15
+ page.title.should eql("Click Page Target")
16
+
17
+ page.click "previousPage", :wait_for => :page
18
+ page.click "enclosedImage", :wait_for => :page
19
+ page.title.should eql("Click Page Target")
20
+
21
+ page.click "previousPage", :wait_for => :page
22
+ page.click "extraEnclosedImage", :wait_for => :page
23
+ page.title.should eql("Click Page Target")
24
+
25
+ page.click "previousPage", :wait_for => :page
26
+ page.click "linkToAnchorOnThisPage"
27
+ page.title.should eql("Click Page 1")
28
+
29
+ page.click "linkWithOnclickReturnsFalse"
30
+ page.title.should eql("Click Page 1")
31
+ end
32
+
33
+ it "double clicks" do
34
+ page.open "http://localhost:4444/selenium-server/tests/html/test_click_page1.html"
35
+ page.double_click "doubleClickable"
36
+
37
+ page.get_alert.should eql("double clicked!")
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ require File.expand_path(__FILE__ + '/../../spec_helper')
2
+
3
+ describe "Cookie Handling" do
4
+ it "deletes all cookies" do
5
+ page.open "http://localhost:4444/selenium-server/tests/html/path1/cookie1.html"
6
+ page.delete_all_visible_cookies
7
+
8
+ page.cookies.should be_empty
9
+
10
+ page.open "http://localhost:4444/selenium-server/tests/html/path2/cookie2.html"
11
+ page.delete_all_visible_cookies
12
+
13
+ page.cookies.should be_empty
14
+ end
15
+
16
+ it "can set cookies" do
17
+ page.open "http://localhost:4444/selenium-server/tests/html/path1/cookie1.html"
18
+ page.create_cookie "addedCookieForPath1=new value1"
19
+ page.create_cookie "addedCookieForPath2=new value2", :path => "/selenium-server/tests/html/path2/", :max_age => 60
20
+ page.open "http://localhost:4444/selenium-server/tests/html/path1/cookie1.html"
21
+ page.cookies.should =~ /addedCookieForPath1=new value1/
22
+
23
+ page.cookie?("addedCookieForPath1").should be_true
24
+ page.cookie("addedCookieForPath1").should eql("new value1")
25
+ page.cookie?("testCookie").should be_false
26
+ page.cookie?("addedCookieForPath2").should be_false
27
+
28
+ page.delete_cookie "addedCookieForPath1", "/selenium-server/tests/html/path1/"
29
+ page.cookies.should be_empty
30
+
31
+ page.open "http://localhost:4444/selenium-server/tests/html/path2/cookie2.html"
32
+ page.cookie("addedCookieForPath2").should eql("new value2")
33
+ page.cookie?("addedCookieForPath1").should be_false
34
+
35
+ page.delete_cookie "addedCookieForPath2", "/selenium-server/tests/html/path2/"
36
+ page.delete_cookie "addedCookieForPath2"
37
+ page.cookies.should be_empty
38
+ end
39
+ end
@@ -0,0 +1,14 @@
1
+ require File.expand_path(__FILE__ + '/../../spec_helper')
2
+
3
+ describe "Element API" do
4
+ it "can detect element presence" do
5
+ page.open "http://localhost:4444/selenium-server/tests/html/test_element_present.html"
6
+ page.element?('aLink').should be_true
7
+
8
+ page.click 'removeLinkAfterAWhile', :wait_for => :no_element, :element => "aLink"
9
+ page.element?('aLink').should be_false
10
+
11
+ page.click 'addLinkAfterAWhile', :wait_for => :element, :element => "aLink"
12
+ page.element?('aLink').should be_true
13
+ end
14
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path(__FILE__ + '/../../spec_helper')
2
+
3
+ describe "Highlight Located Element" do
4
+ it "can be enabled and disabled on the fly" do
5
+ page.open "http://localhost:4567/jquery.html"
6
+ page.execution_delay = 1000
7
+ page.highlight_located_element = true
8
+ begin
9
+ page.text("calculator-result").should be_empty
10
+
11
+ page.type "calculator-expression", "2 + 2"
12
+ page.click "calculator-button" , :wait_for => :ajax, :javascript_framework => :jquery
13
+
14
+ page.value("calculator-result").should eql("4")
15
+ ensure
16
+ page.highlight_located_element = false
17
+ end
18
+ end
19
+ end