rsel 0.0.5 → 0.0.6
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/docs/history.md +10 -1
- data/docs/install.md +2 -2
- data/docs/locators.md +10 -9
- data/docs/scoping.md +10 -4
- data/docs/usage.md +2 -2
- data/lib/rsel/exceptions.rb +3 -1
- data/lib/rsel/selenium_test.rb +126 -23
- data/lib/rsel/support.rb +0 -20
- data/rsel.gemspec +1 -1
- data/spec/selenium_test_spec.rb +698 -523
- metadata +4 -4
data/docs/history.md
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
Rsel History
|
|
2
2
|
============
|
|
3
3
|
|
|
4
|
+
0.0.6
|
|
5
|
+
-----
|
|
6
|
+
|
|
7
|
+
- Added stop_on_error attribute to raise a StopTest exception when a step fails
|
|
8
|
+
- Allow execution of arbitrary Selenium::Client::Driver methods
|
|
9
|
+
- Separated support methods from SeleniumTest methods
|
|
10
|
+
- Fixed field_contains and field_equals so they fail when a field doesn't exist
|
|
11
|
+
|
|
12
|
+
|
|
4
13
|
0.0.5
|
|
5
14
|
-----
|
|
6
15
|
|
|
7
16
|
- Allow Selenium-style locators beginning with id=, name=, xpath=, css= etc.
|
|
8
|
-
- Raise a StopTest exception when Selenium is not running
|
|
17
|
+
- Raise a StopTest exception when Selenium is not running
|
|
9
18
|
- Locators are now documented
|
|
10
19
|
- Example FitNesse tables are now included
|
|
11
20
|
|
data/docs/install.md
CHANGED
data/docs/locators.md
CHANGED
|
@@ -11,11 +11,11 @@ their `name` attribute. Given this HTML:
|
|
|
11
11
|
|
|
12
12
|
<a name="contact_us_link" href="/contact">Contact Us</a>
|
|
13
13
|
|
|
14
|
-
To click on the "
|
|
14
|
+
To click on the "Contact Us" link using a standard Selenium locator, you'd have
|
|
15
15
|
to do one of the following:
|
|
16
16
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
17
|
+
| Click | contact_us_link |
|
|
18
|
+
| Click | link=Contact Us |
|
|
19
19
|
|
|
20
20
|
This is easy enough, but what if the target element does not have a `name`
|
|
21
21
|
attribute defined? What if the link is an image instead of a piece of text? In
|
|
@@ -47,7 +47,7 @@ the `alt` text in the case of an image link. Form fields are matched on their
|
|
|
47
47
|
plain-text label, `name` or `id` attribute. In Rsel, the above examples become
|
|
48
48
|
much easier:
|
|
49
49
|
|
|
50
|
-
|
|
|
50
|
+
| Click | Contact Us |
|
|
51
51
|
| Type | Eric | into field | First name |
|
|
52
52
|
|
|
53
53
|
This allows you to use human-readable locator strings for most HTML elements,
|
|
@@ -62,11 +62,12 @@ sense to write:
|
|
|
62
62
|
|
|
63
63
|
| Type | Eric | into field | link=Contact Us |
|
|
64
64
|
|
|
65
|
-
But Rsel won't stop you from trying! One drawback to
|
|
66
|
-
[scoping](scoping.md) clause is ignored. In most cases,
|
|
67
|
-
more readable to use the plain text locator, and rely
|
|
68
|
-
to find the correct element. This feature is only
|
|
69
|
-
the possibility that Rsel's locator scheme is too
|
|
65
|
+
But Rsel won't stop you from trying! One drawback to using explicit Selenium
|
|
66
|
+
locators is that any [scoping](scoping.md) clause is ignored. In most cases,
|
|
67
|
+
it's easier, safer, and more readable to use the plain text locator, and rely
|
|
68
|
+
on Rsel's internal logic to find the correct element. This feature is only
|
|
69
|
+
provided as a workaround for the possibility that Rsel's locator scheme is too
|
|
70
|
+
restrictive for your needs.
|
|
70
71
|
|
|
71
72
|
Next: [Scoping](scoping.md)
|
|
72
73
|
|
data/docs/scoping.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Scoping
|
|
2
2
|
=======
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
Most of Rsel's actions and verifications accept an optional hash of scoping
|
|
5
5
|
keywords, allowing you to be specific about what area of the page to operate
|
|
6
6
|
on. This page describes how to use them.
|
|
7
7
|
|
|
@@ -96,7 +96,13 @@ contain URLs, email addresses, or other auto-interpreted text:
|
|
|
96
96
|
Another important thing to note is that due to the way FitNesse Slim script
|
|
97
97
|
tables are evaluated, the scoping hash must be added after a cell that contains
|
|
98
98
|
part of the method name. Cells in these tables must contain alternating
|
|
99
|
-
(function, argument) chunks
|
|
99
|
+
(function, argument) chunks. To illustrate, consider the phone number example:
|
|
100
|
+
|
|
101
|
+
| Type | 111-222-3333 | into | Phone number | field | !{within:work} |
|
|
102
|
+
|
|
103
|
+
The cells in this row alternate between function and argument, with the first
|
|
104
|
+
cell being the beginning of the function name, and every alternating cell after
|
|
105
|
+
that being a continuation of the function name. Picture it like this:
|
|
100
106
|
|
|
101
107
|
| Type | | into | | field | |
|
|
102
108
|
| | 111-222-3333 | | Phone number | | !{within:work} |
|
|
@@ -107,8 +113,8 @@ call row that does not end with a function-name component, you need to include
|
|
|
107
113
|
a semicolon after the last function-name component, so all remaining cells will
|
|
108
114
|
be treated as arguments. These are valid alternative ways of calling the same function:
|
|
109
115
|
|
|
110
|
-
| Type | 111-222-3333 | into field; | Phone number | !{within:work |
|
|
111
|
-
| Type into field; | 111-222-3333 | Phone number | !{within:work |
|
|
116
|
+
| Type | 111-222-3333 | into field; | Phone number | !{within:work} |
|
|
117
|
+
| Type into field; | 111-222-3333 | Phone number | !{within:work} |
|
|
112
118
|
|
|
113
119
|
The `SeleniumTest` method names were, for the most part, crafted so that the
|
|
114
120
|
alternating (function, argument) form reads the most naturally.
|
data/docs/usage.md
CHANGED
|
@@ -3,8 +3,8 @@ Usage
|
|
|
3
3
|
|
|
4
4
|
Once you have created your `SetUp` page, you can create sibling pages with
|
|
5
5
|
tests in them. For instance, continuing with the example from
|
|
6
|
-
[Installation
|
|
7
|
-
|
|
6
|
+
[Installation](install.md), your `SeleniumTests.LoginTest` might look like
|
|
7
|
+
this:
|
|
8
8
|
|
|
9
9
|
!| script | selenium test | http://www.mysite.com |
|
|
10
10
|
| Open browser |
|
data/lib/rsel/exceptions.rb
CHANGED
data/lib/rsel/selenium_test.rb
CHANGED
|
@@ -46,9 +46,11 @@ module Rsel
|
|
|
46
46
|
:port => port,
|
|
47
47
|
:browser => browser,
|
|
48
48
|
:url => url)
|
|
49
|
+
@stop_on_error = false
|
|
49
50
|
end
|
|
50
51
|
|
|
51
|
-
attr_reader :url, :browser
|
|
52
|
+
attr_reader :url, :browser, :stop_on_error
|
|
53
|
+
attr_writer :stop_on_error
|
|
52
54
|
|
|
53
55
|
|
|
54
56
|
# Start the session and open a browser to the URL defined at the start of
|
|
@@ -57,13 +59,14 @@ module Rsel
|
|
|
57
59
|
# @example
|
|
58
60
|
# | Open browser |
|
|
59
61
|
#
|
|
60
|
-
# @raise [
|
|
62
|
+
# @raise [StopTestCannotConnect] if Selenium connection cannot be made
|
|
61
63
|
#
|
|
62
64
|
def open_browser
|
|
63
65
|
begin
|
|
64
66
|
@browser.start_new_browser_session
|
|
65
67
|
rescue
|
|
66
|
-
raise
|
|
68
|
+
raise StopTestCannotConnect,
|
|
69
|
+
"Cannot connect to Selenium server at #{@browser.host}:#{@browser.port}"
|
|
67
70
|
else
|
|
68
71
|
visit @url
|
|
69
72
|
end
|
|
@@ -144,7 +147,7 @@ module Rsel
|
|
|
144
147
|
# | See | Welcome, Marcus |
|
|
145
148
|
#
|
|
146
149
|
def see(text)
|
|
147
|
-
|
|
150
|
+
pass_if @browser.text?(text)
|
|
148
151
|
end
|
|
149
152
|
|
|
150
153
|
|
|
@@ -157,7 +160,7 @@ module Rsel
|
|
|
157
160
|
# | Do not see | Take a hike |
|
|
158
161
|
#
|
|
159
162
|
def do_not_see(text)
|
|
160
|
-
|
|
163
|
+
pass_if !@browser.text?(text)
|
|
161
164
|
end
|
|
162
165
|
|
|
163
166
|
|
|
@@ -170,7 +173,7 @@ module Rsel
|
|
|
170
173
|
# | See title | Our Homepage |
|
|
171
174
|
#
|
|
172
175
|
def see_title(title)
|
|
173
|
-
|
|
176
|
+
pass_if @browser.get_title == title
|
|
174
177
|
end
|
|
175
178
|
|
|
176
179
|
|
|
@@ -183,7 +186,7 @@ module Rsel
|
|
|
183
186
|
# | Do not see title | Someone else's homepage |
|
|
184
187
|
#
|
|
185
188
|
def do_not_see_title(title)
|
|
186
|
-
|
|
189
|
+
pass_if !(@browser.get_title == title)
|
|
187
190
|
end
|
|
188
191
|
|
|
189
192
|
|
|
@@ -201,7 +204,7 @@ module Rsel
|
|
|
201
204
|
# @since 0.0.2
|
|
202
205
|
#
|
|
203
206
|
def link_exists(locator, scope={})
|
|
204
|
-
|
|
207
|
+
pass_if @browser.element?(loc(locator, 'link', scope))
|
|
205
208
|
end
|
|
206
209
|
|
|
207
210
|
|
|
@@ -219,7 +222,7 @@ module Rsel
|
|
|
219
222
|
# @since 0.0.2
|
|
220
223
|
#
|
|
221
224
|
def button_exists(locator, scope={})
|
|
222
|
-
|
|
225
|
+
pass_if @browser.element?(loc(locator, 'button', scope))
|
|
223
226
|
end
|
|
224
227
|
|
|
225
228
|
|
|
@@ -236,7 +239,7 @@ module Rsel
|
|
|
236
239
|
#
|
|
237
240
|
def row_exists(cells)
|
|
238
241
|
row = XPath.descendant(:tr)[XPath::HTML.table_row(cells.split(/, */))]
|
|
239
|
-
|
|
242
|
+
pass_if @browser.element?("xpath=#{row.to_s}")
|
|
240
243
|
end
|
|
241
244
|
|
|
242
245
|
|
|
@@ -290,7 +293,13 @@ module Rsel
|
|
|
290
293
|
# | Field | First name | contains | Eric |
|
|
291
294
|
#
|
|
292
295
|
def field_contains(locator, text, scope={})
|
|
293
|
-
|
|
296
|
+
begin
|
|
297
|
+
field = @browser.field(loc(locator, 'field', scope))
|
|
298
|
+
rescue => e
|
|
299
|
+
failure e.message
|
|
300
|
+
else
|
|
301
|
+
pass_if field.include?(text)
|
|
302
|
+
end
|
|
294
303
|
end
|
|
295
304
|
|
|
296
305
|
|
|
@@ -307,7 +316,13 @@ module Rsel
|
|
|
307
316
|
# | Field | First name | equals; | Eric | !{within:contact} |
|
|
308
317
|
#
|
|
309
318
|
def field_equals(locator, text, scope={})
|
|
310
|
-
|
|
319
|
+
begin
|
|
320
|
+
field = @browser.field(loc(locator, 'field', scope))
|
|
321
|
+
rescue => e
|
|
322
|
+
failure e.message
|
|
323
|
+
else
|
|
324
|
+
pass_if field == text
|
|
325
|
+
end
|
|
311
326
|
end
|
|
312
327
|
|
|
313
328
|
|
|
@@ -425,8 +440,8 @@ module Rsel
|
|
|
425
440
|
xp = loc(locator, 'checkbox', scope)
|
|
426
441
|
begin
|
|
427
442
|
enabled = @browser.checked?(xp)
|
|
428
|
-
rescue
|
|
429
|
-
|
|
443
|
+
rescue => e
|
|
444
|
+
failure e.message
|
|
430
445
|
else
|
|
431
446
|
return enabled
|
|
432
447
|
end
|
|
@@ -450,8 +465,8 @@ module Rsel
|
|
|
450
465
|
xp = loc(locator, 'radio_button', scope)
|
|
451
466
|
begin
|
|
452
467
|
enabled = @browser.checked?(xp)
|
|
453
|
-
rescue
|
|
454
|
-
|
|
468
|
+
rescue => e
|
|
469
|
+
failure e.message
|
|
455
470
|
else
|
|
456
471
|
return enabled
|
|
457
472
|
end
|
|
@@ -473,8 +488,8 @@ module Rsel
|
|
|
473
488
|
xp = loc(locator, 'checkbox', scope)
|
|
474
489
|
begin
|
|
475
490
|
enabled = @browser.checked?(xp)
|
|
476
|
-
rescue
|
|
477
|
-
|
|
491
|
+
rescue => e
|
|
492
|
+
failure e.message
|
|
478
493
|
else
|
|
479
494
|
return !enabled
|
|
480
495
|
end
|
|
@@ -498,8 +513,8 @@ module Rsel
|
|
|
498
513
|
xp = loc(locator, 'radio_button', scope)
|
|
499
514
|
begin
|
|
500
515
|
enabled = @browser.checked?(xp)
|
|
501
|
-
rescue
|
|
502
|
-
|
|
516
|
+
rescue => e
|
|
517
|
+
failure e.message
|
|
503
518
|
else
|
|
504
519
|
return !enabled
|
|
505
520
|
end
|
|
@@ -559,7 +574,7 @@ module Rsel
|
|
|
559
574
|
dropdown = XPath::HTML.select(locator)
|
|
560
575
|
opt = dropdown[XPath::HTML.option(option)]
|
|
561
576
|
opt_str = opt.to_s
|
|
562
|
-
|
|
577
|
+
pass_if @browser.element?("xpath=#{opt_str}")
|
|
563
578
|
end
|
|
564
579
|
|
|
565
580
|
|
|
@@ -578,8 +593,8 @@ module Rsel
|
|
|
578
593
|
def dropdown_equals(locator, option, scope={})
|
|
579
594
|
begin
|
|
580
595
|
selected = @browser.get_selected_label(loc(locator, 'select', scope))
|
|
581
|
-
rescue
|
|
582
|
-
|
|
596
|
+
rescue => e
|
|
597
|
+
failure e.message
|
|
583
598
|
else
|
|
584
599
|
return selected == option
|
|
585
600
|
end
|
|
@@ -616,6 +631,94 @@ module Rsel
|
|
|
616
631
|
end
|
|
617
632
|
end
|
|
618
633
|
|
|
634
|
+
|
|
635
|
+
# Execute the given block, and return false if it raises an exception.
|
|
636
|
+
# Otherwise, return true. If `@stop_on_error` is true, raise a
|
|
637
|
+
# `StopTestStepFailed` exception instead of returning false.
|
|
638
|
+
#
|
|
639
|
+
# @example
|
|
640
|
+
# return_error_status do
|
|
641
|
+
# # some code that might raise an exception
|
|
642
|
+
# end
|
|
643
|
+
#
|
|
644
|
+
def return_error_status
|
|
645
|
+
begin
|
|
646
|
+
yield
|
|
647
|
+
rescue => e
|
|
648
|
+
#puts e.message
|
|
649
|
+
#puts e.backtrace
|
|
650
|
+
failure e.message
|
|
651
|
+
else
|
|
652
|
+
return true
|
|
653
|
+
end
|
|
654
|
+
end
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
# Invoke a missing method. If a method is called on a SeleniumTest
|
|
658
|
+
# instance, and that method is not explicitly defined, this method
|
|
659
|
+
# will check to see whether the underlying Selenium::Client::Driver
|
|
660
|
+
# instance can respond to that method. If so, that method is called
|
|
661
|
+
# instead.
|
|
662
|
+
#
|
|
663
|
+
# @since 0.0.6
|
|
664
|
+
#
|
|
665
|
+
def method_missing(method, *args, &block)
|
|
666
|
+
if @browser.respond_to?(method)
|
|
667
|
+
@browser.send(method, *args, &block)
|
|
668
|
+
else
|
|
669
|
+
super
|
|
670
|
+
end
|
|
671
|
+
end
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
# Return true if SeleniumTest explicitly responds to a given method
|
|
675
|
+
# name, or if the underlying Selenium::Client::Driver instance can
|
|
676
|
+
# respond to it. This is a counterpart to {#method_missing}, used
|
|
677
|
+
# for checking whether a given method can be called on this instance.
|
|
678
|
+
#
|
|
679
|
+
# @since 0.0.6
|
|
680
|
+
#
|
|
681
|
+
def respond_to?(method, include_private=false)
|
|
682
|
+
if @browser.respond_to?(method)
|
|
683
|
+
true
|
|
684
|
+
else
|
|
685
|
+
super
|
|
686
|
+
end
|
|
687
|
+
end
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
# Indicate a failure by returning `false` or raising an exception.
|
|
691
|
+
# If `@stop_on_error` is true, raise a `StopTestStepFailed` exception.
|
|
692
|
+
# Otherwise, simply return false.
|
|
693
|
+
#
|
|
694
|
+
# @param [String] message
|
|
695
|
+
# Optional message to include in the exception.
|
|
696
|
+
# Ignored if `@stop_on_error` is false.
|
|
697
|
+
#
|
|
698
|
+
# @since 0.0.6
|
|
699
|
+
#
|
|
700
|
+
def failure(message='')
|
|
701
|
+
if @stop_on_error
|
|
702
|
+
raise StopTestStepFailed, message
|
|
703
|
+
else
|
|
704
|
+
return false
|
|
705
|
+
end
|
|
706
|
+
end
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
# Pass if the given condition is true; otherwise, fail by calling
|
|
710
|
+
# {#failure} with an optional `message`.
|
|
711
|
+
#
|
|
712
|
+
# @since 0.0.6
|
|
713
|
+
#
|
|
714
|
+
def pass_if(condition, message='')
|
|
715
|
+
if condition
|
|
716
|
+
return true
|
|
717
|
+
else
|
|
718
|
+
failure message
|
|
719
|
+
end
|
|
720
|
+
end
|
|
721
|
+
|
|
619
722
|
end
|
|
620
723
|
end
|
|
621
724
|
|
data/lib/rsel/support.rb
CHANGED
|
@@ -6,26 +6,6 @@ module Rsel
|
|
|
6
6
|
# Support functions for Rsel
|
|
7
7
|
module Support
|
|
8
8
|
|
|
9
|
-
# Execute the given block, and return false if it raises an exception.
|
|
10
|
-
# Otherwise, return true.
|
|
11
|
-
#
|
|
12
|
-
# @example
|
|
13
|
-
# return_error_status do
|
|
14
|
-
# # some code that might raise an exception
|
|
15
|
-
# end
|
|
16
|
-
#
|
|
17
|
-
def return_error_status
|
|
18
|
-
begin
|
|
19
|
-
yield
|
|
20
|
-
rescue => e
|
|
21
|
-
#puts e.message
|
|
22
|
-
#puts e.backtrace
|
|
23
|
-
return false
|
|
24
|
-
else
|
|
25
|
-
return true
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
9
|
# Convert the given locator to a format accepted by Selenium. If `locator`
|
|
30
10
|
# starts with `id=`, `name=`, `dom=`, `xpath=` `link=` or `css=`, then the
|
|
31
11
|
# locator is returned unchanged. Otherwise, `locator` is assumed to be a
|
data/rsel.gemspec
CHANGED
data/spec/selenium_test_spec.rb
CHANGED
|
@@ -23,796 +23,818 @@ describe Rsel::SeleniumTest do
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
context "
|
|
26
|
+
context "navigation" do
|
|
27
27
|
before(:each) do
|
|
28
|
-
@st.visit("/
|
|
28
|
+
@st.visit("/").should be_true
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
describe "#
|
|
31
|
+
describe "#visit" do
|
|
32
32
|
context "passes when" do
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
@st.enable_checkbox("I like cheese").should be_true
|
|
36
|
-
@st.enable_checkbox("I like salami").should be_true
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "exists within scope" do
|
|
40
|
-
@st.enable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
|
41
|
-
@st.enable_checkbox("I like salami", :within => "salami_checkbox").should be_true
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it "exists in table row" do
|
|
45
|
-
@st.visit("/table")
|
|
46
|
-
@st.enable_checkbox("Like", :in_row => "Marcus").should be_true
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
context "checkbox with id=" do
|
|
51
|
-
it "exists" do
|
|
52
|
-
@st.enable_checkbox("id=like_cheese").should be_true
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
context "checkbox with xpath=" do
|
|
57
|
-
it "exists" do
|
|
58
|
-
@st.enable_checkbox("xpath=//input[@id='like_cheese']").should be_true
|
|
59
|
-
end
|
|
33
|
+
it "page exists" do
|
|
34
|
+
@st.visit("/about").should be_true
|
|
60
35
|
end
|
|
61
36
|
end
|
|
62
37
|
|
|
63
38
|
context "fails when" do
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
@st.enable_checkbox("I dislike bacon").should be_false
|
|
67
|
-
@st.enable_checkbox("I like broccoli").should be_false
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it "exists, but not within scope" do
|
|
71
|
-
@st.enable_checkbox("I like cheese", :within => "salami_checkbox").should be_false
|
|
72
|
-
@st.enable_checkbox("I like salami", :within => "cheese_checkbox").should be_false
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it "exists, but not in table row" do
|
|
76
|
-
@st.visit("/table")
|
|
77
|
-
@st.enable_checkbox("Like", :in_row => "Eric").should be_false
|
|
78
|
-
end
|
|
39
|
+
it "page does not exist" do
|
|
40
|
+
@st.visit("/bad/path").should be_false
|
|
79
41
|
end
|
|
80
42
|
end
|
|
81
43
|
end
|
|
82
44
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
it "exists" do
|
|
87
|
-
@st.disable_checkbox("I like cheese").should be_true
|
|
88
|
-
@st.disable_checkbox("I like salami").should be_true
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it "exists within scope" do
|
|
92
|
-
@st.disable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
|
93
|
-
@st.disable_checkbox("I like salami", :within => "preferences_form").should be_true
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
it "exists in table row" do
|
|
97
|
-
@st.visit("/table")
|
|
98
|
-
@st.disable_checkbox("Like", :in_row => "Marcus").should be_true
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
context "checkbox with id=" do
|
|
103
|
-
it "exists" do
|
|
104
|
-
@st.disable_checkbox("id=like_cheese").should be_true
|
|
105
|
-
end
|
|
106
|
-
end
|
|
45
|
+
context "reload the current page" do
|
|
46
|
+
# TODO
|
|
47
|
+
end
|
|
107
48
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
49
|
+
describe "#click_back" do
|
|
50
|
+
it "passes and loads the correct URL" do
|
|
51
|
+
@st.visit("/about")
|
|
52
|
+
@st.visit("/")
|
|
53
|
+
@st.click_back.should be_true
|
|
54
|
+
@st.see_title("About this site").should be_true
|
|
113
55
|
end
|
|
114
56
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
57
|
+
#it "fails when there is no previous page in the history" do
|
|
58
|
+
# TODO: No obvious way to test this, since everything is running in the
|
|
59
|
+
# same session
|
|
60
|
+
#end
|
|
61
|
+
end
|
|
62
|
+
end # navigation
|
|
121
63
|
|
|
122
|
-
it "exists, but not within scope" do
|
|
123
|
-
@st.disable_checkbox("I like cheese", :within => "salami_checkbox").should be_false
|
|
124
|
-
@st.disable_checkbox("I like salami", :within => "cheese_checkbox").should be_false
|
|
125
|
-
end
|
|
126
64
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
end
|
|
131
|
-
end
|
|
132
|
-
end
|
|
65
|
+
context "visibility" do
|
|
66
|
+
before(:each) do
|
|
67
|
+
@st.visit("/").should be_true
|
|
133
68
|
end
|
|
134
69
|
|
|
135
|
-
describe "#
|
|
70
|
+
describe "#see" do
|
|
136
71
|
context "passes when" do
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
@st.checkbox_is_enabled("I like cheese").should be_true
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
it "exists within scope and is checked" do
|
|
144
|
-
@st.enable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
|
145
|
-
@st.checkbox_is_enabled("I like cheese", :within => "cheese_checkbox").should be_true
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
it "exists in table row and is checked" do
|
|
149
|
-
@st.visit("/table")
|
|
150
|
-
@st.enable_checkbox("Like", :in_row => "Ken").should be_true
|
|
151
|
-
@st.checkbox_is_enabled("Like", :in_row => "Ken").should be_true
|
|
152
|
-
end
|
|
72
|
+
it "text is present" do
|
|
73
|
+
@st.see("Welcome").should be_true
|
|
74
|
+
@st.see("This is a Sinatra webapp").should be_true
|
|
153
75
|
end
|
|
154
76
|
end
|
|
155
77
|
|
|
156
78
|
context "fails when" do
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
it "exists but is unchecked" do
|
|
163
|
-
@st.disable_checkbox("I like cheese").should be_true
|
|
164
|
-
@st.checkbox_is_enabled("I like cheese").should be_false
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
it "exists and is checked, but not within scope" do
|
|
168
|
-
@st.enable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
|
169
|
-
@st.checkbox_is_enabled("I like cheese", :within => "salami_checkbox").should be_false
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
it "exists and is checked, but not in table row" do
|
|
173
|
-
@st.visit("/table")
|
|
174
|
-
@st.enable_checkbox("Like", :in_row => "Marcus").should be_true
|
|
175
|
-
@st.checkbox_is_enabled("Like", :in_row => "Eric").should be_false
|
|
176
|
-
end
|
|
79
|
+
it "text is absent" do
|
|
80
|
+
@st.see("Nonexistent").should be_false
|
|
81
|
+
@st.see("Some bogus text").should be_false
|
|
177
82
|
end
|
|
178
83
|
end
|
|
84
|
+
|
|
85
|
+
it "is case-sensitive" do
|
|
86
|
+
@st.see("Sinatra webapp").should be_true
|
|
87
|
+
@st.see("sinatra Webapp").should be_false
|
|
88
|
+
end
|
|
179
89
|
end
|
|
180
90
|
|
|
181
|
-
describe "#
|
|
91
|
+
describe "#do_not_see" do
|
|
182
92
|
context "passes when" do
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
@st.checkbox_is_disabled("I like cheese").should be_true
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
it "exists within scope and is unchecked" do
|
|
190
|
-
@st.disable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
|
191
|
-
@st.checkbox_is_disabled("I like cheese", :within => "cheese_checkbox").should be_true
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
it "exists in table row and is unchecked" do
|
|
195
|
-
@st.visit("/table")
|
|
196
|
-
@st.disable_checkbox("Like", :in_row => "Ken").should be_true
|
|
197
|
-
@st.checkbox_is_disabled("Like", :in_row => "Ken").should be_true
|
|
198
|
-
end
|
|
93
|
+
it "text is absent" do
|
|
94
|
+
@st.do_not_see("Nonexistent").should be_true
|
|
95
|
+
@st.do_not_see("Some bogus text").should be_true
|
|
199
96
|
end
|
|
200
97
|
end
|
|
201
98
|
|
|
202
99
|
context "fails when" do
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
it "exists but is checked" do
|
|
209
|
-
@st.enable_checkbox("I like cheese").should be_true
|
|
210
|
-
@st.checkbox_is_disabled("I like cheese").should be_false
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
it "exists and is unchecked, but not within scope" do
|
|
214
|
-
@st.disable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
|
215
|
-
@st.checkbox_is_disabled("I like cheese", :within => "salami_checkbox").should be_false
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
it "exists and is unchecked, but not in table row" do
|
|
219
|
-
@st.visit("/table")
|
|
220
|
-
@st.disable_checkbox("Like", :in_row => "Marcus").should be_true
|
|
221
|
-
@st.checkbox_is_disabled("Like", :in_row => "Eric").should be_false
|
|
222
|
-
end
|
|
100
|
+
it "fails when test is present" do
|
|
101
|
+
@st.do_not_see("Welcome").should be_false
|
|
102
|
+
@st.do_not_see("This is a Sinatra webapp").should be_false
|
|
223
103
|
end
|
|
224
104
|
end
|
|
105
|
+
|
|
106
|
+
it "is case-sensitive" do
|
|
107
|
+
@st.do_not_see("Sinatra webapp").should be_false
|
|
108
|
+
@st.do_not_see("sinatra Webapp").should be_true
|
|
109
|
+
end
|
|
225
110
|
end
|
|
226
|
-
end
|
|
111
|
+
end # visibility
|
|
227
112
|
|
|
228
113
|
|
|
229
|
-
context "
|
|
114
|
+
context "links" do
|
|
230
115
|
before(:each) do
|
|
231
|
-
@st.visit("/
|
|
116
|
+
@st.visit("/").should be_true
|
|
232
117
|
end
|
|
233
118
|
|
|
234
|
-
|
|
119
|
+
describe "#click" do
|
|
235
120
|
context "passes when" do
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
@st.select_radio("Briefs").should be_true
|
|
239
|
-
end
|
|
240
|
-
|
|
241
|
-
it "exists within scope" do
|
|
242
|
-
@st.select_radio("Briefs", :within => "clothing").should be_true
|
|
243
|
-
end
|
|
244
|
-
|
|
245
|
-
it "exists in table row" do
|
|
246
|
-
# TODO
|
|
247
|
-
end
|
|
121
|
+
it "link exists" do
|
|
122
|
+
@st.click("About this site").should be_true
|
|
248
123
|
end
|
|
249
124
|
end
|
|
250
125
|
|
|
251
126
|
context "fails when" do
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
@st.select_radio("Naked").should be_false
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
it "exists, but not within scope" do
|
|
258
|
-
@st.select_radio("Briefs", :within => "food").should be_false
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
it "exists, but not in table row" do
|
|
262
|
-
# TODO
|
|
263
|
-
end
|
|
127
|
+
it "link does not exist" do
|
|
128
|
+
@st.click("Bogus link").should be_false
|
|
264
129
|
end
|
|
265
130
|
end
|
|
266
131
|
end
|
|
267
132
|
|
|
268
|
-
|
|
133
|
+
describe "#click_link" do
|
|
269
134
|
context "passes when" do
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
@st.radio_is_enabled("Briefs").should be_true
|
|
274
|
-
end
|
|
135
|
+
it "link exists" do
|
|
136
|
+
@st.click_link("About this site").should be_true
|
|
137
|
+
end
|
|
275
138
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
end
|
|
139
|
+
it "link exists within scope" do
|
|
140
|
+
@st.click_link("About this site", :within => "header").should be_true
|
|
141
|
+
end
|
|
280
142
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
143
|
+
it "link exists in table row" do
|
|
144
|
+
@st.visit("/table")
|
|
145
|
+
@st.click_link("Edit", :in_row => "Marcus").should be_true
|
|
146
|
+
@st.see_title("Editing Marcus").should be_true
|
|
284
147
|
end
|
|
285
148
|
end
|
|
286
149
|
|
|
287
150
|
context "fails when" do
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
end
|
|
151
|
+
it "link does not exist" do
|
|
152
|
+
@st.click_link("Bogus link").should be_false
|
|
153
|
+
end
|
|
292
154
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
end
|
|
155
|
+
it "link exists, but not within scope" do
|
|
156
|
+
@st.click_link("About this site", :within => "footer").should be_false
|
|
157
|
+
end
|
|
297
158
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
end
|
|
159
|
+
it "link exists, but not in table row" do
|
|
160
|
+
@st.visit("/table")
|
|
161
|
+
@st.click_link("Edit", :in_row => "Ken").should be_false
|
|
302
162
|
end
|
|
303
163
|
end
|
|
304
164
|
end
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
context "dropdowns" do
|
|
309
|
-
before(:each) do
|
|
310
|
-
@st.visit("/form").should be_true
|
|
311
|
-
end
|
|
312
165
|
|
|
313
|
-
|
|
166
|
+
describe "#link_exists" do
|
|
314
167
|
context "passes when" do
|
|
315
|
-
it "
|
|
316
|
-
@st.
|
|
317
|
-
@st.
|
|
318
|
-
end
|
|
319
|
-
|
|
320
|
-
it "option exists in the dropdown within scope" do
|
|
321
|
-
@st.select_from_dropdown("Tall", "Height", :within => "spouse_form").should be_true
|
|
168
|
+
it "link with the given text exists" do
|
|
169
|
+
@st.link_exists("About this site").should be_true
|
|
170
|
+
@st.link_exists("Form test").should be_true
|
|
322
171
|
end
|
|
323
172
|
|
|
324
|
-
it "
|
|
325
|
-
@st.
|
|
326
|
-
@st.
|
|
173
|
+
it "link with the given text exists within scope" do
|
|
174
|
+
@st.link_exists("About this site", :within => "header").should be_true
|
|
175
|
+
@st.link_exists("Form test", :within => "footer").should be_true
|
|
176
|
+
@st.link_exists("Table test", :within => "footer").should be_true
|
|
327
177
|
end
|
|
328
178
|
end
|
|
329
179
|
|
|
330
180
|
context "fails when" do
|
|
331
|
-
it "no such
|
|
332
|
-
@st.
|
|
181
|
+
it "no such link exists" do
|
|
182
|
+
@st.link_exists("Welcome").should be_false
|
|
183
|
+
@st.link_exists("Don't click here").should be_false
|
|
333
184
|
end
|
|
334
185
|
|
|
335
|
-
it "
|
|
336
|
-
@st.
|
|
337
|
-
@st.
|
|
186
|
+
it "link exists, but not within scope" do
|
|
187
|
+
@st.link_exists("About this site", :within => "footer").should be_false
|
|
188
|
+
@st.link_exists("Form test", :within => "header").should be_false
|
|
189
|
+
@st.link_exists("Table test", :within => "header").should be_false
|
|
338
190
|
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end # links
|
|
339
194
|
|
|
340
|
-
|
|
341
|
-
|
|
195
|
+
|
|
196
|
+
context "buttons" do
|
|
197
|
+
before(:each) do
|
|
198
|
+
@st.visit("/form").should be_true
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
describe "#click_button" do
|
|
202
|
+
context "passes when" do
|
|
203
|
+
it "button exists and is enabled" do
|
|
204
|
+
@st.click_button("Submit person form").should be_true
|
|
342
205
|
end
|
|
343
206
|
|
|
344
|
-
it "
|
|
345
|
-
@st.
|
|
346
|
-
@st.select_from_dropdown("Female", "Gender", :in_row => "First name").should be_false
|
|
207
|
+
it "button exists within scope" do
|
|
208
|
+
@st.click_button("Submit person form", :within => "person_form").should be_true
|
|
347
209
|
end
|
|
348
|
-
end
|
|
349
|
-
end
|
|
350
210
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
it "option exists in the dropdown" do
|
|
354
|
-
@st.dropdown_includes("Height", "Tall").should be_true
|
|
355
|
-
@st.dropdown_includes("Weight", "Medium").should be_true
|
|
211
|
+
it "button exists in table row" do
|
|
212
|
+
# TODO
|
|
356
213
|
end
|
|
357
214
|
end
|
|
358
215
|
|
|
359
216
|
context "fails when" do
|
|
360
|
-
it "
|
|
361
|
-
@st.
|
|
362
|
-
@st.dropdown_includes("Weight", "Obese").should be_false
|
|
217
|
+
it "button does not exist" do
|
|
218
|
+
@st.click_button("No such button").should be_false
|
|
363
219
|
end
|
|
364
220
|
|
|
365
|
-
it "
|
|
366
|
-
@st.
|
|
221
|
+
it "button exists, but not within scope" do
|
|
222
|
+
@st.click_button("Submit person form", :within => "spouse_form").should be_false
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
it "button exists, but not in table row" do
|
|
226
|
+
# TODO
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
it "button exists, but is disabled" do
|
|
230
|
+
# TODO
|
|
367
231
|
end
|
|
368
232
|
end
|
|
369
233
|
end
|
|
370
234
|
|
|
371
|
-
|
|
235
|
+
|
|
236
|
+
describe "#button_exists" do
|
|
372
237
|
context "passes when" do
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
@st.
|
|
376
|
-
@st.
|
|
238
|
+
context "button with text" do
|
|
239
|
+
it "exists" do
|
|
240
|
+
@st.button_exists("Submit person form").should be_true
|
|
241
|
+
@st.button_exists("Save preferences").should be_true
|
|
377
242
|
end
|
|
378
|
-
end
|
|
379
243
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
@st.
|
|
383
|
-
@st.dropdown_equals("Height", height, :within => "spouse_form").should be_true
|
|
244
|
+
it "exists within scope" do
|
|
245
|
+
@st.button_exists("Submit person form", :within => "person_form").should be_true
|
|
246
|
+
@st.button_exists("Submit spouse form", :within => "spouse_form").should be_true
|
|
384
247
|
end
|
|
385
|
-
end
|
|
386
248
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
["Male", "Female"].each do |gender|
|
|
390
|
-
@st.select_from_dropdown(gender, "Gender", :in_row => "Eric")
|
|
391
|
-
@st.dropdown_equals("Gender", gender, :in_row => "Eric")
|
|
249
|
+
it "exists in table row" do
|
|
250
|
+
# TODO
|
|
392
251
|
end
|
|
393
252
|
end
|
|
394
253
|
end
|
|
395
254
|
|
|
396
255
|
context "fails when" do
|
|
397
|
-
it "no such
|
|
398
|
-
@st.
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
it "dropdown exists, but the option is not selected" do
|
|
402
|
-
@st.select_from_dropdown("Short", "Height")
|
|
403
|
-
@st.dropdown_equals("Height", "Average").should be_false
|
|
404
|
-
@st.dropdown_equals("Height", "Tall").should be_false
|
|
405
|
-
|
|
406
|
-
@st.select_from_dropdown("Average", "Height")
|
|
407
|
-
@st.dropdown_equals("Height", "Short").should be_false
|
|
408
|
-
@st.dropdown_equals("Height", "Tall").should be_false
|
|
409
|
-
|
|
410
|
-
@st.select_from_dropdown("Tall", "Height")
|
|
411
|
-
@st.dropdown_equals("Height", "Short").should be_false
|
|
412
|
-
@st.dropdown_equals("Height", "Average").should be_false
|
|
256
|
+
it "no such button exists" do
|
|
257
|
+
@st.button_exists("Apple").should be_false
|
|
258
|
+
@st.button_exists("Big Red").should be_false
|
|
413
259
|
end
|
|
414
260
|
|
|
415
|
-
it "
|
|
416
|
-
@st.
|
|
417
|
-
@st.
|
|
418
|
-
@st.dropdown_equals("Height", "Tall", :within => "spouse_form").should be_false
|
|
261
|
+
it "button exists, but not within scope" do
|
|
262
|
+
@st.button_exists("Submit spouse form", :within => "person_form").should be_false
|
|
263
|
+
@st.button_exists("Submit person form", :within => "spouse_form").should be_false
|
|
419
264
|
end
|
|
420
265
|
|
|
421
|
-
it "
|
|
422
|
-
|
|
423
|
-
@st.select_from_dropdown("Female", "Gender", :in_row => "Eric")
|
|
424
|
-
@st.select_from_dropdown("Male", "Gender", :in_row => "Marcus")
|
|
425
|
-
@st.dropdown_equals("Gender", "Female", :in_row => "Marcus").should be_false
|
|
266
|
+
it "button exists, but not in table row" do
|
|
267
|
+
# TODO
|
|
426
268
|
end
|
|
427
269
|
end
|
|
428
270
|
end
|
|
429
|
-
end
|
|
271
|
+
end # buttons
|
|
430
272
|
|
|
431
273
|
|
|
432
|
-
context "
|
|
274
|
+
context "fields" do
|
|
433
275
|
before(:each) do
|
|
434
|
-
@st.visit("/").should be_true
|
|
276
|
+
@st.visit("/form").should be_true
|
|
435
277
|
end
|
|
436
278
|
|
|
437
|
-
describe "#
|
|
279
|
+
describe "#type_into_field" do
|
|
438
280
|
context "passes when" do
|
|
439
|
-
|
|
440
|
-
|
|
281
|
+
context "text field with label" do
|
|
282
|
+
it "exists" do
|
|
283
|
+
@st.type_into_field("Eric", "First name").should be_true
|
|
284
|
+
@st.fill_in_with("Last name", "Pierce").should be_true
|
|
285
|
+
end
|
|
286
|
+
it "exists within scope" do
|
|
287
|
+
@st.type_into_field("Eric", "First name", :within => 'person_form').should be_true
|
|
288
|
+
@st.type_into_field("Andrea", "First name", :within => 'spouse_form').should be_true
|
|
289
|
+
end
|
|
441
290
|
end
|
|
442
|
-
end
|
|
443
291
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
292
|
+
context "text field with id" do
|
|
293
|
+
it "exists" do
|
|
294
|
+
@st.type_into_field("Eric", "first_name").should be_true
|
|
295
|
+
@st.fill_in_with("last_name", "Pierce").should be_true
|
|
296
|
+
end
|
|
447
297
|
end
|
|
448
|
-
end
|
|
449
|
-
end
|
|
450
298
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
299
|
+
context "textarea with label" do
|
|
300
|
+
it "exists" do
|
|
301
|
+
@st.type_into_field("Blah blah blah", "Life story").should be_true
|
|
302
|
+
@st.fill_in_with("Life story", "Jibber jabber").should be_true
|
|
303
|
+
end
|
|
304
|
+
end
|
|
454
305
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
306
|
+
context "textarea with id" do
|
|
307
|
+
it "exists" do
|
|
308
|
+
@st.type_into_field("Blah blah blah", "biography").should be_true
|
|
309
|
+
@st.fill_in_with("biography", "Jibber jabber").should be_true
|
|
310
|
+
end
|
|
311
|
+
end
|
|
461
312
|
end
|
|
462
313
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
end
|
|
469
|
-
|
|
314
|
+
context "fails when" do
|
|
315
|
+
it "no field with the given label or id exists" do
|
|
316
|
+
@st.type_into_field("Matthew", "Middle name").should be_false
|
|
317
|
+
@st.fill_in_with("middle_name", "Matthew").should be_false
|
|
318
|
+
end
|
|
470
319
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
320
|
+
it "field exists, but not within scope" do
|
|
321
|
+
@st.type_into_field("Long story", "Life story",
|
|
322
|
+
:within => 'spouse_form').should be_false
|
|
323
|
+
end
|
|
324
|
+
end
|
|
474
325
|
end
|
|
475
326
|
|
|
476
|
-
describe "#
|
|
327
|
+
describe "#field_contains" do
|
|
477
328
|
context "passes when" do
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
329
|
+
context "text field with label" do
|
|
330
|
+
it "equals the text" do
|
|
331
|
+
@st.fill_in_with("First name", "Marcus")
|
|
332
|
+
@st.field_contains("First name", "Marcus").should be_true
|
|
333
|
+
end
|
|
481
334
|
|
|
482
|
-
|
|
483
|
-
|
|
335
|
+
it "contains the text" do
|
|
336
|
+
@st.fill_in_with("First name", "Marcus")
|
|
337
|
+
@st.field_contains("First name", "Marc").should be_true
|
|
338
|
+
end
|
|
484
339
|
end
|
|
485
340
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
341
|
+
context "textarea with label" do
|
|
342
|
+
it "contains the text" do
|
|
343
|
+
@st.fill_in_with("Life story", "Blah dee blah")
|
|
344
|
+
@st.field_contains("Life story", "blah").should be_true
|
|
345
|
+
end
|
|
490
346
|
end
|
|
491
347
|
end
|
|
492
348
|
|
|
493
349
|
context "fails when" do
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
350
|
+
context "text field with label" do
|
|
351
|
+
it "does not exist" do
|
|
352
|
+
@st.field_contains("Third name", "Smith").should be_false
|
|
353
|
+
end
|
|
497
354
|
|
|
498
|
-
|
|
499
|
-
|
|
355
|
+
it "does not contain the text" do
|
|
356
|
+
@st.fill_in_with("First name", "Marcus")
|
|
357
|
+
@st.field_contains("First name", "Eric").should be_false
|
|
358
|
+
end
|
|
500
359
|
end
|
|
501
360
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
361
|
+
context "textarea with label" do
|
|
362
|
+
it "does not contain the text" do
|
|
363
|
+
@st.fill_in_with("Life story", "Blah dee blah")
|
|
364
|
+
@st.field_contains("Life story", "spam").should be_false
|
|
365
|
+
end
|
|
505
366
|
end
|
|
506
367
|
end
|
|
507
368
|
end
|
|
508
369
|
|
|
509
|
-
describe "#
|
|
370
|
+
describe "#field_equals" do
|
|
510
371
|
context "passes when" do
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
372
|
+
context "text field with label" do
|
|
373
|
+
it "equals the text" do
|
|
374
|
+
@st.fill_in_with("First name", "Ken")
|
|
375
|
+
@st.field_equals("First name", "Ken").should be_true
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
it "equals the text, and is within scope" do
|
|
379
|
+
@st.fill_in_with("First name", "Eric", :within => "person_form")
|
|
380
|
+
@st.field_equals("First name", "Eric", :within => "person_form")
|
|
381
|
+
end
|
|
514
382
|
end
|
|
515
383
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
384
|
+
context "textarea with label" do
|
|
385
|
+
it "equals the text" do
|
|
386
|
+
@st.fill_in_with("Life story", "Blah dee blah")
|
|
387
|
+
@st.field_equals("Life story", "Blah dee blah").should be_true
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
it "equals the text, and is within scope" do
|
|
391
|
+
@st.fill_in_with("Life story", "Blah dee blah",
|
|
392
|
+
:within => "person_form")
|
|
393
|
+
@st.field_equals("Life story", "Blah dee blah",
|
|
394
|
+
:within => "person_form").should be_true
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
it "equals the text, and is in table row" do
|
|
398
|
+
# TODO
|
|
399
|
+
end
|
|
520
400
|
end
|
|
521
401
|
end
|
|
522
402
|
|
|
523
403
|
context "fails when" do
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
404
|
+
context "text field with label" do
|
|
405
|
+
it "does not exactly equal the text" do
|
|
406
|
+
@st.fill_in_with("First name", "Marcus")
|
|
407
|
+
@st.field_equals("First name", "Marc").should be_false
|
|
408
|
+
end
|
|
527
409
|
end
|
|
528
410
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
411
|
+
context "textarea with label" do
|
|
412
|
+
it "does not exist" do
|
|
413
|
+
@st.field_equals("Third name", "Smith").should be_false
|
|
414
|
+
end
|
|
415
|
+
|
|
416
|
+
it "does not exactly equal the text" do
|
|
417
|
+
@st.fill_in_with("Life story", "Blah dee blah")
|
|
418
|
+
@st.field_equals("Life story", "Blah dee").should be_false
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
it "exactly equals the text, but is not within scope" do
|
|
422
|
+
# TODO
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
it "exactly equals the text, but is not in table row" do
|
|
426
|
+
# TODO
|
|
427
|
+
end
|
|
533
428
|
end
|
|
534
429
|
end
|
|
535
430
|
end
|
|
536
|
-
end
|
|
431
|
+
end # fields
|
|
537
432
|
|
|
538
433
|
|
|
539
|
-
context "
|
|
434
|
+
context "checkboxes" do
|
|
540
435
|
before(:each) do
|
|
541
436
|
@st.visit("/form").should be_true
|
|
542
437
|
end
|
|
543
438
|
|
|
544
|
-
describe "#
|
|
439
|
+
describe "#enable_checkbox" do
|
|
545
440
|
context "passes when" do
|
|
546
|
-
|
|
547
|
-
|
|
441
|
+
context "checkbox with label" do
|
|
442
|
+
it "exists" do
|
|
443
|
+
@st.enable_checkbox("I like cheese").should be_true
|
|
444
|
+
@st.enable_checkbox("I like salami").should be_true
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
it "exists within scope" do
|
|
448
|
+
@st.enable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
|
449
|
+
@st.enable_checkbox("I like salami", :within => "salami_checkbox").should be_true
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
it "exists in table row" do
|
|
453
|
+
@st.visit("/table")
|
|
454
|
+
@st.enable_checkbox("Like", :in_row => "Marcus").should be_true
|
|
455
|
+
end
|
|
548
456
|
end
|
|
549
457
|
|
|
550
|
-
|
|
551
|
-
|
|
458
|
+
context "checkbox with id=" do
|
|
459
|
+
it "exists" do
|
|
460
|
+
@st.enable_checkbox("id=like_cheese").should be_true
|
|
461
|
+
end
|
|
552
462
|
end
|
|
553
463
|
|
|
554
|
-
|
|
555
|
-
|
|
464
|
+
context "checkbox with xpath=" do
|
|
465
|
+
it "exists" do
|
|
466
|
+
@st.enable_checkbox("xpath=//input[@id='like_cheese']").should be_true
|
|
467
|
+
end
|
|
556
468
|
end
|
|
557
469
|
end
|
|
558
470
|
|
|
559
471
|
context "fails when" do
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
@st.click_button("Submit person form", :within => "spouse_form").should be_false
|
|
566
|
-
end
|
|
472
|
+
context "checkbox with label" do
|
|
473
|
+
it "does not exist" do
|
|
474
|
+
@st.enable_checkbox("I dislike bacon").should be_false
|
|
475
|
+
@st.enable_checkbox("I like broccoli").should be_false
|
|
476
|
+
end
|
|
567
477
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
478
|
+
it "exists, but not within scope" do
|
|
479
|
+
@st.enable_checkbox("I like cheese", :within => "salami_checkbox").should be_false
|
|
480
|
+
@st.enable_checkbox("I like salami", :within => "cheese_checkbox").should be_false
|
|
481
|
+
end
|
|
571
482
|
|
|
572
|
-
|
|
573
|
-
|
|
483
|
+
it "exists, but not in table row" do
|
|
484
|
+
@st.visit("/table")
|
|
485
|
+
@st.enable_checkbox("Like", :in_row => "Eric").should be_false
|
|
486
|
+
end
|
|
574
487
|
end
|
|
575
488
|
end
|
|
576
489
|
end
|
|
577
490
|
|
|
578
|
-
|
|
579
|
-
describe "#button_exists" do
|
|
491
|
+
describe "#disable_checkbox" do
|
|
580
492
|
context "passes when" do
|
|
581
|
-
context "
|
|
493
|
+
context "checkbox with label" do
|
|
582
494
|
it "exists" do
|
|
583
|
-
@st.
|
|
584
|
-
@st.
|
|
495
|
+
@st.disable_checkbox("I like cheese").should be_true
|
|
496
|
+
@st.disable_checkbox("I like salami").should be_true
|
|
585
497
|
end
|
|
586
498
|
|
|
587
499
|
it "exists within scope" do
|
|
588
|
-
@st.
|
|
589
|
-
@st.
|
|
500
|
+
@st.disable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
|
501
|
+
@st.disable_checkbox("I like salami", :within => "preferences_form").should be_true
|
|
590
502
|
end
|
|
591
503
|
|
|
592
504
|
it "exists in table row" do
|
|
593
|
-
|
|
505
|
+
@st.visit("/table")
|
|
506
|
+
@st.disable_checkbox("Like", :in_row => "Marcus").should be_true
|
|
594
507
|
end
|
|
595
508
|
end
|
|
596
|
-
end
|
|
597
|
-
|
|
598
|
-
context "fails when" do
|
|
599
|
-
it "no such button exists" do
|
|
600
|
-
@st.button_exists("Apple").should be_false
|
|
601
|
-
@st.button_exists("Big Red").should be_false
|
|
602
|
-
end
|
|
603
509
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
510
|
+
context "checkbox with id=" do
|
|
511
|
+
it "exists" do
|
|
512
|
+
@st.disable_checkbox("id=like_cheese").should be_true
|
|
513
|
+
end
|
|
607
514
|
end
|
|
608
515
|
|
|
609
|
-
|
|
610
|
-
|
|
516
|
+
context "checkbox with xpath=" do
|
|
517
|
+
it "exists" do
|
|
518
|
+
@st.disable_checkbox("xpath=//input[@id='like_cheese']").should be_true
|
|
519
|
+
end
|
|
611
520
|
end
|
|
612
521
|
end
|
|
613
|
-
end
|
|
614
|
-
end
|
|
615
522
|
|
|
523
|
+
context "fails when" do
|
|
524
|
+
context "checkbox with label" do
|
|
525
|
+
it "does not exist" do
|
|
526
|
+
@st.disable_checkbox("I dislike bacon").should be_false
|
|
527
|
+
@st.disable_checkbox("I like broccoli").should be_false
|
|
528
|
+
end
|
|
529
|
+
|
|
530
|
+
it "exists, but not within scope" do
|
|
531
|
+
@st.disable_checkbox("I like cheese", :within => "salami_checkbox").should be_false
|
|
532
|
+
@st.disable_checkbox("I like salami", :within => "cheese_checkbox").should be_false
|
|
533
|
+
end
|
|
616
534
|
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
535
|
+
it "exists, but not in table row" do
|
|
536
|
+
@st.visit("/table")
|
|
537
|
+
@st.disable_checkbox("Like", :in_row => "Eric").should be_false
|
|
538
|
+
end
|
|
539
|
+
end
|
|
540
|
+
end
|
|
620
541
|
end
|
|
621
542
|
|
|
622
|
-
describe "#
|
|
543
|
+
describe "#checkbox_is_enabled" do
|
|
623
544
|
context "passes when" do
|
|
624
|
-
context "
|
|
625
|
-
it "exists" do
|
|
626
|
-
@st.
|
|
627
|
-
@st.
|
|
545
|
+
context "checkbox with label" do
|
|
546
|
+
it "exists and is checked" do
|
|
547
|
+
@st.enable_checkbox("I like cheese").should be_true
|
|
548
|
+
@st.checkbox_is_enabled("I like cheese").should be_true
|
|
628
549
|
end
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
@st.
|
|
550
|
+
|
|
551
|
+
it "exists within scope and is checked" do
|
|
552
|
+
@st.enable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
|
553
|
+
@st.checkbox_is_enabled("I like cheese", :within => "cheese_checkbox").should be_true
|
|
632
554
|
end
|
|
633
|
-
end
|
|
634
555
|
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
@st.
|
|
638
|
-
@st.
|
|
556
|
+
it "exists in table row and is checked" do
|
|
557
|
+
@st.visit("/table")
|
|
558
|
+
@st.enable_checkbox("Like", :in_row => "Ken").should be_true
|
|
559
|
+
@st.checkbox_is_enabled("Like", :in_row => "Ken").should be_true
|
|
639
560
|
end
|
|
640
561
|
end
|
|
562
|
+
end
|
|
641
563
|
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
@st.
|
|
564
|
+
context "fails when" do
|
|
565
|
+
context "checkbox with label" do
|
|
566
|
+
it "does not exist" do
|
|
567
|
+
@st.checkbox_is_enabled("I dislike bacon").should be_false
|
|
568
|
+
end
|
|
569
|
+
|
|
570
|
+
it "exists but is unchecked" do
|
|
571
|
+
@st.disable_checkbox("I like cheese").should be_true
|
|
572
|
+
@st.checkbox_is_enabled("I like cheese").should be_false
|
|
573
|
+
end
|
|
574
|
+
|
|
575
|
+
it "exists and is checked, but not within scope" do
|
|
576
|
+
@st.enable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
|
577
|
+
@st.checkbox_is_enabled("I like cheese", :within => "salami_checkbox").should be_false
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
it "exists and is checked, but not in table row" do
|
|
581
|
+
@st.visit("/table")
|
|
582
|
+
@st.enable_checkbox("Like", :in_row => "Marcus").should be_true
|
|
583
|
+
@st.checkbox_is_enabled("Like", :in_row => "Eric").should be_false
|
|
646
584
|
end
|
|
647
585
|
end
|
|
586
|
+
end
|
|
587
|
+
end
|
|
648
588
|
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
589
|
+
describe "#checkbox_is_disabled" do
|
|
590
|
+
context "passes when" do
|
|
591
|
+
context "checkbox with label" do
|
|
592
|
+
it "exists and is unchecked" do
|
|
593
|
+
@st.disable_checkbox("I like cheese").should be_true
|
|
594
|
+
@st.checkbox_is_disabled("I like cheese").should be_true
|
|
595
|
+
end
|
|
596
|
+
|
|
597
|
+
it "exists within scope and is unchecked" do
|
|
598
|
+
@st.disable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
|
599
|
+
@st.checkbox_is_disabled("I like cheese", :within => "cheese_checkbox").should be_true
|
|
600
|
+
end
|
|
601
|
+
|
|
602
|
+
it "exists in table row and is unchecked" do
|
|
603
|
+
@st.visit("/table")
|
|
604
|
+
@st.disable_checkbox("Like", :in_row => "Ken").should be_true
|
|
605
|
+
@st.checkbox_is_disabled("Like", :in_row => "Ken").should be_true
|
|
653
606
|
end
|
|
654
607
|
end
|
|
655
608
|
end
|
|
656
609
|
|
|
657
610
|
context "fails when" do
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
611
|
+
context "checkbox with label" do
|
|
612
|
+
it "does not exist" do
|
|
613
|
+
@st.checkbox_is_disabled("I dislike bacon").should be_false
|
|
614
|
+
end
|
|
662
615
|
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
616
|
+
it "exists but is checked" do
|
|
617
|
+
@st.enable_checkbox("I like cheese").should be_true
|
|
618
|
+
@st.checkbox_is_disabled("I like cheese").should be_false
|
|
619
|
+
end
|
|
620
|
+
|
|
621
|
+
it "exists and is unchecked, but not within scope" do
|
|
622
|
+
@st.disable_checkbox("I like cheese", :within => "cheese_checkbox").should be_true
|
|
623
|
+
@st.checkbox_is_disabled("I like cheese", :within => "salami_checkbox").should be_false
|
|
624
|
+
end
|
|
625
|
+
|
|
626
|
+
it "exists and is unchecked, but not in table row" do
|
|
627
|
+
@st.visit("/table")
|
|
628
|
+
@st.disable_checkbox("Like", :in_row => "Marcus").should be_true
|
|
629
|
+
@st.checkbox_is_disabled("Like", :in_row => "Eric").should be_false
|
|
630
|
+
end
|
|
666
631
|
end
|
|
667
632
|
end
|
|
668
633
|
end
|
|
634
|
+
end # checkboxes
|
|
669
635
|
|
|
670
|
-
|
|
636
|
+
|
|
637
|
+
context "radiobuttons" do
|
|
638
|
+
before(:each) do
|
|
639
|
+
@st.visit("/form").should be_true
|
|
640
|
+
end
|
|
641
|
+
|
|
642
|
+
context "#select_radio" do
|
|
671
643
|
context "passes when" do
|
|
672
|
-
context "
|
|
673
|
-
it "
|
|
674
|
-
@st.
|
|
675
|
-
@st.field_contains("First name", "Marcus").should be_true
|
|
644
|
+
context "radiobutton with label" do
|
|
645
|
+
it "exists" do
|
|
646
|
+
@st.select_radio("Briefs").should be_true
|
|
676
647
|
end
|
|
677
648
|
|
|
678
|
-
it "
|
|
679
|
-
@st.
|
|
680
|
-
@st.field_contains("First name", "Marc").should be_true
|
|
649
|
+
it "exists within scope" do
|
|
650
|
+
@st.select_radio("Briefs", :within => "clothing").should be_true
|
|
681
651
|
end
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
it "contains the text" do
|
|
686
|
-
@st.fill_in_with("Life story", "Blah dee blah")
|
|
687
|
-
@st.field_contains("Life story", "blah").should be_true
|
|
652
|
+
|
|
653
|
+
it "exists in table row" do
|
|
654
|
+
# TODO
|
|
688
655
|
end
|
|
689
656
|
end
|
|
690
657
|
end
|
|
691
658
|
|
|
692
659
|
context "fails when" do
|
|
693
|
-
context "
|
|
694
|
-
it "does not
|
|
695
|
-
@st.
|
|
696
|
-
@st.field_contains("First name", "Eric").should be_false
|
|
660
|
+
context "radiobutton with label" do
|
|
661
|
+
it "does not exist" do
|
|
662
|
+
@st.select_radio("Naked").should be_false
|
|
697
663
|
end
|
|
698
|
-
end
|
|
699
664
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
665
|
+
it "exists, but not within scope" do
|
|
666
|
+
@st.select_radio("Briefs", :within => "food").should be_false
|
|
667
|
+
end
|
|
668
|
+
|
|
669
|
+
it "exists, but not in table row" do
|
|
670
|
+
# TODO
|
|
704
671
|
end
|
|
705
672
|
end
|
|
706
673
|
end
|
|
707
674
|
end
|
|
708
675
|
|
|
709
|
-
|
|
676
|
+
context "#radio_is_enabled" do
|
|
710
677
|
context "passes when" do
|
|
711
|
-
context "
|
|
712
|
-
it "
|
|
713
|
-
@st.
|
|
714
|
-
@st.
|
|
715
|
-
end
|
|
716
|
-
|
|
717
|
-
it "equals the text, and is within scope" do
|
|
718
|
-
@st.fill_in_with("First name", "Eric", :within => "person_form")
|
|
719
|
-
@st.field_equals("First name", "Eric", :within => "person_form")
|
|
720
|
-
end
|
|
721
|
-
end
|
|
722
|
-
|
|
723
|
-
context "textarea with label" do
|
|
724
|
-
it "equals the text" do
|
|
725
|
-
@st.fill_in_with("Life story", "Blah dee blah")
|
|
726
|
-
@st.field_equals("Life story", "Blah dee blah").should be_true
|
|
678
|
+
context "radiobutton with label" do
|
|
679
|
+
it "exists, and is enabled" do
|
|
680
|
+
@st.select_radio("Briefs")
|
|
681
|
+
@st.radio_is_enabled("Briefs").should be_true
|
|
727
682
|
end
|
|
728
683
|
|
|
729
|
-
it "
|
|
730
|
-
@st.
|
|
731
|
-
|
|
732
|
-
@st.field_equals("Life story", "Blah dee blah",
|
|
733
|
-
:within => "person_form").should be_true
|
|
684
|
+
it "exists within scope, and is enabled" do
|
|
685
|
+
@st.select_radio("Briefs", :within => "clothing")
|
|
686
|
+
@st.radio_is_enabled("Briefs", :within => "clothing").should be_true
|
|
734
687
|
end
|
|
735
688
|
|
|
736
|
-
it "
|
|
689
|
+
it "exists in table row, and is enabled" do
|
|
737
690
|
# TODO
|
|
738
691
|
end
|
|
739
692
|
end
|
|
740
693
|
end
|
|
741
694
|
|
|
742
695
|
context "fails when" do
|
|
743
|
-
context "
|
|
744
|
-
it "does not
|
|
745
|
-
@st.
|
|
746
|
-
@st.field_equals("First name", "Marc").should be_false
|
|
747
|
-
end
|
|
748
|
-
end
|
|
749
|
-
|
|
750
|
-
context "textarea with label" do
|
|
751
|
-
it "does not exactly equal the text" do
|
|
752
|
-
@st.fill_in_with("Life story", "Blah dee blah")
|
|
753
|
-
@st.field_equals("Life story", "Blah dee").should be_false
|
|
696
|
+
context "radiobutton with label" do
|
|
697
|
+
it "does not exist" do
|
|
698
|
+
@st.radio_is_enabled("Naked").should be_false
|
|
754
699
|
end
|
|
755
700
|
|
|
756
|
-
it "
|
|
757
|
-
|
|
701
|
+
it "exists, but is not enabled" do
|
|
702
|
+
@st.select_radio("Briefs")
|
|
703
|
+
@st.radio_is_enabled("Boxers").should be_false
|
|
758
704
|
end
|
|
759
705
|
|
|
760
|
-
it "
|
|
761
|
-
|
|
706
|
+
it "exists and is enabled, but not within scope" do
|
|
707
|
+
@st.select_radio("Briefs", :within => "clothing")
|
|
708
|
+
@st.radio_is_enabled("Briefs", :within => "food").should be_false
|
|
762
709
|
end
|
|
763
710
|
end
|
|
764
711
|
end
|
|
765
712
|
end
|
|
766
|
-
end
|
|
713
|
+
end # radiobuttons
|
|
767
714
|
|
|
768
715
|
|
|
769
|
-
context "
|
|
716
|
+
context "dropdowns" do
|
|
770
717
|
before(:each) do
|
|
771
|
-
@st.visit("/").should be_true
|
|
718
|
+
@st.visit("/form").should be_true
|
|
772
719
|
end
|
|
773
720
|
|
|
774
|
-
|
|
721
|
+
context "#select_from_dropdown" do
|
|
775
722
|
context "passes when" do
|
|
776
|
-
it "
|
|
777
|
-
@st.
|
|
778
|
-
@st.
|
|
723
|
+
it "option exists in the dropdown" do
|
|
724
|
+
@st.select_from_dropdown("Tall", "Height").should be_true
|
|
725
|
+
@st.select_from_dropdown("Medium", "Weight").should be_true
|
|
726
|
+
end
|
|
727
|
+
|
|
728
|
+
it "option exists in the dropdown within scope" do
|
|
729
|
+
@st.select_from_dropdown("Tall", "Height", :within => "spouse_form").should be_true
|
|
730
|
+
end
|
|
731
|
+
|
|
732
|
+
it "option exists in the dropdown in table row" do
|
|
733
|
+
@st.visit("/table")
|
|
734
|
+
@st.select_from_dropdown("Male", "Gender", :in_row => "Eric").should be_true
|
|
779
735
|
end
|
|
780
736
|
end
|
|
781
737
|
|
|
782
738
|
context "fails when" do
|
|
783
|
-
it "
|
|
784
|
-
@st.
|
|
785
|
-
@st.see("Some bogus text").should be_false
|
|
739
|
+
it "no such dropdown exists" do
|
|
740
|
+
@st.select_from_dropdown("Over easy", "Eggs").should be_false
|
|
786
741
|
end
|
|
787
|
-
end
|
|
788
742
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
743
|
+
it "dropdown exists, but the option doesn't" do
|
|
744
|
+
@st.select_from_dropdown("Giant", "Height").should be_false
|
|
745
|
+
@st.select_from_dropdown("Obese", "Weight").should be_false
|
|
746
|
+
end
|
|
747
|
+
|
|
748
|
+
it "dropdown exists, but not within scope" do
|
|
749
|
+
@st.select_from_dropdown("Medium", "Weight", :within => "spouse_form").should be_false
|
|
750
|
+
end
|
|
751
|
+
|
|
752
|
+
it "dropdown exists, but not in table row" do
|
|
753
|
+
@st.visit("/table")
|
|
754
|
+
@st.select_from_dropdown("Female", "Gender", :in_row => "First name").should be_false
|
|
755
|
+
end
|
|
792
756
|
end
|
|
793
757
|
end
|
|
794
758
|
|
|
795
|
-
|
|
759
|
+
context "#dropdown_includes" do
|
|
796
760
|
context "passes when" do
|
|
797
|
-
it "
|
|
798
|
-
@st.
|
|
799
|
-
@st.
|
|
761
|
+
it "option exists in the dropdown" do
|
|
762
|
+
@st.dropdown_includes("Height", "Tall").should be_true
|
|
763
|
+
@st.dropdown_includes("Weight", "Medium").should be_true
|
|
800
764
|
end
|
|
801
765
|
end
|
|
802
766
|
|
|
803
767
|
context "fails when" do
|
|
804
|
-
it "
|
|
805
|
-
@st.
|
|
806
|
-
@st.
|
|
768
|
+
it "dropdown exists, but the option doesn't" do
|
|
769
|
+
@st.dropdown_includes("Height", "Giant").should be_false
|
|
770
|
+
@st.dropdown_includes("Weight", "Obese").should be_false
|
|
771
|
+
end
|
|
772
|
+
|
|
773
|
+
it "no such dropdown exists" do
|
|
774
|
+
@st.dropdown_includes("Eggs", "Over easy").should be_false
|
|
807
775
|
end
|
|
808
776
|
end
|
|
777
|
+
end
|
|
809
778
|
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
779
|
+
context "#dropdown_equals" do
|
|
780
|
+
context "passes when" do
|
|
781
|
+
it "option is selected in the dropdown" do
|
|
782
|
+
["Short", "Average", "Tall"].each do |height|
|
|
783
|
+
@st.select_from_dropdown(height, "Height")
|
|
784
|
+
@st.dropdown_equals("Height", height).should be_true
|
|
785
|
+
end
|
|
786
|
+
end
|
|
787
|
+
|
|
788
|
+
it "option is selected in the dropdown, within scope" do
|
|
789
|
+
["Short", "Average", "Tall"].each do |height|
|
|
790
|
+
@st.select_from_dropdown(height, "Height", :within => "spouse_form")
|
|
791
|
+
@st.dropdown_equals("Height", height, :within => "spouse_form").should be_true
|
|
792
|
+
end
|
|
793
|
+
end
|
|
794
|
+
|
|
795
|
+
it "option is selected in the dropdown, in table row" do
|
|
796
|
+
@st.visit("/table")
|
|
797
|
+
["Male", "Female"].each do |gender|
|
|
798
|
+
@st.select_from_dropdown(gender, "Gender", :in_row => "Eric")
|
|
799
|
+
@st.dropdown_equals("Gender", gender, :in_row => "Eric")
|
|
800
|
+
end
|
|
801
|
+
end
|
|
802
|
+
end
|
|
803
|
+
|
|
804
|
+
context "fails when" do
|
|
805
|
+
it "no such dropdown exists" do
|
|
806
|
+
@st.dropdown_equals("Eggs", "Over easy").should be_false
|
|
807
|
+
end
|
|
808
|
+
|
|
809
|
+
it "dropdown exists, but the option is not selected" do
|
|
810
|
+
@st.select_from_dropdown("Short", "Height")
|
|
811
|
+
@st.dropdown_equals("Height", "Average").should be_false
|
|
812
|
+
@st.dropdown_equals("Height", "Tall").should be_false
|
|
813
|
+
|
|
814
|
+
@st.select_from_dropdown("Average", "Height")
|
|
815
|
+
@st.dropdown_equals("Height", "Short").should be_false
|
|
816
|
+
@st.dropdown_equals("Height", "Tall").should be_false
|
|
817
|
+
|
|
818
|
+
@st.select_from_dropdown("Tall", "Height")
|
|
819
|
+
@st.dropdown_equals("Height", "Short").should be_false
|
|
820
|
+
@st.dropdown_equals("Height", "Average").should be_false
|
|
821
|
+
end
|
|
822
|
+
|
|
823
|
+
it "dropdown exists, and option is selected, but not in scope" do
|
|
824
|
+
@st.select_from_dropdown("Tall", "Height", :within => "person_form")
|
|
825
|
+
@st.select_from_dropdown("Short", "Height", :within => "spouse_form")
|
|
826
|
+
@st.dropdown_equals("Height", "Tall", :within => "spouse_form").should be_false
|
|
827
|
+
end
|
|
828
|
+
|
|
829
|
+
it "dropdown exists, and option is selected, but not in table row" do
|
|
830
|
+
@st.visit("/table")
|
|
831
|
+
@st.select_from_dropdown("Female", "Gender", :in_row => "Eric")
|
|
832
|
+
@st.select_from_dropdown("Male", "Gender", :in_row => "Marcus")
|
|
833
|
+
@st.dropdown_equals("Gender", "Female", :in_row => "Marcus").should be_false
|
|
834
|
+
end
|
|
813
835
|
end
|
|
814
836
|
end
|
|
815
|
-
end
|
|
837
|
+
end # dropdowns
|
|
816
838
|
|
|
817
839
|
|
|
818
840
|
context "tables" do
|
|
@@ -853,6 +875,159 @@ describe Rsel::SeleniumTest do
|
|
|
853
875
|
end
|
|
854
876
|
end
|
|
855
877
|
|
|
856
|
-
end
|
|
878
|
+
end # tables
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
context "stop on error" do
|
|
882
|
+
before(:each) do
|
|
883
|
+
@st.visit("/").should be_true
|
|
884
|
+
@st.stop_on_error = true
|
|
885
|
+
end
|
|
886
|
+
|
|
887
|
+
after(:each) do
|
|
888
|
+
@st.stop_on_error = false
|
|
889
|
+
end
|
|
890
|
+
|
|
891
|
+
context "causes an exception to be raised" do
|
|
892
|
+
it "when #see fails" do
|
|
893
|
+
lambda do
|
|
894
|
+
@st.see("Nonexistent")
|
|
895
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
896
|
+
end
|
|
897
|
+
|
|
898
|
+
it "when #do_not_see fails" do
|
|
899
|
+
lambda do
|
|
900
|
+
@st.do_not_see("Welcome")
|
|
901
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
902
|
+
end
|
|
903
|
+
|
|
904
|
+
it "when #see_title fails" do
|
|
905
|
+
lambda do
|
|
906
|
+
@st.see_title("Wrong Title")
|
|
907
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
908
|
+
end
|
|
909
|
+
|
|
910
|
+
it "when #do_not_see_title fails" do
|
|
911
|
+
lambda do
|
|
912
|
+
@st.do_not_see_title("Rsel Test Site")
|
|
913
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
914
|
+
end
|
|
915
|
+
|
|
916
|
+
it "when #link_exists fails" do
|
|
917
|
+
lambda do
|
|
918
|
+
@st.link_exists("Bogus Link")
|
|
919
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
920
|
+
end
|
|
921
|
+
|
|
922
|
+
it "when #button_exists fails" do
|
|
923
|
+
lambda do
|
|
924
|
+
@st.button_exists("Bogus Button")
|
|
925
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
926
|
+
end
|
|
927
|
+
|
|
928
|
+
it "when #row_exists fails" do
|
|
929
|
+
lambda do
|
|
930
|
+
@st.row_exists("No, Such, Row")
|
|
931
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
932
|
+
end
|
|
933
|
+
|
|
934
|
+
it "when #type_into_field fails" do
|
|
935
|
+
lambda do
|
|
936
|
+
@st.type_into_field("Hello", "Bad Field")
|
|
937
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
938
|
+
end
|
|
939
|
+
|
|
940
|
+
it "when #field_contains fails" do
|
|
941
|
+
lambda do
|
|
942
|
+
@st.field_contains("Bad Field", "Hello")
|
|
943
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
944
|
+
end
|
|
945
|
+
|
|
946
|
+
it "when #field_equals fails" do
|
|
947
|
+
lambda do
|
|
948
|
+
@st.field_equals("Bad Field", "Hello")
|
|
949
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
950
|
+
end
|
|
951
|
+
|
|
952
|
+
it "when #click fails" do
|
|
953
|
+
lambda do
|
|
954
|
+
@st.click("No Such Link")
|
|
955
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
956
|
+
end
|
|
957
|
+
|
|
958
|
+
it "when #click_link fails" do
|
|
959
|
+
lambda do
|
|
960
|
+
@st.click_link("No Such Link")
|
|
961
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
962
|
+
end
|
|
963
|
+
|
|
964
|
+
it "when #click_button fails" do
|
|
965
|
+
lambda do
|
|
966
|
+
@st.click_button("No Such Link")
|
|
967
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
968
|
+
end
|
|
969
|
+
|
|
970
|
+
it "when #enable_checkbox fails" do
|
|
971
|
+
lambda do
|
|
972
|
+
@st.enable_checkbox("No Such Checkbox")
|
|
973
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
974
|
+
end
|
|
975
|
+
|
|
976
|
+
it "when #disable_checkbox fails" do
|
|
977
|
+
lambda do
|
|
978
|
+
@st.disable_checkbox("No Such Checkbox")
|
|
979
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
980
|
+
end
|
|
981
|
+
|
|
982
|
+
it "when #checkbox_is_enabled fails" do
|
|
983
|
+
lambda do
|
|
984
|
+
@st.checkbox_is_enabled("No Such Checkbox")
|
|
985
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
986
|
+
end
|
|
987
|
+
|
|
988
|
+
it "when #checkbox_is_disabled fails" do
|
|
989
|
+
lambda do
|
|
990
|
+
@st.checkbox_is_disabled("No Such Checkbox")
|
|
991
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
992
|
+
end
|
|
993
|
+
|
|
994
|
+
it "when #radio_is_enabled fails" do
|
|
995
|
+
lambda do
|
|
996
|
+
@st.radio_is_enabled("No Such Radio")
|
|
997
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
998
|
+
end
|
|
999
|
+
|
|
1000
|
+
it "when #radio_is_disabled fails" do
|
|
1001
|
+
lambda do
|
|
1002
|
+
@st.radio_is_disabled("No Such Radio")
|
|
1003
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
1004
|
+
end
|
|
1005
|
+
|
|
1006
|
+
it "when #select_radio fails" do
|
|
1007
|
+
lambda do
|
|
1008
|
+
@st.select_radio("No Such Radio")
|
|
1009
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
1010
|
+
end
|
|
1011
|
+
|
|
1012
|
+
it "when #select_from_dropdown fails" do
|
|
1013
|
+
lambda do
|
|
1014
|
+
@st.select_from_dropdown("Junk", "No Such Dropdown")
|
|
1015
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
1016
|
+
end
|
|
1017
|
+
|
|
1018
|
+
it "when #dropdown_includes fails" do
|
|
1019
|
+
lambda do
|
|
1020
|
+
@st.dropdown_includes("No Such Dropdown", "Junk")
|
|
1021
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
1022
|
+
end
|
|
1023
|
+
|
|
1024
|
+
it "when #dropdown_equals fails" do
|
|
1025
|
+
lambda do
|
|
1026
|
+
@st.dropdown_equals("No Such Dropdown", "Junk")
|
|
1027
|
+
end.should raise_error(Rsel::StopTestStepFailed)
|
|
1028
|
+
end
|
|
1029
|
+
end
|
|
1030
|
+
end # stop on error
|
|
1031
|
+
|
|
857
1032
|
end
|
|
858
1033
|
|