celerity 0.0.1 → 0.0.2
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/History.txt +10 -0
- data/README.txt +8 -11
- data/Rakefile +5 -3
- data/benchmark/bm_2000_spans.rb +48 -0
- data/benchmark/bm_digg.rb +26 -0
- data/benchmark/bm_google_images.rb +36 -0
- data/benchmark/bm_input_locator.rb +69 -0
- data/benchmark/loader.rb +9 -0
- data/lib/celerity.rb +3 -1
- data/lib/celerity/container.rb +23 -171
- data/lib/celerity/disabled_element.rb +1 -1
- data/lib/celerity/element.rb +78 -47
- data/lib/celerity/element_collections.rb +16 -32
- data/lib/celerity/element_locator.rb +135 -0
- data/lib/celerity/elements/button.rb +15 -0
- data/lib/celerity/elements/file_field.rb +1 -1
- data/lib/celerity/elements/form.rb +2 -1
- data/lib/celerity/elements/frame.rb +18 -21
- data/lib/celerity/elements/image.rb +2 -8
- data/lib/celerity/elements/label.rb +1 -3
- data/lib/celerity/elements/link.rb +1 -1
- data/lib/celerity/elements/option.rb +16 -0
- data/lib/celerity/elements/radio_check.rb +18 -7
- data/lib/celerity/elements/select_list.rb +1 -17
- data/lib/celerity/elements/table.rb +4 -4
- data/lib/celerity/elements/table_body.rb +6 -8
- data/lib/celerity/elements/table_cell.rb +3 -14
- data/lib/celerity/elements/table_row.rb +4 -10
- data/lib/celerity/elements/text_field.rb +16 -4
- data/lib/celerity/extra/method_generator.rb +144 -0
- data/lib/celerity/identifier.rb +10 -0
- data/lib/celerity/ie.rb +28 -13
- data/lib/celerity/input_element.rb +0 -4
- data/lib/celerity/non_control_elements.rb +12 -12
- data/lib/celerity/version.rb +1 -1
- data/spec/area_spec.rb +41 -41
- data/spec/areas_spec.rb +11 -11
- data/spec/button_spec.rb +73 -68
- data/spec/buttons_spec.rb +10 -10
- data/spec/checkbox_spec.rb +102 -96
- data/spec/checkboxes_spec.rb +10 -10
- data/spec/div_spec.rb +78 -73
- data/spec/divs_spec.rb +10 -10
- data/spec/element_spec.rb +20 -11
- data/spec/filefield_spec.rb +36 -41
- data/spec/filefields_spec.rb +10 -10
- data/spec/form_spec.rb +29 -29
- data/spec/forms_spec.rb +11 -11
- data/spec/frame_spec.rb +54 -49
- data/spec/hidden_spec.rb +43 -43
- data/spec/hiddens_spec.rb +10 -10
- data/spec/html/2000_spans.html +2009 -0
- data/spec/html/forms_with_input_elements.html +15 -9
- data/spec/html/non_control_elements.html +4 -2
- data/spec/ie_spec.rb +82 -48
- data/spec/image_spec.rb +83 -100
- data/spec/images_spec.rb +10 -10
- data/spec/label_spec.rb +29 -29
- data/spec/labels_spec.rb +10 -10
- data/spec/li_spec.rb +41 -41
- data/spec/link_spec.rb +65 -59
- data/spec/links_spec.rb +11 -11
- data/spec/lis_spec.rb +10 -10
- data/spec/map_spec.rb +30 -30
- data/spec/maps_spec.rb +10 -10
- data/spec/p_spec.rb +49 -49
- data/spec/pre_spec.rb +41 -41
- data/spec/pres_spec.rb +10 -10
- data/spec/ps_spec.rb +10 -10
- data/spec/radio_spec.rb +104 -97
- data/spec/radios_spec.rb +11 -11
- data/spec/select_list_spec.rb +118 -106
- data/spec/select_lists_spec.rb +15 -15
- data/spec/span_spec.rb +54 -54
- data/spec/spans_spec.rb +11 -11
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +23 -3
- data/spec/table_bodies.rb +8 -8
- data/spec/table_bodies_spec.rb +9 -9
- data/spec/table_body_spec.rb +28 -27
- data/spec/table_cell_spec.rb +25 -25
- data/spec/table_cells_spec.rb +16 -16
- data/spec/table_row_spec.rb +16 -16
- data/spec/table_rows_spec.rb +12 -12
- data/spec/table_spec.rb +36 -36
- data/spec/tables_spec.rb +12 -12
- data/spec/text_field_spec.rb +111 -92
- data/spec/text_fields_spec.rb +13 -13
- data/tasks/benchmark.rake +3 -0
- data/tasks/rspec.rake +2 -2
- data/tasks/testserver.rake +15 -0
- metadata +58 -46
- data/tasks/simple_ci.rake +0 -94
data/spec/buttons_spec.rb
CHANGED
@@ -3,38 +3,38 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
3
3
|
describe "Buttons" do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@
|
7
|
-
add_spec_checker(@
|
6
|
+
@browser = IE.new
|
7
|
+
add_spec_checker(@browser)
|
8
8
|
end
|
9
9
|
|
10
10
|
before :each do
|
11
|
-
@
|
11
|
+
@browser.goto(TEST_HOST + "/forms_with_input_elements.html")
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "#length" do
|
15
15
|
it "should return the number of buttons" do
|
16
|
-
@
|
16
|
+
@browser.buttons.length.should == 7
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
describe "#[]" do
|
21
21
|
it "should return the button at the given index" do
|
22
|
-
@
|
22
|
+
@browser.buttons[1].title.should == "Submit the form"
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "#each" do
|
27
27
|
it "should iterate through buttons correctly" do
|
28
|
-
@
|
29
|
-
b.name.should == @
|
30
|
-
b.id.should == @
|
31
|
-
b.value.should == @
|
28
|
+
@browser.buttons.each_with_index do |b, index|
|
29
|
+
b.name.should == @browser.button(:index, index+1).name
|
30
|
+
b.id.should == @browser.button(:index, index+1).id
|
31
|
+
b.value.should == @browser.button(:index, index+1).value
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
after :all do
|
37
|
-
@
|
37
|
+
@browser.close
|
38
38
|
end
|
39
39
|
|
40
40
|
end
|
data/spec/checkbox_spec.rb
CHANGED
@@ -3,12 +3,12 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
3
3
|
describe "Checkbox" do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@
|
7
|
-
add_spec_checker(@
|
6
|
+
@browser = IE.new
|
7
|
+
add_spec_checker(@browser)
|
8
8
|
end
|
9
9
|
|
10
10
|
before :each do
|
11
|
-
@
|
11
|
+
@browser.goto(TEST_HOST + "/forms_with_input_elements.html")
|
12
12
|
end
|
13
13
|
|
14
14
|
|
@@ -16,59 +16,59 @@ describe "Checkbox" do
|
|
16
16
|
|
17
17
|
describe "#exists?" do
|
18
18
|
it "should return true if the checkbox button exists" do
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
24
|
-
@
|
19
|
+
@browser.checkbox(:id, "new_user_interests_books").should exist
|
20
|
+
@browser.checkbox(:id, /new_user_interests_books/).should exist
|
21
|
+
@browser.checkbox(:name, "new_user_interests").should exist
|
22
|
+
@browser.checkbox(:name, /new_user_interests/).should exist
|
23
|
+
@browser.checkbox(:value, "books").should exist
|
24
|
+
@browser.checkbox(:value, /books/).should exist
|
25
25
|
# unsure what :text is supposed to represent here
|
26
|
-
# @
|
27
|
-
# @
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
31
|
-
@
|
26
|
+
# @browser.checkbox(:text, "books").should exist
|
27
|
+
# @browser.checkbox(:text, /books/).should exist
|
28
|
+
@browser.checkbox(:class, "fun").should exist
|
29
|
+
@browser.checkbox(:class, /fun/).should exist
|
30
|
+
@browser.checkbox(:index, 1).should exist
|
31
|
+
@browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").should exist
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should return true if the checkbox button exists (search by name and value)" do
|
35
|
-
@
|
36
|
-
@
|
35
|
+
@browser.checkbox(:name, "new_user_interests", 'cars').should exist
|
36
|
+
@browser.checkbox(:xpath, "//input[@name='new_user_interests' and @value='cars']").set
|
37
37
|
end
|
38
38
|
|
39
39
|
it "should return false if the checkbox button does not exist" do
|
40
|
-
@
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@
|
44
|
-
@
|
45
|
-
@
|
46
|
-
@
|
47
|
-
@
|
48
|
-
@
|
49
|
-
@
|
50
|
-
@
|
51
|
-
@
|
40
|
+
@browser.checkbox(:id, "no_such_id").should_not exist
|
41
|
+
@browser.checkbox(:id, /no_such_id/).should_not exist
|
42
|
+
@browser.checkbox(:name, "no_such_name").should_not exist
|
43
|
+
@browser.checkbox(:name, /no_such_name/).should_not exist
|
44
|
+
@browser.checkbox(:value, "no_such_value").should_not exist
|
45
|
+
@browser.checkbox(:value, /no_such_value/).should_not exist
|
46
|
+
@browser.checkbox(:text, "no_such_text").should_not exist
|
47
|
+
@browser.checkbox(:text, /no_such_text/).should_not exist
|
48
|
+
@browser.checkbox(:class, "no_such_class").should_not exist
|
49
|
+
@browser.checkbox(:class, /no_such_class/).should_not exist
|
50
|
+
@browser.checkbox(:index, 1337).should_not exist
|
51
|
+
@browser.checkbox(:xpath, "//input[@id='no_such_id']").should_not exist
|
52
52
|
end
|
53
53
|
|
54
54
|
it "should return false if the checkbox button does not exist (search by name and value)" do
|
55
|
-
@
|
56
|
-
@
|
57
|
-
@
|
58
|
-
@
|
55
|
+
@browser.checkbox(:name, "new_user_interests", 'no_such_value').should_not exist
|
56
|
+
@browser.checkbox(:xpath, "//input[@name='new_user_interests' and @value='no_such_value']").should_not exist
|
57
|
+
@browser.checkbox(:name, "no_such_name", 'cars').should_not exist
|
58
|
+
@browser.checkbox(:xpath, "//input[@name='no_such_name' and @value='cars']").should_not exist
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should return true for checkboxs with a string value" do
|
62
|
-
@
|
63
|
-
@
|
62
|
+
@browser.checkbox(:name, 'new_user_interests', 'books').should exist
|
63
|
+
@browser.checkbox(:name, 'new_user_interests', 'cars').should exist
|
64
64
|
end
|
65
65
|
|
66
|
-
it "should raise ArgumentError when what argument is invalid" do
|
67
|
-
lambda { @
|
66
|
+
it "should raise ArgumentError when 'what' argument is invalid" do
|
67
|
+
lambda { @browser.checkbox(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
68
68
|
end
|
69
69
|
|
70
|
-
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
71
|
-
lambda { @
|
70
|
+
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
71
|
+
lambda { @browser.checkbox(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -77,67 +77,67 @@ describe "Checkbox" do
|
|
77
77
|
|
78
78
|
describe "#class_name" do
|
79
79
|
it "should return the class name if the checkbox exists and has an attribute" do
|
80
|
-
@
|
80
|
+
@browser.checkbox(:id, "new_user_interests_dancing").class_name.should == "fun"
|
81
81
|
end
|
82
82
|
it "should return an emptry string if the checkbox exists and the attribute doesn't" do
|
83
|
-
@
|
83
|
+
@browser.checkbox(:id, "new_user_interests_books").class_name.should == ""
|
84
84
|
end
|
85
85
|
it "should raise UnknownObjectException if the checkbox doesn't exist" do
|
86
|
-
lambda { @
|
86
|
+
lambda { @browser.checkbox(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
describe "#id" do
|
91
91
|
it "should return the id attribute if the checkbox exists and has an attribute" do
|
92
|
-
@
|
92
|
+
@browser.checkbox(:index, 1).id.should == "new_user_interests_books"
|
93
93
|
end
|
94
94
|
it "should return an emptry string if the checkbox exists and the attribute doesn't" do
|
95
|
-
@
|
95
|
+
@browser.checkbox(:index, 2).id.should == ""
|
96
96
|
end
|
97
97
|
it "should raise UnknownObjectException if the checkbox doesn't exist" do
|
98
|
-
lambda { @
|
98
|
+
lambda { @browser.checkbox(:index, 1337).id }.should raise_error(UnknownObjectException)
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
102
|
describe "#name" do
|
103
103
|
it "should return the name attribute if the checkbox exists" do
|
104
|
-
@
|
104
|
+
@browser.checkbox(:id, 'new_user_interests_books').name.should == "new_user_interests"
|
105
105
|
end
|
106
106
|
it "should return an empty string if the checkbox exists and the attribute doesn't" do
|
107
|
-
@
|
107
|
+
@browser.checkbox(:id, 'new_user_interests_food').name.should == ""
|
108
108
|
end
|
109
109
|
it "should raise UnknownObjectException if the checkbox doesn't exist" do
|
110
|
-
lambda { @
|
110
|
+
lambda { @browser.checkbox(:index, 1337).name }.should raise_error(UnknownObjectException)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
114
114
|
describe "#title" do
|
115
115
|
it "should return the title attribute if the checkbox exists" do
|
116
|
-
@
|
116
|
+
@browser.checkbox(:id, "new_user_interests_dancing").title.should == "Dancing is fun!"
|
117
117
|
end
|
118
118
|
it "should return an emptry string if the checkbox exists and the attribute doesn't" do
|
119
|
-
@
|
119
|
+
@browser.checkbox(:id, "new_user_interests_books").title.should == ""
|
120
120
|
end
|
121
121
|
it "should raise UnknownObjectException if the checkbox doesn't exist" do
|
122
|
-
lambda { @
|
122
|
+
lambda { @browser.checkbox(:index, 1337).title }.should raise_error(UnknownObjectException)
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
126
|
describe "#type" do
|
127
127
|
it "should return the type attribute if the checkbox exists" do
|
128
|
-
@
|
128
|
+
@browser.checkbox(:index, 1).type.should == "checkbox"
|
129
129
|
end
|
130
130
|
it "should raise UnknownObjectException if the checkbox doesn't exist" do
|
131
|
-
lambda { @
|
131
|
+
lambda { @browser.checkbox(:index, 1337).type }.should raise_error(UnknownObjectException)
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
135
|
describe "#value" do
|
136
136
|
it "should return the value attribute if the checkbox exists" do
|
137
|
-
@
|
137
|
+
@browser.checkbox(:id, 'new_user_interests_books').value.should == 'books'
|
138
138
|
end
|
139
139
|
it "should raise UnknownObjectException if the checkbox doesn't exist" do
|
140
|
-
lambda { @
|
140
|
+
lambda { @browser.checkbox(:index, 1337).value}.should raise_error(UnknownObjectException)
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
@@ -146,28 +146,28 @@ describe "Checkbox" do
|
|
146
146
|
|
147
147
|
describe "#enabled?" do
|
148
148
|
it "should return true if the checkbox button is enabled" do
|
149
|
-
@
|
150
|
-
@
|
149
|
+
@browser.checkbox(:id, "new_user_interests_books").should be_enabled
|
150
|
+
@browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").should be_enabled
|
151
151
|
end
|
152
152
|
it "should return false if the checkbox button is disabled" do
|
153
|
-
@
|
154
|
-
@
|
153
|
+
@browser.checkbox(:id, "new_user_interests_dentistry").should_not be_enabled
|
154
|
+
@browser.checkbox(:xpath,"//input[@id='new_user_interests_dentistry']").should_not be_enabled
|
155
155
|
end
|
156
156
|
it "should raise UnknownObjectException if the checkbox button doesn't exist" do
|
157
|
-
lambda { @
|
158
|
-
lambda { @
|
157
|
+
lambda { @browser.checkbox(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
|
158
|
+
lambda { @browser.checkbox(:xpath, "//input[@id='no_such_id']").enabled? }.should raise_error(UnknownObjectException)
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
162
|
describe "#disabled?" do
|
163
163
|
it "should return true if the checkbox is disabled" do
|
164
|
-
@
|
164
|
+
@browser.checkbox(:id, 'new_user_interests_dentistry').should be_disabled
|
165
165
|
end
|
166
166
|
it "should return false if the checkbox is enabled" do
|
167
|
-
@
|
167
|
+
@browser.checkbox(:id, 'new_user_interests_books').should_not be_disabled
|
168
168
|
end
|
169
169
|
it "should raise UnknownObjectException if the checkbox doesn't exist" do
|
170
|
-
lambda { @
|
170
|
+
lambda { @browser.checkbox(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
@@ -176,43 +176,49 @@ describe "Checkbox" do
|
|
176
176
|
|
177
177
|
describe "#clear" do
|
178
178
|
it "should raise ObjectDisabledException if the checkbox is disabled" do
|
179
|
-
@
|
180
|
-
lambda { @
|
181
|
-
lambda { @
|
179
|
+
@browser.checkbox(:id, "new_user_interests_dentistry").should_not be_set
|
180
|
+
lambda { @browser.checkbox(:id, "new_user_interests_dentistry").clear }.should raise_error(ObjectDisabledException)
|
181
|
+
lambda { @browser.checkbox(:xpath, "//input[@id='new_user_interests_dentistry']").clear }.should raise_error(ObjectDisabledException)
|
182
182
|
end
|
183
183
|
it "should clear the checkbox button if it is set" do
|
184
|
-
@
|
185
|
-
@
|
184
|
+
@browser.checkbox(:id, "new_user_interests_books").clear
|
185
|
+
@browser.checkbox(:id, "new_user_interests_books").should_not be_set
|
186
186
|
end
|
187
187
|
it "should clear the checkbox button when found by :xpath" do
|
188
|
-
@
|
189
|
-
@
|
188
|
+
@browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").clear
|
189
|
+
@browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").should_not be_set
|
190
190
|
end
|
191
191
|
it "should raise UnknownObjectException if the checkbox button doesn't exist" do
|
192
|
-
lambda { @
|
193
|
-
lambda { @
|
192
|
+
lambda { @browser.checkbox(:name, "no_such_id").clear }.should raise_error(UnknownObjectException)
|
193
|
+
lambda { @browser.checkbox(:xpath, "//input[@id='no_such_id']").clear }.should raise_error(UnknownObjectException)
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
197
197
|
describe "#set" do
|
198
198
|
it "should set the checkbox button" do
|
199
|
-
@
|
200
|
-
@
|
199
|
+
@browser.checkbox(:id, "new_user_interests_cars").set
|
200
|
+
@browser.checkbox(:id, "new_user_interests_cars").should be_set
|
201
201
|
end
|
202
202
|
it "should set the checkbox button when found by :xpath" do
|
203
|
-
@
|
204
|
-
@
|
203
|
+
@browser.checkbox(:xpath, "//input[@id='new_user_interests_cars']").set
|
204
|
+
@browser.checkbox(:xpath, "//input[@id='new_user_interests_cars']").should be_set
|
205
205
|
end
|
206
206
|
|
207
|
-
it "should fire the onclick event"
|
207
|
+
it "should fire the onclick event" do
|
208
|
+
@browser.button(:id, "disabled_button").should be_disabled
|
209
|
+
@browser.checkbox(:id, "toggle_button_checkbox").set
|
210
|
+
@browser.button(:id, "disabled_button").should_not be_disabled
|
211
|
+
@browser.checkbox(:id, "toggle_button_checkbox").clear
|
212
|
+
@browser.button(:id, "disabled_button").should be_disabled
|
213
|
+
end
|
208
214
|
|
209
215
|
it "should raise UnknownObjectException if the checkbox button doesn't exist" do
|
210
|
-
lambda { @
|
211
|
-
lambda { @
|
216
|
+
lambda { @browser.checkbox(:name, "no_such_name").set }.should raise_error(UnknownObjectException)
|
217
|
+
lambda { @browser.checkbox(:xpath, "//input[@name='no_such_name']").set }.should raise_error(UnknownObjectException)
|
212
218
|
end
|
213
219
|
it "should raise ObjectDisabledException if the checkbox is disabled" do
|
214
|
-
lambda { @
|
215
|
-
lambda { @
|
220
|
+
lambda { @browser.checkbox(:id, "new_user_interests_dentistry").set }.should raise_error(ObjectDisabledException)
|
221
|
+
lambda { @browser.checkbox(:xpath, "//input[@id='new_user_interests_dentistry']").set }.should raise_error(ObjectDisabledException )
|
216
222
|
end
|
217
223
|
end
|
218
224
|
|
@@ -221,39 +227,39 @@ describe "Checkbox" do
|
|
221
227
|
|
222
228
|
describe '#set?' do
|
223
229
|
it "should return true if the checkbox button is set" do
|
224
|
-
@
|
230
|
+
@browser.checkbox(:id, "new_user_interests_books").should be_set
|
225
231
|
end
|
226
232
|
it "should return false if the checkbox button unset" do
|
227
|
-
@
|
233
|
+
@browser.checkbox(:id, "new_user_interests_cars").should_not be_set
|
228
234
|
end
|
229
235
|
it "should return the state for checkboxs with string values" do
|
230
|
-
@
|
231
|
-
@
|
232
|
-
@
|
233
|
-
@
|
234
|
-
@
|
236
|
+
@browser.checkbox(:name, "new_user_interests", 'cars').should_not be_set
|
237
|
+
@browser.checkbox(:name, "new_user_interests", 'cars').set
|
238
|
+
@browser.checkbox(:name, "new_user_interests", 'cars').should be_set
|
239
|
+
@browser.checkbox(:name, "new_user_interests", 'cars').clear
|
240
|
+
@browser.checkbox(:name, "new_user_interests", 'cars').should_not be_set
|
235
241
|
end
|
236
242
|
it "should raise UnknownObjectException if the checkbox button doesn't exist" do
|
237
|
-
lambda { @
|
238
|
-
lambda { @
|
243
|
+
lambda { @browser.checkbox(:id, "no_such_id").set? }.should raise_error(UnknownObjectException)
|
244
|
+
lambda { @browser.checkbox(:xpath, "//input[@id='no_such_id']").set? }.should raise_error(UnknownObjectException)
|
239
245
|
end
|
240
246
|
end
|
241
247
|
|
242
248
|
describe "#get_state" do
|
243
249
|
it "should return true if the checkbox is set" do
|
244
|
-
@
|
250
|
+
@browser.checkbox(:id, "new_user_interests_books").get_state.should be_true
|
245
251
|
end
|
246
252
|
it "should return false if the checkbox is unset" do
|
247
|
-
@
|
253
|
+
@browser.checkbox(:id, "new_user_interests_cars").get_state.should be_false
|
248
254
|
end
|
249
255
|
it "should raise UnknownObjectException if the checkbox doesn't exist" do
|
250
|
-
lambda { @
|
251
|
-
lambda { @
|
256
|
+
lambda { @browser.checkbox(:name, "no_such_name").get_state }.should raise_error(UnknownObjectException)
|
257
|
+
lambda { @browser.checkbox(:xpath, "//input[@name='no_such_name']").get_state }.should raise_error(UnknownObjectException)
|
252
258
|
end
|
253
259
|
end
|
254
260
|
|
255
261
|
after :all do
|
256
|
-
@
|
262
|
+
@browser.close
|
257
263
|
end
|
258
264
|
end
|
259
265
|
|
data/spec/checkboxes_spec.rb
CHANGED
@@ -2,38 +2,38 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe "CheckBoxes" do
|
4
4
|
before :all do
|
5
|
-
@
|
6
|
-
add_spec_checker(@
|
5
|
+
@browser = IE.new
|
6
|
+
add_spec_checker(@browser)
|
7
7
|
end
|
8
8
|
|
9
9
|
before :each do
|
10
|
-
@
|
10
|
+
@browser.goto(TEST_HOST + "/forms_with_input_elements.html")
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "#length" do
|
14
14
|
it "should return the number of checkboxes" do
|
15
|
-
@
|
15
|
+
@browser.checkboxes.length.should == 7
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#[]" do
|
20
20
|
it "should return the checkbox at the given index" do
|
21
|
-
@
|
21
|
+
@browser.checkboxes[1].id.should == "new_user_interests_books"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe "#each" do
|
26
26
|
it "should iterate through checkboxes correctly" do
|
27
|
-
@
|
28
|
-
c.name.should == @
|
29
|
-
c.id.should == @
|
30
|
-
c.value.should == @
|
27
|
+
@browser.checkboxes.each_with_index do |c, index|
|
28
|
+
c.name.should == @browser.checkbox(:index, index+1).name
|
29
|
+
c.id.should == @browser.checkbox(:index, index+1).id
|
30
|
+
c.value.should == @browser.checkbox(:index, index+1).value
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
after :all do
|
36
|
-
@
|
36
|
+
@browser.close
|
37
37
|
end
|
38
38
|
|
39
39
|
end
|