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/radios_spec.rb
CHANGED
@@ -3,41 +3,41 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
3
3
|
describe "Radios" 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 radios" do
|
16
|
-
@
|
16
|
+
@browser.radios.length.should == 5
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
describe "#[]" do
|
21
21
|
it "should return the radio button at the given index" do
|
22
|
-
@
|
22
|
+
@browser.radios[1].id.should == "new_user_newsletter_yes"
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "#each" do
|
27
27
|
it "should iterate through radio buttons correctly" do
|
28
28
|
index = 1
|
29
|
-
@
|
30
|
-
r.name.should == @
|
31
|
-
r.id.should == @
|
32
|
-
r.value.should == @
|
29
|
+
@browser.radios.each do |r|
|
30
|
+
r.name.should == @browser.radio(:index, index).name
|
31
|
+
r.id.should == @browser.radio(:index, index).id
|
32
|
+
r.value.should == @browser.radio(:index, index).value
|
33
33
|
index += 1
|
34
34
|
end
|
35
|
-
@
|
35
|
+
@browser.radios.length.should == index - 1
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
after :all do
|
40
|
-
@
|
40
|
+
@browser.close
|
41
41
|
end
|
42
42
|
|
43
43
|
end
|
data/spec/select_list_spec.rb
CHANGED
@@ -2,12 +2,12 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe "SelectList" do
|
4
4
|
before :all do
|
5
|
-
@
|
6
|
-
add_spec_checker(@
|
5
|
+
@browser = Celerity::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
|
|
@@ -15,44 +15,44 @@ describe "SelectList" do
|
|
15
15
|
|
16
16
|
describe "#exists?" do
|
17
17
|
it "should return true if the select list exists" do
|
18
|
-
@
|
19
|
-
@
|
20
|
-
@
|
21
|
-
@
|
18
|
+
@browser.select_list(:id, 'new_user_country').should exist
|
19
|
+
@browser.select_list(:id, /new_user_country/).should exist
|
20
|
+
@browser.select_list(:name, 'new_user_country').should exist
|
21
|
+
@browser.select_list(:name, /new_user_country/).should exist
|
22
22
|
|
23
23
|
# check behaviour in Watir
|
24
|
-
# @
|
25
|
-
# @
|
24
|
+
# @browser.select_list(:value, 'Norway').should exist
|
25
|
+
# @browser.select_list(:value, /Norway/).should exist
|
26
26
|
|
27
27
|
# not sure what :text is for input elements
|
28
|
-
# @
|
29
|
-
# @
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
28
|
+
# @browser.select_list(:text, 'Norway').should exist
|
29
|
+
# @browser.select_list(:text, /Norway/).should exist
|
30
|
+
@browser.select_list(:class, 'country').should exist
|
31
|
+
@browser.select_list(:class, /country/).should exist
|
32
|
+
@browser.select_list(:index, 1).should exist
|
33
|
+
@browser.select_list(:xpath, "//select[@id='new_user_country']").should exist
|
34
34
|
end
|
35
35
|
it "should return false if the select list doesn't exist" do
|
36
|
-
@
|
37
|
-
@
|
38
|
-
@
|
39
|
-
@
|
40
|
-
@
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@
|
44
|
-
@
|
45
|
-
@
|
46
|
-
@
|
47
|
-
@
|
36
|
+
@browser.select_list(:id, 'no_such_id').should_not exist
|
37
|
+
@browser.select_list(:id, /no_such_id/).should_not exist
|
38
|
+
@browser.select_list(:name, 'no_such_name').should_not exist
|
39
|
+
@browser.select_list(:name, /no_such_name/).should_not exist
|
40
|
+
@browser.select_list(:value, 'no_such_value').should_not exist
|
41
|
+
@browser.select_list(:value, /no_such_value/).should_not exist
|
42
|
+
@browser.select_list(:text, 'no_such_text').should_not exist
|
43
|
+
@browser.select_list(:text, /no_such_text/).should_not exist
|
44
|
+
@browser.select_list(:class, 'no_such_class').should_not exist
|
45
|
+
@browser.select_list(:class, /no_such_class/).should_not exist
|
46
|
+
@browser.select_list(:index, 1337).should_not exist
|
47
|
+
@browser.select_list(:xpath, "//select[@id='no_such_id']").should_not exist
|
48
48
|
end
|
49
49
|
|
50
|
-
it "should raise ArgumentError when what argument is invalid" do
|
51
|
-
lambda { @
|
50
|
+
it "should raise ArgumentError when 'what' argument is invalid" do
|
51
|
+
lambda { @browser.select_list(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
52
52
|
end
|
53
53
|
|
54
|
-
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
55
|
-
lambda { @
|
54
|
+
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
55
|
+
lambda { @browser.select_list(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -61,53 +61,49 @@ describe "SelectList" do
|
|
61
61
|
|
62
62
|
describe "#class_name" do
|
63
63
|
it "should return the class name of the select list" do
|
64
|
-
@
|
64
|
+
@browser.select_list(:name, 'new_user_country').class_name.should == 'country'
|
65
65
|
end
|
66
66
|
it "should raise UnknownObjectException if the select list doesn't exist" do
|
67
|
-
lambda { @
|
67
|
+
lambda { @browser.select_list(:name, 'no_such_name').class_name }.should raise_error(UnknownObjectException)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
describe "#id" do
|
72
72
|
it "should return the id of the element" do
|
73
|
-
@
|
73
|
+
@browser.select_list(:index, 1).id.should == "new_user_country"
|
74
74
|
end
|
75
75
|
it "should raise UnknownObjectException if the select list doesn't exist" do
|
76
|
-
lambda { @
|
76
|
+
lambda { @browser.select_list(:index, 1337).id }.should raise_error(UnknownObjectException)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
80
|
describe "#name" do
|
81
81
|
it "should return the name of the element" do
|
82
|
-
@
|
82
|
+
@browser.select_list(:index, 1).name.should == "new_user_country"
|
83
83
|
end
|
84
84
|
it "should raise UnknownObjectException if the select list doesn't exist" do
|
85
|
-
lambda { @
|
85
|
+
lambda { @browser.select_list(:index, 1337).name }.should raise_error(UnknownObjectException)
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
89
|
-
it "should should raise UnknownObjectException when the select list does not exist" do
|
90
|
-
lambda { @ie.select_list(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
|
91
|
-
end
|
92
|
-
|
93
89
|
describe "#type" do
|
94
90
|
it "should return the type of the element" do
|
95
|
-
@
|
96
|
-
@
|
91
|
+
@browser.select_list(:index, 1).type.should == "select-one"
|
92
|
+
@browser.select_list(:index, 2).type.should == "select-multiple"
|
97
93
|
end
|
98
94
|
it "should raise UnknownObjectException if the select list doesn't exist" do
|
99
|
-
lambda { @
|
95
|
+
lambda { @browser.select_list(:index, 1337).type }.should raise_error(UnknownObjectException)
|
100
96
|
end
|
101
97
|
end
|
102
98
|
|
103
99
|
describe "#value" do
|
104
100
|
it "should return the value of the selected option" do
|
105
|
-
@
|
106
|
-
@
|
107
|
-
@
|
101
|
+
@browser.select_list(:index, 1).value.should == "Norway"
|
102
|
+
@browser.select_list(:index, 1).select(/Sweden/)
|
103
|
+
@browser.select_list(:index, 1).value.should == "Sweden"
|
108
104
|
end
|
109
105
|
it "should raise UnknownObjectException if the select list doesn't exist" do
|
110
|
-
lambda { @
|
106
|
+
lambda { @browser.select_list(:index, 1337).value }.should raise_error(UnknownObjectException)
|
111
107
|
end
|
112
108
|
end
|
113
109
|
|
@@ -116,22 +112,26 @@ describe "SelectList" do
|
|
116
112
|
|
117
113
|
describe "#enabled?" do
|
118
114
|
it "should return true if the select list is enabled" do
|
119
|
-
@
|
115
|
+
@browser.select_list(:name, 'new_user_country').should be_enabled
|
120
116
|
end
|
121
117
|
it "should return false if the select list is disabled" do
|
122
|
-
@
|
118
|
+
@browser.select_list(:name, 'new_user_role').should_not be_enabled
|
123
119
|
end
|
124
120
|
it "should raise UnknownObjectException if the select_list doesn't exist" do
|
125
|
-
lambda { @
|
121
|
+
lambda { @browser.select_list(:name, 'no_such_name').enabled? }.should raise_error(UnknownObjectException)
|
126
122
|
end
|
127
123
|
end
|
128
124
|
|
129
125
|
describe "#disabled?" do
|
130
126
|
it "should return true if the select list is disabled" do
|
131
|
-
@
|
127
|
+
@browser.select_list(:index, 3).should be_disabled
|
132
128
|
end
|
133
129
|
it "should return false if the select list is enabled" do
|
134
|
-
@
|
130
|
+
@browser.select_list(:index, 1).should_not be_disabled
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should should raise UnknownObjectException when the select list does not exist" do
|
134
|
+
lambda { @browser.select_list(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
@@ -140,146 +140,158 @@ describe "SelectList" do
|
|
140
140
|
|
141
141
|
describe "#option" do
|
142
142
|
it "should return an instance of Option" do
|
143
|
-
@
|
143
|
+
@browser.select_list(:name, "new_user_country").option(:text, "Denmark").should be_instance_of(Celerity::Option)
|
144
144
|
end
|
145
145
|
|
146
146
|
# do we need a seperate spec for this object?
|
147
147
|
it "should should be able to select the chosen option" do
|
148
|
-
@
|
149
|
-
@
|
150
|
-
@
|
148
|
+
@browser.select_list(:name , "new_user_country").clear_selection
|
149
|
+
@browser.select_list(:name , "new_user_country").option(:text, "Denmark").select
|
150
|
+
@browser.select_list(:name, "new_user_country").get_selected_items.should == ["Denmark"]
|
151
151
|
end
|
152
152
|
|
153
153
|
it "should select the option when found by text" do
|
154
|
-
@
|
155
|
-
@
|
154
|
+
@browser.select_list(:name, 'new_user_country').option(:text, 'Sweden').select
|
155
|
+
@browser.select_list(:name, 'new_user_country').option(:text, 'Sweden').should be_selected
|
156
156
|
end
|
157
157
|
|
158
158
|
it "should raise UnknownObjectException if the option does not exist" do
|
159
|
-
lambda { @
|
160
|
-
lambda { @
|
159
|
+
lambda { @browser.select_list(:name, "new_user_country").option(:text, "no_such_text").select }.should raise_error(UnknownObjectException)
|
160
|
+
lambda { @browser.select_list(:name, "new_user_country").option(:text, /missing/).select }.should raise_error(UnknownObjectException)
|
161
161
|
end
|
162
162
|
|
163
163
|
it "should raise MissingWayOfFindingObjectException when given a bad 'how'" do
|
164
|
-
lambda { @
|
164
|
+
lambda { @browser.select_list(:name, "new_user_country").option(:missing, "Denmark").select }.should raise_error(MissingWayOfFindingObjectException)
|
165
165
|
end
|
166
166
|
|
167
167
|
it "should be able to get attributes" do
|
168
|
-
@
|
169
|
-
lambda { @ie.select_list(:name, "new_user_country").option(:text, "no_such_text").class_name }.should raise_error(UnknownObjectException)
|
168
|
+
@browser.select_list(:name, "new_user_country").option(:text , 'Sweden').class_name.should == "scandinavia"
|
170
169
|
end
|
171
170
|
end
|
172
171
|
|
173
172
|
describe "#get_all_contents" do
|
174
173
|
it "should should raise UnknownObjectException if the select list doesn't exist" do
|
175
|
-
lambda { @
|
174
|
+
lambda { @browser.select_list(:name, 'no_such_name').get_all_contents }.should raise_error(UnknownObjectException)
|
176
175
|
end
|
177
176
|
it "should return all the options as an Array" do
|
178
|
-
@
|
177
|
+
@browser.select_list(:name, "new_user_country").get_all_contents.should == ["Denmark" ,"Norway" , "Sweden" , "United Kingdom", "USA"]
|
179
178
|
end
|
180
179
|
end
|
181
180
|
|
182
181
|
describe "#get_selected_items" do
|
183
182
|
it "should should raise UnknownObjectException if the select list doesn't exist" do
|
184
|
-
lambda { @
|
183
|
+
lambda { @browser.select_list(:name, 'no_such_name').get_selected_items }.should raise_error(UnknownObjectException)
|
185
184
|
end
|
186
185
|
|
187
186
|
it "should get the currently selected item(s)" do
|
188
|
-
@
|
189
|
-
@
|
187
|
+
@browser.select_list(:name, "new_user_country").get_selected_items.should == ["Norway"]
|
188
|
+
@browser.select_list(:name, "new_user_languages").get_selected_items.should == ["English", "Norwegian"]
|
190
189
|
end
|
191
190
|
end
|
192
191
|
|
193
192
|
describe "#clear_selection" do
|
194
193
|
it "should clear the selection when possible" do
|
195
|
-
@
|
196
|
-
@
|
194
|
+
@browser.select_list(:name, "new_user_languages").clear_selection
|
195
|
+
@browser.select_list(:name, "new_user_languages").get_selected_items.should be_empty
|
197
196
|
end
|
198
197
|
it "should not clear selections when not possible" do
|
199
|
-
@
|
200
|
-
@
|
198
|
+
@browser.select_list(:name , "new_user_country").clear_selection
|
199
|
+
@browser.select_list(:name, "new_user_country").get_selected_items.should == ["Norway"]
|
201
200
|
end
|
202
201
|
it "should should raise UnknownObjectException if the select list doesn't exist" do
|
203
|
-
lambda { @
|
202
|
+
lambda { @browser.select_list(:name, 'no_such_name').clear_selection }.should raise_error(UnknownObjectException)
|
204
203
|
end
|
205
204
|
end
|
206
205
|
|
207
206
|
describe "#includes?" do
|
208
207
|
it "should return true if the given option exists" do
|
209
|
-
@
|
208
|
+
@browser.select_list(:name, 'new_user_country').includes?('Denmark').should be_true
|
210
209
|
end
|
211
210
|
it "should return false if the given option doesn't exist" do
|
212
|
-
@
|
211
|
+
@browser.select_list(:name, 'new_user_country').includes?('Ireland').should be_false
|
213
212
|
end
|
214
213
|
end
|
215
214
|
|
216
215
|
describe "#selected?" do
|
217
216
|
it "should return true if the given option is selected" do
|
218
|
-
@
|
219
|
-
@
|
217
|
+
@browser.select_list(:name, 'new_user_country').select('Denmark')
|
218
|
+
@browser.select_list(:name, 'new_user_country').selected?('Denmark').should be_true
|
220
219
|
end
|
221
220
|
it "should return false if the given option is not selected" do
|
222
|
-
@
|
221
|
+
@browser.select_list(:name, 'new_user_country').selected?('Sweden').should be_false
|
223
222
|
end
|
224
223
|
it "should raise UnknonwObjectException if the option doesn't exist" do
|
225
|
-
lambda { @
|
224
|
+
lambda { @browser.select_list(:name, 'new_user_country').selected?('missing_option') }.should raise_error(UnknownObjectException)
|
226
225
|
end
|
227
226
|
end
|
228
227
|
|
229
228
|
describe "#select" do
|
230
229
|
it "should select the given item when given a String" do
|
231
|
-
@
|
232
|
-
@
|
230
|
+
@browser.select_list(:name, "new_user_country").select("Denmark")
|
231
|
+
@browser.select_list(:name, "new_user_country").get_selected_items.should == ["Denmark"]
|
233
232
|
end
|
234
233
|
it "should select the given item when given a Regexp" do
|
235
|
-
@
|
236
|
-
@
|
234
|
+
@browser.select_list(:name, "new_user_country").select(/Denmark/)
|
235
|
+
@browser.select_list(:name, "new_user_country").get_selected_items.should == ["Denmark"]
|
237
236
|
end
|
238
237
|
it "should select the given item when given an Xpath" do
|
239
|
-
@
|
240
|
-
@
|
238
|
+
@browser.select_list(:xpath, "//select[@name='new_user_country']").select("Denmark")
|
239
|
+
@browser.select_list(:xpath, "//select[@name='new_user_country']").get_selected_items.should == ["Denmark"]
|
241
240
|
end
|
242
241
|
it "should be able to select multiple items using :name and a String" do
|
243
|
-
@
|
244
|
-
@
|
245
|
-
@
|
246
|
-
@
|
242
|
+
@browser.select_list(:name, "new_user_languages").clear_selection
|
243
|
+
@browser.select_list(:name, "new_user_languages").select("Danish")
|
244
|
+
@browser.select_list(:name, "new_user_languages").select("Swedish")
|
245
|
+
@browser.select_list(:name, "new_user_languages").get_selected_items.should == ["Danish", "Swedish"]
|
247
246
|
end
|
248
247
|
it "should be able to select multiple items using :name and a Regexp" do
|
249
|
-
@
|
250
|
-
@
|
251
|
-
@
|
248
|
+
@browser.select_list(:name, "new_user_languages").clear_selection
|
249
|
+
@browser.select_list(:name, "new_user_languages").select(/ish/)
|
250
|
+
@browser.select_list(:name, "new_user_languages").get_selected_items.should == ["Danish", "English", "Swedish"]
|
252
251
|
end
|
253
252
|
it "should be able to select multiple items using :xpath" do
|
254
|
-
@
|
255
|
-
@
|
256
|
-
@
|
253
|
+
@browser.select_list(:xpath, "//select[@name='new_user_languages']").clear_selection
|
254
|
+
@browser.select_list(:xpath, "//select[@name='new_user_languages']").select( /ish/ )
|
255
|
+
@browser.select_list(:xpath, "//select[@name='new_user_languages']").get_selected_items.should == ["Danish", "English", "Swedish"]
|
257
256
|
end
|
258
257
|
|
259
|
-
it "should fire onchange event when selecting an item"
|
258
|
+
it "should fire onchange event when selecting an item" do
|
259
|
+
@browser.div(:id, "changed_language").text.should be_empty
|
260
|
+
@browser.select_list(:id, "new_user_languages").select("Danish")
|
261
|
+
@browser.div(:id, "changed_language").text.should == "changed language"
|
262
|
+
@browser.refresh # to reset js
|
263
|
+
end
|
264
|
+
|
265
|
+
it "should not fire onchange event when selecting an already selected item" do
|
266
|
+
@browser.select_list(:id, "new_user_languages").clear_selection # removes two options
|
267
|
+
@browser.div(:id, "changed_language").text.should == "changed languagechanged language"
|
268
|
+
@browser.select_list(:id, "new_user_languages").select("English")
|
269
|
+
@browser.div(:id, "changed_language").text.should == "changed languagechanged languagechanged language"
|
260
270
|
|
261
|
-
|
271
|
+
@browser.select_list(:id, "new_user_languages").select("English")
|
272
|
+
@browser.div(:id, "changed_language").text.should == "changed languagechanged languagechanged language"
|
273
|
+
end
|
262
274
|
|
263
275
|
it "should raise NoValueFoundException if the option doesn't exist" do
|
264
|
-
lambda { @
|
265
|
-
lambda { @
|
276
|
+
lambda { @browser.select_list(:name, "new_user_country").select("missing_option") }.should raise_error(NoValueFoundException)
|
277
|
+
lambda { @browser.select_list(:name, "new_user_country").select(/missing_option/) }.should raise_error(NoValueFoundException)
|
266
278
|
end
|
267
279
|
end
|
268
280
|
|
269
281
|
describe "#select_value" do
|
270
282
|
it "should select the given item" do
|
271
|
-
@
|
272
|
-
@
|
273
|
-
@
|
283
|
+
@browser.select_list(:name, "new_user_languages").clear_selection
|
284
|
+
@browser.select_list(:name, "new_user_languages").select("Swedish")
|
285
|
+
@browser.select_list(:name, "new_user_languages").get_selected_items.should == ["Swedish"]
|
274
286
|
end
|
275
287
|
it "should raise NoValueFoundException if the option doesn't exist" do
|
276
|
-
lambda { @
|
277
|
-
lambda { @
|
288
|
+
lambda { @browser.select_list(:name, "new_user_languages").select_value("no_such_option") }.should raise_error(NoValueFoundException)
|
289
|
+
lambda { @browser.select_list(:name, "new_user_languages").select_value(/no_such_option/) }.should raise_error(NoValueFoundException)
|
278
290
|
end
|
279
291
|
end
|
280
292
|
|
281
293
|
after :all do
|
282
|
-
@
|
294
|
+
@browser.close
|
283
295
|
end
|
284
296
|
|
285
297
|
end
|
data/spec/select_lists_spec.rb
CHANGED
@@ -2,45 +2,45 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
2
|
|
3
3
|
describe "SelectLists" do
|
4
4
|
before :all do
|
5
|
-
@
|
6
|
-
add_spec_checker(@
|
5
|
+
@browser = Celerity::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 correct number of select lists on the page" do
|
15
|
-
@
|
15
|
+
@browser.select_lists.length.should == 4
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "#[]" do
|
20
20
|
it "should return the correct item" do
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
24
|
-
@
|
21
|
+
@browser.select_lists[1].value.should == "Norway"
|
22
|
+
@browser.select_lists[1].name.should == "new_user_country"
|
23
|
+
@browser.select_lists[1].type.should == "select-one"
|
24
|
+
@browser.select_lists[2].type.should == "select-multiple"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "#each" do
|
29
29
|
it "should iterate through the select lists correctly" do
|
30
30
|
index=1
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
34
|
-
@
|
35
|
-
@
|
31
|
+
@browser.select_lists.each do |l|
|
32
|
+
@browser.select_list(:index, index).name.should == l.name
|
33
|
+
@browser.select_list(:index, index).id.should == l.id
|
34
|
+
@browser.select_list(:index, index).type.should == l.type
|
35
|
+
@browser.select_list(:index, index).value.should == l.value
|
36
36
|
index += 1
|
37
37
|
end
|
38
|
-
(index - 1).should == @
|
38
|
+
(index - 1).should == @browser.select_lists.length
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
after :all do
|
43
|
-
@
|
43
|
+
@browser.close
|
44
44
|
end
|
45
45
|
|
46
46
|
end
|