seleniumrc 0.0.1
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.
- data/CHANGES +2 -0
- data/README +0 -0
- data/Rakefile +68 -0
- data/lib/seleniumrc/app_server_checker.rb +43 -0
- data/lib/seleniumrc/dsl/selenium_dsl.rb +186 -0
- data/lib/seleniumrc/dsl/test_unit_dsl.rb +95 -0
- data/lib/seleniumrc/extensions/selenium_driver.rb +33 -0
- data/lib/seleniumrc/extensions/testrunnermediator.rb +19 -0
- data/lib/seleniumrc/mongrel_selenium_server_runner.rb +35 -0
- data/lib/seleniumrc/selenium_configuration.rb +78 -0
- data/lib/seleniumrc/selenium_context.rb +226 -0
- data/lib/seleniumrc/selenium_element.rb +195 -0
- data/lib/seleniumrc/selenium_helper.rb +5 -0
- data/lib/seleniumrc/selenium_page.rb +76 -0
- data/lib/seleniumrc/selenium_server_runner.rb +33 -0
- data/lib/seleniumrc/selenium_test_case.rb +95 -0
- data/lib/seleniumrc/tasks/selenium_test_task.rb +21 -0
- data/lib/seleniumrc/wait_for.rb +47 -0
- data/lib/seleniumrc/webrick_selenium_server_runner.rb +33 -0
- data/lib/seleniumrc.rb +28 -0
- data/spec/seleniumrc/app_server_checker_spec.rb +56 -0
- data/spec/seleniumrc/mongrel_selenium_server_runner_spec.rb +42 -0
- data/spec/seleniumrc/selenese_interpreter_spec.rb +25 -0
- data/spec/seleniumrc/selenium_configuration_spec.rb +21 -0
- data/spec/seleniumrc/selenium_context_spec.rb +362 -0
- data/spec/seleniumrc/selenium_element_spec.rb +530 -0
- data/spec/seleniumrc/selenium_page_spec.rb +226 -0
- data/spec/seleniumrc/selenium_server_runner_spec.rb +42 -0
- data/spec/seleniumrc/selenium_test_case_class_method_spec.rb +41 -0
- data/spec/seleniumrc/selenium_test_case_spec.rb +908 -0
- data/spec/seleniumrc/selenium_test_case_spec_helper.rb +23 -0
- data/spec/seleniumrc/webrick_selenium_server_runner_spec.rb +116 -0
- data/spec/spec_helper.rb +57 -0
- data/spec/spec_suite.rb +4 -0
- metadata +83 -0
@@ -0,0 +1,530 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
module Seleniumrc
|
4
|
+
describe SeleniumElement, :shared => true do
|
5
|
+
include SeleniumTestCaseSpec
|
6
|
+
|
7
|
+
before do
|
8
|
+
@selenium = "Selenium"
|
9
|
+
@element_locator ||= "id=foobar"
|
10
|
+
@element = SeleniumElement.new(@selenium, @element_locator)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe SeleniumElement, "#initialize" do
|
15
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
16
|
+
|
17
|
+
it "sets the locator" do
|
18
|
+
@element.locator.should == @element_locator
|
19
|
+
end
|
20
|
+
|
21
|
+
it "sets the selenium object" do
|
22
|
+
@element.selenium.should == @selenium
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe SeleniumElement, "#is_present" do
|
27
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
28
|
+
|
29
|
+
it "passes when element is present" do
|
30
|
+
ticks = [false, false, false, true]
|
31
|
+
mock(@selenium).is_element_present(@element_locator) do
|
32
|
+
ticks.shift
|
33
|
+
end.times(4)
|
34
|
+
@element.is_present
|
35
|
+
end
|
36
|
+
|
37
|
+
it "fails when element is not present" do
|
38
|
+
stub(@selenium).is_element_present(@element_locator) {false}
|
39
|
+
proc do
|
40
|
+
@element.is_present
|
41
|
+
end.should raise_error("Expected element 'id=foobar' to be present, but it was not (after 5 sec)")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe SeleniumElement, "#is_present?" do
|
46
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
47
|
+
|
48
|
+
it "returns true when element is present" do
|
49
|
+
mock(@selenium).is_element_present(@element_locator) {true}
|
50
|
+
@element.is_present?.should be_true
|
51
|
+
end
|
52
|
+
|
53
|
+
it "returns false when element is not present" do
|
54
|
+
mock(@selenium).is_element_present(@element_locator) {false}
|
55
|
+
@element.is_present?.should be_false
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe SeleniumElement, "#is_not_present" do
|
60
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
61
|
+
|
62
|
+
it "passes when element is not present" do
|
63
|
+
ticks = [true, true, true, false]
|
64
|
+
mock(@selenium).is_element_present(@element_locator) do
|
65
|
+
ticks.shift
|
66
|
+
end.times(4)
|
67
|
+
@element.is_not_present
|
68
|
+
end
|
69
|
+
|
70
|
+
it "fails when element is present" do
|
71
|
+
stub(@selenium).is_element_present(@element_locator) {true}
|
72
|
+
proc do
|
73
|
+
@element.is_not_present
|
74
|
+
end.should raise_error("Expected element 'id=foobar' to be absent, but it was not (after 5 sec)")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe SeleniumElement, "#is_not_present?" do
|
79
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
80
|
+
|
81
|
+
it "returns true when element is not present" do
|
82
|
+
mock(@selenium).is_element_present(@element_locator) {false}
|
83
|
+
@element.is_not_present?.should be_true
|
84
|
+
end
|
85
|
+
|
86
|
+
it "returns false when element is present" do
|
87
|
+
mock(@selenium).is_element_present(@element_locator) {true}
|
88
|
+
@element.is_not_present?.should be_false
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe SeleniumElement, "#has_value" do
|
93
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
94
|
+
|
95
|
+
it "passes when element is present and value is expected value" do
|
96
|
+
element_ticks = [false, false, false, true]
|
97
|
+
mock(@selenium).is_element_present(@element_locator) do
|
98
|
+
element_ticks.shift
|
99
|
+
end.times(4)
|
100
|
+
value_ticks = [nil, nil, nil, "joe"]
|
101
|
+
mock(@selenium).get_value(@element_locator) do
|
102
|
+
value_ticks.shift
|
103
|
+
end.times(4)
|
104
|
+
@element.has_value("joe")
|
105
|
+
end
|
106
|
+
|
107
|
+
it "fails when element is present and not expected value" do
|
108
|
+
mock(@selenium).is_element_present(@element_locator) {true}
|
109
|
+
stub(@selenium).get_value(@element_locator) {"jane"}
|
110
|
+
proc do
|
111
|
+
@element.has_value("joe")
|
112
|
+
end.should raise_error
|
113
|
+
end
|
114
|
+
|
115
|
+
it "fails when element is not present" do
|
116
|
+
stub(@selenium).is_element_present(@element_locator) {false}
|
117
|
+
proc do
|
118
|
+
@element.has_value("joe")
|
119
|
+
end.should raise_error
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe SeleniumElement, "#has_value?" do
|
124
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
125
|
+
|
126
|
+
it "returns true when value is expected value" do
|
127
|
+
mock(@selenium).get_value(@element_locator) {"joe"}
|
128
|
+
@element.has_value?("joe").should be_true
|
129
|
+
end
|
130
|
+
|
131
|
+
it "returns false when value is not expected value" do
|
132
|
+
stub(@selenium).get_value(@element_locator) {"jane"}
|
133
|
+
@element.has_value?("joe").should be_false
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe SeleniumElement, "#has_attribute" do
|
138
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
139
|
+
|
140
|
+
prepend_before do
|
141
|
+
@element_locator = "id=foobar@theattribute"
|
142
|
+
end
|
143
|
+
|
144
|
+
it "passes when element is present and value is expected value" do
|
145
|
+
element_ticks = [false, false, false, true]
|
146
|
+
mock(@selenium).is_element_present(@element_locator) do
|
147
|
+
element_ticks.shift
|
148
|
+
end.times(4)
|
149
|
+
label_ticks = ["jane", "jane", "jane", "joe"]
|
150
|
+
mock(@selenium).get_attribute(@element_locator) do
|
151
|
+
label_ticks.shift
|
152
|
+
end.times(4)
|
153
|
+
@element.has_attribute("joe")
|
154
|
+
end
|
155
|
+
|
156
|
+
it "fails when element is present and value is not expected" do
|
157
|
+
stub(@selenium).is_element_present(@element_locator) {true}
|
158
|
+
stub(@selenium).get_attribute(@element_locator) {"jane"}
|
159
|
+
proc do
|
160
|
+
@element.has_attribute("joe")
|
161
|
+
end.should raise_error
|
162
|
+
end
|
163
|
+
|
164
|
+
it "fails when element is not present" do
|
165
|
+
stub(@selenium).is_element_present(@element_locator) {false}
|
166
|
+
proc do
|
167
|
+
@element.has_attribute("joe")
|
168
|
+
end.should raise_error
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe SeleniumElement, "#has_selected" do
|
173
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
174
|
+
|
175
|
+
prepend_before do
|
176
|
+
@element_locator = "id=foobar"
|
177
|
+
end
|
178
|
+
|
179
|
+
it "passes when element is present and value is expected value" do
|
180
|
+
element_ticks = [false, false, false, true]
|
181
|
+
mock(@selenium).is_element_present(@element_locator) do
|
182
|
+
element_ticks.shift
|
183
|
+
end.times(4)
|
184
|
+
label_ticks = ["jane", "jane", "jane", "joe"]
|
185
|
+
mock(@selenium).get_selected_label(@element_locator) do
|
186
|
+
label_ticks.shift
|
187
|
+
end.times(4)
|
188
|
+
@element.has_selected("joe")
|
189
|
+
end
|
190
|
+
|
191
|
+
it "fails when element is present and value is not expected" do
|
192
|
+
stub(@selenium).is_element_present(@element_locator) {true}
|
193
|
+
stub(@selenium).get_selected_label(@element_locator) {"jane"}
|
194
|
+
proc do
|
195
|
+
@element.has_selected("joe")
|
196
|
+
end.should raise_error
|
197
|
+
end
|
198
|
+
|
199
|
+
it "fails when element is not present" do
|
200
|
+
stub(@selenium).is_element_present(@element_locator) {false}
|
201
|
+
proc do
|
202
|
+
@element.has_selected("joe")
|
203
|
+
end.should raise_error
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
describe SeleniumElement, "#is_visible" do
|
208
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
209
|
+
|
210
|
+
prepend_before do
|
211
|
+
@element_locator = "id=foobar"
|
212
|
+
end
|
213
|
+
|
214
|
+
it "passes when element exists and is visible" do
|
215
|
+
element_ticks = [false, false, false, true]
|
216
|
+
mock(@selenium).is_element_present(@element_locator) do
|
217
|
+
element_ticks.shift
|
218
|
+
end.times(4)
|
219
|
+
visible_ticks = [false, false, false, true]
|
220
|
+
mock(@selenium).is_visible(@element_locator) do
|
221
|
+
visible_ticks.shift
|
222
|
+
end.times(4)
|
223
|
+
@element.is_visible
|
224
|
+
end
|
225
|
+
|
226
|
+
it "fails when element is present and is not visible" do
|
227
|
+
stub(@selenium).is_element_present(@element_locator) {true}
|
228
|
+
stub(@selenium).is_visible(@element_locator) {false}
|
229
|
+
proc do
|
230
|
+
@element.is_visible
|
231
|
+
end.should raise_error
|
232
|
+
end
|
233
|
+
|
234
|
+
it "fails when element is not present" do
|
235
|
+
stub(@selenium).is_element_present(@element_locator) {false}
|
236
|
+
proc do
|
237
|
+
@element.is_visible
|
238
|
+
end.should raise_error
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
describe SeleniumElement, "#is_not_visible" do
|
243
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
244
|
+
|
245
|
+
prepend_before do
|
246
|
+
@element_locator = "id=foobar"
|
247
|
+
end
|
248
|
+
|
249
|
+
it "passes when element exists and is not visible" do
|
250
|
+
element_ticks = [false, false, false, true]
|
251
|
+
mock(@selenium).is_element_present(@element_locator) do
|
252
|
+
element_ticks.shift
|
253
|
+
end.times(4)
|
254
|
+
visible_ticks = [true, true, true, false]
|
255
|
+
mock(@selenium).is_visible(@element_locator) do
|
256
|
+
visible_ticks.shift
|
257
|
+
end.times(4)
|
258
|
+
@element.is_not_visible
|
259
|
+
end
|
260
|
+
|
261
|
+
it "fails when element is present and is visible" do
|
262
|
+
stub(@selenium).is_element_present(@element_locator) {true}
|
263
|
+
stub(@selenium).is__visible(@element_locator) {true}
|
264
|
+
proc do
|
265
|
+
@element.is_not_visible
|
266
|
+
end.should raise_error
|
267
|
+
end
|
268
|
+
|
269
|
+
it "fails when element is not present" do
|
270
|
+
stub(@selenium).is_element_present(@element_locator) {false}
|
271
|
+
proc do
|
272
|
+
@element.is_visible
|
273
|
+
end.should raise_error
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
describe SeleniumElement, "#is_checked" do
|
278
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
279
|
+
|
280
|
+
prepend_before do
|
281
|
+
@element_locator = "id=foobar"
|
282
|
+
end
|
283
|
+
|
284
|
+
it "passes when element is present and value is expected value" do
|
285
|
+
element_ticks = [false, false, false, true]
|
286
|
+
mock(@selenium).is_element_present(@element_locator) do
|
287
|
+
element_ticks.shift
|
288
|
+
end.times(4)
|
289
|
+
checked_ticks = [false, false, false, true]
|
290
|
+
mock(@selenium).is_checked(@element_locator) do
|
291
|
+
checked_ticks.shift
|
292
|
+
end.times(4)
|
293
|
+
@element.is_checked
|
294
|
+
end
|
295
|
+
|
296
|
+
it "fails when element is present and value is not expected" do
|
297
|
+
stub(@selenium).is_element_present(@element_locator) {true}
|
298
|
+
stub(@selenium).is_checked(@element_locator) {false}
|
299
|
+
proc do
|
300
|
+
@element.is_checked
|
301
|
+
end.should raise_error
|
302
|
+
end
|
303
|
+
|
304
|
+
it "fails when element is not present" do
|
305
|
+
stub(@selenium).is_element_present(@element_locator) {false}
|
306
|
+
proc do
|
307
|
+
@element.is_checked
|
308
|
+
end.should raise_error
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
describe SeleniumElement, "#is_not_checked" do
|
313
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
314
|
+
|
315
|
+
prepend_before do
|
316
|
+
@element_locator = "id=foobar"
|
317
|
+
end
|
318
|
+
|
319
|
+
it "passes when element is present and value is expected value" do
|
320
|
+
element_ticks = [false, false, false, true]
|
321
|
+
mock(@selenium).is_element_present(@element_locator) do
|
322
|
+
element_ticks.shift
|
323
|
+
end.times(4)
|
324
|
+
checked_ticks = [true, true, true, false]
|
325
|
+
mock(@selenium).is_checked(@element_locator) do
|
326
|
+
checked_ticks.shift
|
327
|
+
end.times(4)
|
328
|
+
@element.is_not_checked
|
329
|
+
end
|
330
|
+
|
331
|
+
it "fails when element is present and value is not expected" do
|
332
|
+
stub(@selenium).is_element_present(@element_locator) {true}
|
333
|
+
stub(@selenium).is_checked(@element_locator) {true}
|
334
|
+
proc do
|
335
|
+
@element.is_not_checked
|
336
|
+
end.should raise_error
|
337
|
+
end
|
338
|
+
|
339
|
+
it "fails when element is not present" do
|
340
|
+
stub(@selenium).is_element_present(@element_locator) {false}
|
341
|
+
proc do
|
342
|
+
@element.is_not_checked
|
343
|
+
end.should raise_error
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
describe SeleniumElement, "#has_text" do
|
348
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
349
|
+
|
350
|
+
prepend_before do
|
351
|
+
@element_locator = "id=foobar"
|
352
|
+
end
|
353
|
+
|
354
|
+
it "passes when element is present and value is expected value" do
|
355
|
+
element_ticks = [false, false, false, true]
|
356
|
+
mock(@selenium).is_element_present(@element_locator) do
|
357
|
+
element_ticks.shift
|
358
|
+
end.times(4)
|
359
|
+
checked_ticks = ["no match", "no match", "no match", "match"]
|
360
|
+
mock(@selenium).get_text(@element_locator) do
|
361
|
+
checked_ticks.shift
|
362
|
+
end.times(4)
|
363
|
+
@element.has_text("match")
|
364
|
+
end
|
365
|
+
|
366
|
+
it "fails when element is present and value is not expected" do
|
367
|
+
stub(@selenium).is_element_present(@element_locator) {true}
|
368
|
+
stub(@selenium).get_text(@element_locator) {"no match"}
|
369
|
+
proc do
|
370
|
+
@element.has_text "match"
|
371
|
+
end.should raise_error
|
372
|
+
end
|
373
|
+
|
374
|
+
it "fails when element is not present" do
|
375
|
+
stub(@selenium).is_element_present(@element_locator) {false}
|
376
|
+
proc do
|
377
|
+
@element.has_text "match"
|
378
|
+
end.should raise_error
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
describe SeleniumElement, "#contains_text" do
|
383
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
384
|
+
|
385
|
+
prepend_before do
|
386
|
+
@element_locator = "id=foobar"
|
387
|
+
@evaled_js = "this.page().findElement(\"#{@element_locator}\").innerHTML"
|
388
|
+
end
|
389
|
+
|
390
|
+
it "passes when element is present and the element contains text" do
|
391
|
+
element_ticks = [false, false, false, true]
|
392
|
+
mock(@selenium).is_element_present(@element_locator) do
|
393
|
+
element_ticks.shift
|
394
|
+
end.times(4)
|
395
|
+
inner_html_ticks = ["html", "html", "html", "html match html"]
|
396
|
+
mock(@selenium).get_eval(@evaled_js) do
|
397
|
+
inner_html_ticks.shift
|
398
|
+
end.times(4)
|
399
|
+
@element.contains_text("match")
|
400
|
+
end
|
401
|
+
|
402
|
+
it "fails when element is present and the element does not contain text" do
|
403
|
+
stub(@selenium).is_element_present(@element_locator) {true}
|
404
|
+
stub(@selenium).get_eval(@evaled_js) {"html"}
|
405
|
+
proc do
|
406
|
+
@element.contains_text "match"
|
407
|
+
end.should raise_error
|
408
|
+
end
|
409
|
+
|
410
|
+
it "fails when element is not present" do
|
411
|
+
stub(@selenium).is_element_present(@element_locator) {false}
|
412
|
+
proc do
|
413
|
+
@element.contains_text "match"
|
414
|
+
end.should raise_error
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
418
|
+
describe SeleniumElement, "#does_not_contain_text" do
|
419
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
420
|
+
|
421
|
+
prepend_before do
|
422
|
+
@element_locator = "id=foobar"
|
423
|
+
@evaled_js = "this.page().findElement(\"#{@element_locator}\").innerHTML"
|
424
|
+
end
|
425
|
+
|
426
|
+
it "passes when element is present and the element does not contain text" do
|
427
|
+
element_ticks = [false, false, false, true]
|
428
|
+
mock(@selenium).is_element_present(@element_locator) do
|
429
|
+
element_ticks.shift
|
430
|
+
end.times(4)
|
431
|
+
inner_html_ticks = ["html match html", "html match html", "html match html", "html"]
|
432
|
+
mock(@selenium).get_eval(@evaled_js) do
|
433
|
+
inner_html_ticks.shift
|
434
|
+
end.times(4)
|
435
|
+
@element.does_not_contain_text("match")
|
436
|
+
end
|
437
|
+
|
438
|
+
it "fails when element is present and the element contains text" do
|
439
|
+
stub(@selenium).is_element_present(@element_locator) {true}
|
440
|
+
stub(@selenium).get_eval(@evaled_js) {"html match html"}
|
441
|
+
proc do
|
442
|
+
@element.does_not_contain_text "match"
|
443
|
+
end.should raise_error
|
444
|
+
end
|
445
|
+
|
446
|
+
it "fails when element is not present" do
|
447
|
+
stub(@selenium).is_element_present(@element_locator) {false}
|
448
|
+
proc do
|
449
|
+
@element.does_not_contain_text "match"
|
450
|
+
end.should raise_error
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
describe SeleniumElement, "#has_next_sibling" do
|
455
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
456
|
+
|
457
|
+
prepend_before do
|
458
|
+
@element_locator = "id=foobar"
|
459
|
+
@evaled_js = "this.page().findElement('#{@element_locator}').nextSibling.id"
|
460
|
+
end
|
461
|
+
|
462
|
+
it "passes when element is present and value is expected value" do
|
463
|
+
element_ticks = [false, false, false, true]
|
464
|
+
mock(@selenium).is_element_present(@element_locator) do
|
465
|
+
element_ticks.shift
|
466
|
+
end.times(4)
|
467
|
+
inner_html_ticks = ["", "", "", "next_element"]
|
468
|
+
mock(@selenium).get_eval(@evaled_js) do
|
469
|
+
inner_html_ticks.shift
|
470
|
+
end.times(4)
|
471
|
+
@element.has_next_sibling("next_element")
|
472
|
+
end
|
473
|
+
|
474
|
+
it "fails when element is present and value is not expected" do
|
475
|
+
stub(@selenium).is_element_present(@element_locator) {true}
|
476
|
+
stub(@selenium).get_eval(@evaled_js) {""}
|
477
|
+
proc do
|
478
|
+
@element.has_next_sibling "next_element"
|
479
|
+
end.should raise_error
|
480
|
+
end
|
481
|
+
|
482
|
+
it "fails when element is not present" do
|
483
|
+
stub(@selenium).is_element_present(@element_locator) {false}
|
484
|
+
proc do
|
485
|
+
@element.has_next_sibling "match"
|
486
|
+
end.should raise_error
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
490
|
+
describe SeleniumElement, "#has_text_in_order" do
|
491
|
+
it_should_behave_like "Seleniumrc::SeleniumElement"
|
492
|
+
|
493
|
+
prepend_before do
|
494
|
+
@element_locator = "id=foobar"
|
495
|
+
@evaled_js = "this.page().findElement('#{@element_locator}').nextSibling.id"
|
496
|
+
end
|
497
|
+
|
498
|
+
it "passes when element is present and value is expected value" do
|
499
|
+
element_ticks = [false, false, false, true]
|
500
|
+
mock(@selenium).is_element_present(@element_locator) do
|
501
|
+
element_ticks.shift
|
502
|
+
end.times(4)
|
503
|
+
get_text_ticks = [
|
504
|
+
"no match",
|
505
|
+
"no match",
|
506
|
+
"no match",
|
507
|
+
"one\ntwo\nthree",
|
508
|
+
]
|
509
|
+
mock(@selenium).get_text(@element_locator) do
|
510
|
+
get_text_ticks.shift
|
511
|
+
end.times(4)
|
512
|
+
@element.has_text_in_order('one', 'two', 'three')
|
513
|
+
end
|
514
|
+
|
515
|
+
it "fails when element is present and value is not expected" do
|
516
|
+
stub(@selenium).is_element_present(@element_locator) {true}
|
517
|
+
stub(@selenium).get_text(@element_locator) {"no match"}
|
518
|
+
proc do
|
519
|
+
@element.has_text_in_order 'one', 'two', 'three'
|
520
|
+
end.should raise_error
|
521
|
+
end
|
522
|
+
|
523
|
+
it "fails when element is not present" do
|
524
|
+
stub(@selenium).is_element_present(@element_locator) {false}
|
525
|
+
proc do
|
526
|
+
@element.has_text_in_order 'one', 'two', 'three'
|
527
|
+
end.should raise_error
|
528
|
+
end
|
529
|
+
end
|
530
|
+
end
|