celerity 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +14 -0
- data/Manifest.txt +127 -151
- data/README.txt +15 -20
- data/lib/celerity.rb +13 -5
- data/lib/celerity/browser.rb +296 -0
- data/lib/celerity/clickable_element.rb +1 -0
- data/lib/celerity/collections.rb +4 -0
- data/lib/celerity/container.rb +69 -2
- data/lib/celerity/disabled_element.rb +1 -0
- data/lib/celerity/element.rb +103 -38
- data/lib/celerity/element_collections.rb +14 -8
- data/lib/celerity/element_locator.rb +61 -50
- data/lib/celerity/element_map.rb +51 -0
- data/lib/celerity/elements/button.rb +1 -0
- data/lib/celerity/elements/file_field.rb +3 -2
- data/lib/celerity/elements/form.rb +1 -0
- data/lib/celerity/elements/frame.rb +16 -1
- data/lib/celerity/elements/image.rb +15 -13
- data/lib/celerity/elements/link.rb +4 -1
- data/lib/celerity/elements/option.rb +1 -0
- data/lib/celerity/elements/radio_check.rb +19 -7
- data/lib/celerity/elements/select_list.rb +17 -2
- data/lib/celerity/elements/table.rb +34 -20
- data/lib/celerity/elements/table_body.rb +2 -2
- data/lib/celerity/elements/table_cell.rb +3 -1
- data/lib/celerity/elements/table_footer.rb +2 -2
- data/lib/celerity/elements/table_header.rb +2 -2
- data/lib/celerity/elements/table_row.rb +4 -2
- data/lib/celerity/elements/text_field.rb +20 -9
- data/lib/celerity/exception.rb +11 -18
- data/lib/celerity/extra/method_generator.rb +13 -8
- data/lib/celerity/htmlunit/download.sh +23 -0
- data/lib/celerity/htmlunit/htmlunit-2.2.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-core-js-2.2.jar +0 -0
- data/lib/celerity/htmlunit/{nekohtml-1.9.7.jar → nekohtml-1.9.8.jar} +0 -0
- data/lib/celerity/input_element.rb +1 -1
- data/lib/celerity/version.rb +1 -1
- data/lib/celerity/watir_compatibility.rb +37 -23
- data/spec/area_spec.rb +19 -4
- data/spec/areas_spec.rb +2 -3
- data/spec/{ie_spec.rb → browser_spec.rb} +66 -15
- data/spec/button_spec.rb +36 -3
- data/spec/buttons_spec.rb +2 -3
- data/spec/checkbox_spec.rb +43 -8
- data/spec/checkboxes_spec.rb +2 -3
- data/spec/div_spec.rb +31 -4
- data/spec/divs_spec.rb +2 -3
- data/spec/element_spec.rb +36 -6
- data/spec/filefield_spec.rb +28 -13
- data/spec/filefields_spec.rb +2 -3
- data/spec/form_spec.rb +6 -3
- data/spec/forms_spec.rb +2 -3
- data/spec/frame_spec.rb +14 -5
- data/spec/frames_spec.rb +71 -0
- data/spec/hidden_spec.rb +21 -3
- data/spec/hiddens_spec.rb +2 -3
- data/spec/hn_spec.rb +30 -12
- data/spec/hns_spec.rb +14 -10
- data/spec/html/form_js_bug.html +11 -0
- data/spec/html/forms_with_input_elements.html +2 -1
- data/spec/html/invalid_js.html +11 -0
- data/spec/html/latin1_text.html +1 -0
- data/spec/html/non_control_elements.html +8 -4
- data/spec/html/simple_ajax.html +22 -0
- data/spec/htmlunit_spec.rb +4 -5
- data/spec/image_spec.rb +33 -3
- data/spec/images_spec.rb +2 -3
- data/spec/label_spec.rb +16 -3
- data/spec/labels_spec.rb +2 -3
- data/spec/li_spec.rb +25 -3
- data/spec/link_spec.rb +35 -3
- data/spec/links_spec.rb +2 -3
- data/spec/lis_spec.rb +2 -3
- data/spec/map_spec.rb +19 -3
- data/spec/maps_spec.rb +2 -3
- data/spec/meta_spec.rb +3 -1
- data/spec/ol_spec.rb +17 -3
- data/spec/ols_spec.rb +2 -3
- data/spec/option_spec.rb +28 -3
- data/spec/p_spec.rb +30 -2
- data/spec/pre_spec.rb +25 -3
- data/spec/pres_spec.rb +2 -3
- data/spec/ps_spec.rb +2 -3
- data/spec/radio_spec.rb +47 -3
- data/spec/radios_spec.rb +2 -3
- data/spec/select_list_spec.rb +42 -3
- data/spec/select_lists_spec.rb +2 -3
- data/spec/span_spec.rb +32 -7
- data/spec/spans_spec.rb +2 -4
- data/spec/spec_helper.rb +5 -25
- data/spec/table_bodies_spec.rb +7 -5
- data/spec/table_body_spec.rb +11 -4
- data/spec/table_cell_spec.rb +15 -4
- data/spec/table_cells_spec.rb +3 -4
- data/spec/table_footer_spec.rb +11 -4
- data/spec/table_footers_spec.rb +7 -5
- data/spec/table_header_spec.rb +11 -4
- data/spec/table_headers_spec.rb +7 -5
- data/spec/table_row_spec.rb +31 -7
- data/spec/table_rows_spec.rb +5 -4
- data/spec/table_spec.rb +36 -7
- data/spec/tables_spec.rb +2 -3
- data/spec/text_field_spec.rb +51 -13
- data/spec/text_fields_spec.rb +2 -3
- data/spec/ul_spec.rb +18 -3
- data/spec/uls_spec.rb +2 -3
- data/spec/{watir_compatability_spec.rb → watir_compatibility_spec.rb} +42 -35
- data/support/spec_server.rb +9 -0
- metadata +167 -161
- metadata.gz.sig +0 -0
- data/benchmark/bm_2000_spans.rb +0 -48
- data/benchmark/bm_digg.rb +0 -26
- data/benchmark/bm_google_images.rb +0 -36
- data/benchmark/bm_input_locator.rb +0 -69
- data/benchmark/loader.rb +0 -9
- data/config/hoe.rb +0 -68
- data/config/requirements.rb +0 -15
- data/lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/js-1.7R1.jar +0 -0
- data/lib/celerity/ie.rb +0 -195
- data/setup.rb +0 -1583
- data/support/celerity_viewer/rubycocoa/CelerityViewer.icns +0 -0
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/classes.nib +0 -37
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/info.nib +0 -19
- data/support/celerity_viewer/rubycocoa/English.lproj/Main.nib/keyedobjects.nib +0 -0
- data/support/celerity_viewer/rubycocoa/Info.plist.erb +0 -28
- data/support/celerity_viewer/rubycocoa/MainController.rb +0 -23
- data/support/celerity_viewer/rubycocoa/README +0 -94
- data/support/celerity_viewer/rubycocoa/Rakefile +0 -100
- data/support/celerity_viewer/rubycocoa/distributed_viewer.rb +0 -86
- data/support/celerity_viewer/rubycocoa/main.m +0 -7
- data/support/celerity_viewer/rubycocoa/main.rb +0 -27
- data/tasks/benchmark.rake +0 -4
- data/tasks/environment.rake +0 -7
- data/tasks/simple_ci.rake +0 -94
data/spec/buttons_spec.rb
CHANGED
data/spec/checkbox_spec.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe CheckBox do
|
3
|
+
describe "CheckBox" do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@browser =
|
7
|
-
add_spec_checker(@browser)
|
6
|
+
@browser = Browser.new
|
8
7
|
end
|
9
8
|
|
10
9
|
before :each do
|
@@ -30,14 +29,16 @@ describe CheckBox do
|
|
30
29
|
@browser.checkbox(:index, 1).should exist
|
31
30
|
@browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").should exist
|
32
31
|
end
|
32
|
+
|
33
33
|
it "should return true if the element exists (default how = :name)" do
|
34
34
|
@browser.checkbox("new_user_interests").should exist
|
35
35
|
end
|
36
|
+
|
36
37
|
it "should return true if the checkbox button exists (search by name and value)" do
|
37
38
|
@browser.checkbox(:name, "new_user_interests", 'cars').should exist
|
38
39
|
@browser.checkbox(:xpath, "//input[@name='new_user_interests' and @value='cars']").set
|
39
40
|
end
|
40
|
-
|
41
|
+
|
41
42
|
it "should return false if the checkbox button does not exist" do
|
42
43
|
@browser.checkbox(:id, "no_such_id").should_not exist
|
43
44
|
@browser.checkbox(:id, /no_such_id/).should_not exist
|
@@ -52,19 +53,19 @@ describe CheckBox do
|
|
52
53
|
@browser.checkbox(:index, 1337).should_not exist
|
53
54
|
@browser.checkbox(:xpath, "//input[@id='no_such_id']").should_not exist
|
54
55
|
end
|
55
|
-
|
56
|
+
|
56
57
|
it "should return false if the checkbox button does not exist (search by name and value)" do
|
57
58
|
@browser.checkbox(:name, "new_user_interests", 'no_such_value').should_not exist
|
58
59
|
@browser.checkbox(:xpath, "//input[@name='new_user_interests' and @value='no_such_value']").should_not exist
|
59
60
|
@browser.checkbox(:name, "no_such_name", 'cars').should_not exist
|
60
61
|
@browser.checkbox(:xpath, "//input[@name='no_such_name' and @value='cars']").should_not exist
|
61
62
|
end
|
62
|
-
|
63
|
+
|
63
64
|
it "should return true for checkboxs with a string value" do
|
64
65
|
@browser.checkbox(:name, 'new_user_interests', 'books').should exist
|
65
66
|
@browser.checkbox(:name, 'new_user_interests', 'cars').should exist
|
66
67
|
end
|
67
|
-
|
68
|
+
|
68
69
|
it "should raise ArgumentError when 'what' argument is invalid" do
|
69
70
|
lambda { @browser.checkbox(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
70
71
|
end
|
@@ -81,9 +82,11 @@ describe CheckBox do
|
|
81
82
|
it "should return the class name if the checkbox exists and has an attribute" do
|
82
83
|
@browser.checkbox(:id, "new_user_interests_dancing").class_name.should == "fun"
|
83
84
|
end
|
85
|
+
|
84
86
|
it "should return an emptry string if the checkbox exists and the attribute doesn't" do
|
85
87
|
@browser.checkbox(:id, "new_user_interests_books").class_name.should == ""
|
86
88
|
end
|
89
|
+
|
87
90
|
it "should raise UnknownObjectException if the checkbox doesn't exist" do
|
88
91
|
lambda { @browser.checkbox(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
89
92
|
end
|
@@ -93,9 +96,11 @@ describe CheckBox do
|
|
93
96
|
it "should return the id attribute if the checkbox exists and has an attribute" do
|
94
97
|
@browser.checkbox(:index, 1).id.should == "new_user_interests_books"
|
95
98
|
end
|
99
|
+
|
96
100
|
it "should return an emptry string if the checkbox exists and the attribute doesn't" do
|
97
101
|
@browser.checkbox(:index, 2).id.should == ""
|
98
102
|
end
|
103
|
+
|
99
104
|
it "should raise UnknownObjectException if the checkbox doesn't exist" do
|
100
105
|
lambda { @browser.checkbox(:index, 1337).id }.should raise_error(UnknownObjectException)
|
101
106
|
end
|
@@ -105,9 +110,11 @@ describe CheckBox do
|
|
105
110
|
it "should return the name attribute if the checkbox exists" do
|
106
111
|
@browser.checkbox(:id, 'new_user_interests_books').name.should == "new_user_interests"
|
107
112
|
end
|
113
|
+
|
108
114
|
it "should return an empty string if the checkbox exists and the attribute doesn't" do
|
109
115
|
@browser.checkbox(:id, 'new_user_interests_food').name.should == ""
|
110
116
|
end
|
117
|
+
|
111
118
|
it "should raise UnknownObjectException if the checkbox doesn't exist" do
|
112
119
|
lambda { @browser.checkbox(:index, 1337).name }.should raise_error(UnknownObjectException)
|
113
120
|
end
|
@@ -117,9 +124,11 @@ describe CheckBox do
|
|
117
124
|
it "should return the title attribute if the checkbox exists" do
|
118
125
|
@browser.checkbox(:id, "new_user_interests_dancing").title.should == "Dancing is fun!"
|
119
126
|
end
|
127
|
+
|
120
128
|
it "should return an emptry string if the checkbox exists and the attribute doesn't" do
|
121
129
|
@browser.checkbox(:id, "new_user_interests_books").title.should == ""
|
122
130
|
end
|
131
|
+
|
123
132
|
it "should raise UnknownObjectException if the checkbox doesn't exist" do
|
124
133
|
lambda { @browser.checkbox(:index, 1337).title }.should raise_error(UnknownObjectException)
|
125
134
|
end
|
@@ -129,6 +138,7 @@ describe CheckBox do
|
|
129
138
|
it "should return the type attribute if the checkbox exists" do
|
130
139
|
@browser.checkbox(:index, 1).type.should == "checkbox"
|
131
140
|
end
|
141
|
+
|
132
142
|
it "should raise UnknownObjectException if the checkbox doesn't exist" do
|
133
143
|
lambda { @browser.checkbox(:index, 1337).type }.should raise_error(UnknownObjectException)
|
134
144
|
end
|
@@ -138,11 +148,22 @@ describe CheckBox do
|
|
138
148
|
it "should return the value attribute if the checkbox exists" do
|
139
149
|
@browser.checkbox(:id, 'new_user_interests_books').value.should == 'books'
|
140
150
|
end
|
151
|
+
|
141
152
|
it "should raise UnknownObjectException if the checkbox doesn't exist" do
|
142
153
|
lambda { @browser.checkbox(:index, 1337).value}.should raise_error(UnknownObjectException)
|
143
154
|
end
|
144
155
|
end
|
145
156
|
|
157
|
+
describe "#respond_to?" do
|
158
|
+
it "should return true for all attribute methods" do
|
159
|
+
@browser.checkbox(:index, 1).should respond_to(:class_name)
|
160
|
+
@browser.checkbox(:index, 1).should respond_to(:id)
|
161
|
+
@browser.checkbox(:index, 1).should respond_to(:name)
|
162
|
+
@browser.checkbox(:index, 1).should respond_to(:title)
|
163
|
+
@browser.checkbox(:index, 1).should respond_to(:type)
|
164
|
+
@browser.checkbox(:index, 1).should respond_to(:value)
|
165
|
+
end
|
166
|
+
end
|
146
167
|
|
147
168
|
# Access methods
|
148
169
|
|
@@ -151,10 +172,12 @@ describe CheckBox do
|
|
151
172
|
@browser.checkbox(:id, "new_user_interests_books").should be_enabled
|
152
173
|
@browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").should be_enabled
|
153
174
|
end
|
175
|
+
|
154
176
|
it "should return false if the checkbox button is disabled" do
|
155
177
|
@browser.checkbox(:id, "new_user_interests_dentistry").should_not be_enabled
|
156
178
|
@browser.checkbox(:xpath,"//input[@id='new_user_interests_dentistry']").should_not be_enabled
|
157
179
|
end
|
180
|
+
|
158
181
|
it "should raise UnknownObjectException if the checkbox button doesn't exist" do
|
159
182
|
lambda { @browser.checkbox(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
|
160
183
|
lambda { @browser.checkbox(:xpath, "//input[@id='no_such_id']").enabled? }.should raise_error(UnknownObjectException)
|
@@ -165,9 +188,11 @@ describe CheckBox do
|
|
165
188
|
it "should return true if the checkbox is disabled" do
|
166
189
|
@browser.checkbox(:id, 'new_user_interests_dentistry').should be_disabled
|
167
190
|
end
|
191
|
+
|
168
192
|
it "should return false if the checkbox is enabled" do
|
169
193
|
@browser.checkbox(:id, 'new_user_interests_books').should_not be_disabled
|
170
194
|
end
|
195
|
+
|
171
196
|
it "should raise UnknownObjectException if the checkbox doesn't exist" do
|
172
197
|
lambda { @browser.checkbox(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
|
173
198
|
end
|
@@ -182,14 +207,17 @@ describe CheckBox do
|
|
182
207
|
lambda { @browser.checkbox(:id, "new_user_interests_dentistry").clear }.should raise_error(ObjectDisabledException)
|
183
208
|
lambda { @browser.checkbox(:xpath, "//input[@id='new_user_interests_dentistry']").clear }.should raise_error(ObjectDisabledException)
|
184
209
|
end
|
210
|
+
|
185
211
|
it "should clear the checkbox button if it is set" do
|
186
212
|
@browser.checkbox(:id, "new_user_interests_books").clear
|
187
213
|
@browser.checkbox(:id, "new_user_interests_books").should_not be_set
|
188
214
|
end
|
215
|
+
|
189
216
|
it "should clear the checkbox button when found by :xpath" do
|
190
217
|
@browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").clear
|
191
218
|
@browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").should_not be_set
|
192
219
|
end
|
220
|
+
|
193
221
|
it "should raise UnknownObjectException if the checkbox button doesn't exist" do
|
194
222
|
lambda { @browser.checkbox(:name, "no_such_id").clear }.should raise_error(UnknownObjectException)
|
195
223
|
lambda { @browser.checkbox(:xpath, "//input[@id='no_such_id']").clear }.should raise_error(UnknownObjectException)
|
@@ -201,6 +229,7 @@ describe CheckBox do
|
|
201
229
|
@browser.checkbox(:id, "new_user_interests_cars").set
|
202
230
|
@browser.checkbox(:id, "new_user_interests_cars").should be_set
|
203
231
|
end
|
232
|
+
|
204
233
|
it "should set the checkbox button when found by :xpath" do
|
205
234
|
@browser.checkbox(:xpath, "//input[@id='new_user_interests_cars']").set
|
206
235
|
@browser.checkbox(:xpath, "//input[@id='new_user_interests_cars']").should be_set
|
@@ -213,11 +242,12 @@ describe CheckBox do
|
|
213
242
|
@browser.checkbox(:id, "toggle_button_checkbox").clear
|
214
243
|
@browser.button(:id, "disabled_button").should be_disabled
|
215
244
|
end
|
216
|
-
|
245
|
+
|
217
246
|
it "should raise UnknownObjectException if the checkbox button doesn't exist" do
|
218
247
|
lambda { @browser.checkbox(:name, "no_such_name").set }.should raise_error(UnknownObjectException)
|
219
248
|
lambda { @browser.checkbox(:xpath, "//input[@name='no_such_name']").set }.should raise_error(UnknownObjectException)
|
220
249
|
end
|
250
|
+
|
221
251
|
it "should raise ObjectDisabledException if the checkbox is disabled" do
|
222
252
|
lambda { @browser.checkbox(:id, "new_user_interests_dentistry").set }.should raise_error(ObjectDisabledException)
|
223
253
|
lambda { @browser.checkbox(:xpath, "//input[@id='new_user_interests_dentistry']").set }.should raise_error(ObjectDisabledException )
|
@@ -231,9 +261,11 @@ describe CheckBox do
|
|
231
261
|
it "should return true if the checkbox button is set" do
|
232
262
|
@browser.checkbox(:id, "new_user_interests_books").should be_set
|
233
263
|
end
|
264
|
+
|
234
265
|
it "should return false if the checkbox button unset" do
|
235
266
|
@browser.checkbox(:id, "new_user_interests_cars").should_not be_set
|
236
267
|
end
|
268
|
+
|
237
269
|
it "should return the state for checkboxs with string values" do
|
238
270
|
@browser.checkbox(:name, "new_user_interests", 'cars').should_not be_set
|
239
271
|
@browser.checkbox(:name, "new_user_interests", 'cars').set
|
@@ -241,6 +273,7 @@ describe CheckBox do
|
|
241
273
|
@browser.checkbox(:name, "new_user_interests", 'cars').clear
|
242
274
|
@browser.checkbox(:name, "new_user_interests", 'cars').should_not be_set
|
243
275
|
end
|
276
|
+
|
244
277
|
it "should raise UnknownObjectException if the checkbox button doesn't exist" do
|
245
278
|
lambda { @browser.checkbox(:id, "no_such_id").set? }.should raise_error(UnknownObjectException)
|
246
279
|
lambda { @browser.checkbox(:xpath, "//input[@id='no_such_id']").set? }.should raise_error(UnknownObjectException)
|
@@ -251,9 +284,11 @@ describe CheckBox do
|
|
251
284
|
it "should return true if the checkbox is set" do
|
252
285
|
@browser.checkbox(:id, "new_user_interests_books").get_state.should be_true
|
253
286
|
end
|
287
|
+
|
254
288
|
it "should return false if the checkbox is unset" do
|
255
289
|
@browser.checkbox(:id, "new_user_interests_cars").get_state.should be_false
|
256
290
|
end
|
291
|
+
|
257
292
|
it "should raise UnknownObjectException if the checkbox doesn't exist" do
|
258
293
|
lambda { @browser.checkbox(:name, "no_such_name").get_state }.should raise_error(UnknownObjectException)
|
259
294
|
lambda { @browser.checkbox(:xpath, "//input[@name='no_such_name']").get_state }.should raise_error(UnknownObjectException)
|
data/spec/checkboxes_spec.rb
CHANGED
data/spec/div_spec.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe Div do
|
3
|
+
describe "Div" do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@browser =
|
7
|
-
add_spec_checker(@browser)
|
6
|
+
@browser = Browser.new
|
8
7
|
end
|
9
8
|
|
10
9
|
before :each do
|
@@ -26,9 +25,11 @@ describe Div do
|
|
26
25
|
@browser.div(:index, 1).should exist
|
27
26
|
@browser.div(:xpath, "//div[@id='header']").should exist
|
28
27
|
end
|
28
|
+
|
29
29
|
it "should return true if the element exists (default how = :id)" do
|
30
30
|
@browser.div("header").should exist
|
31
31
|
end
|
32
|
+
|
32
33
|
it "should return false if the element does not exist" do
|
33
34
|
@browser.div(:id, "no_such_id").should_not exist
|
34
35
|
@browser.div(:id, /no_such_id/).should_not exist
|
@@ -40,10 +41,12 @@ describe Div do
|
|
40
41
|
@browser.div(:class, /no_such_class/).should_not exist
|
41
42
|
@browser.div(:index, 1337).should_not exist
|
42
43
|
@browser.div(:xpath, "//div[@id='no_such_id']").should_not exist
|
43
|
-
end
|
44
|
+
end
|
45
|
+
|
44
46
|
it "should raise ArgumentError when 'what' argument is invalid" do
|
45
47
|
lambda { @browser.div(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
46
48
|
end
|
49
|
+
|
47
50
|
it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
48
51
|
lambda { @browser.div(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
49
52
|
end
|
@@ -54,9 +57,11 @@ describe Div do
|
|
54
57
|
it "should return the class attribute if the element exists" do
|
55
58
|
@browser.div(:id , "footer").class_name.should == "profile"
|
56
59
|
end
|
60
|
+
|
57
61
|
it "should return an empty string if the element exists but the attribute doesn't" do
|
58
62
|
@browser.div(:id , "content").class_name.should == ""
|
59
63
|
end
|
64
|
+
|
60
65
|
it "should raise UnknownObjectException if the element does not exist" do
|
61
66
|
lambda { @browser.div(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
62
67
|
lambda { @browser.div(:title, "no_such_title").class_name }.should raise_error(UnknownObjectException)
|
@@ -69,9 +74,11 @@ describe Div do
|
|
69
74
|
it "should return the id attribute if the element exists" do
|
70
75
|
@browser.div(:index, 2).id.should == "outer_container"
|
71
76
|
end
|
77
|
+
|
72
78
|
it "should return an empty string if the element exists, but the attribute doesn't" do
|
73
79
|
@browser.div(:index, 1).id.should == ""
|
74
80
|
end
|
81
|
+
|
75
82
|
it "should raise UnknownObjectException if the element does not exist" do
|
76
83
|
lambda {@browser.div(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
77
84
|
lambda {@browser.div(:title, "no_such_id").id }.should raise_error(UnknownObjectException)
|
@@ -83,9 +90,11 @@ describe Div do
|
|
83
90
|
it "should return the name attribute if the element exists" do
|
84
91
|
@browser.div(:id, 'promo').name.should == "invalid_attribute"
|
85
92
|
end
|
93
|
+
|
86
94
|
it "should return an empty string if the element exists but the attribute doesn't" do
|
87
95
|
@browser.div(:index, 1).name.should == ""
|
88
96
|
end
|
97
|
+
|
89
98
|
it "should raise UnknownObjectException if the element does not exist" do
|
90
99
|
lambda {@browser.div(:id, "no_such_id").name }.should raise_error(UnknownObjectException)
|
91
100
|
lambda {@browser.div(:title, "no_such_title").name }.should raise_error(UnknownObjectException)
|
@@ -97,9 +106,11 @@ describe Div do
|
|
97
106
|
it "should return the style attribute if the element exists" do
|
98
107
|
@browser.div(:id, 'best_language').style.should == "color: red; text-decoration: underline; cursor: pointer;"
|
99
108
|
end
|
109
|
+
|
100
110
|
it "should return an empty string if the element exists but the attribute doesn't" do
|
101
111
|
@browser.div(:id, 'promo').style.should == ""
|
102
112
|
end
|
113
|
+
|
103
114
|
it "should raise UnknownObjectException if the element does not exist" do
|
104
115
|
lambda {@browser.div(:id, "no_such_id").style }.should raise_error(UnknownObjectException)
|
105
116
|
end
|
@@ -111,9 +122,11 @@ describe Div do
|
|
111
122
|
@browser.div(:title, "Closing remarks").text.strip.should == "This is a footer."
|
112
123
|
@browser.div(:xpath, "//div[@id='footer']").text.strip.should == "This is a footer."
|
113
124
|
end
|
125
|
+
|
114
126
|
it "should return an empty string if the element exists but contains no text" do
|
115
127
|
@browser.div(:index, 1).text.strip.should == ""
|
116
128
|
end
|
129
|
+
|
117
130
|
it "should raise UnknownObjectException if the element does not exist" do
|
118
131
|
lambda { @browser.div(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
|
119
132
|
lambda { @browser.div(:title, "no_such_title").text }.should raise_error(UnknownObjectException)
|
@@ -126,9 +139,11 @@ describe Div do
|
|
126
139
|
it "should return the value attribute if the element exists" do
|
127
140
|
@browser.div(:id, 'promo').value.should == "invalid_attribute"
|
128
141
|
end
|
142
|
+
|
129
143
|
it "should return an empty string if the element exists but the attribute doesn't" do
|
130
144
|
@browser.div(:index, 1).value.should == ""
|
131
145
|
end
|
146
|
+
|
132
147
|
it "should raise UnknownObjectException if the element does not exist" do
|
133
148
|
lambda {@browser.div(:id, "no_such_id").value }.should raise_error(UnknownObjectException)
|
134
149
|
lambda {@browser.div(:title, "no_such_title").value }.should raise_error(UnknownObjectException)
|
@@ -136,6 +151,17 @@ describe Div do
|
|
136
151
|
end
|
137
152
|
end
|
138
153
|
|
154
|
+
describe "#respond_to?" do
|
155
|
+
it "should return true for all attribute methods" do
|
156
|
+
@browser.div(:index, 1).should respond_to(:class_name)
|
157
|
+
@browser.div(:index, 1).should respond_to(:id)
|
158
|
+
@browser.div(:index, 1).should respond_to(:name)
|
159
|
+
@browser.div(:index, 1).should respond_to(:style)
|
160
|
+
@browser.div(:index, 1).should respond_to(:text)
|
161
|
+
@browser.div(:index, 1).should respond_to(:value)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
139
165
|
# Manipulation methods
|
140
166
|
describe "#click" do
|
141
167
|
it "should fire events when clicked" do
|
@@ -143,6 +169,7 @@ describe Div do
|
|
143
169
|
@browser.div(:id, 'best_language').click
|
144
170
|
@browser.div(:id, 'best_language').text.should == 'Ruby!'
|
145
171
|
end
|
172
|
+
|
146
173
|
it "should raise UnknownObjectException if the element does not exist" do
|
147
174
|
lambda { @browser.div(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
|
148
175
|
lambda { @browser.div(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
|
data/spec/divs_spec.rb
CHANGED
data/spec/element_spec.rb
CHANGED
@@ -1,38 +1,61 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
2
|
|
3
|
-
describe Element do
|
3
|
+
describe "Element" do
|
4
4
|
|
5
5
|
before :all do
|
6
|
-
@browser =
|
7
|
-
add_spec_checker(@browser)
|
6
|
+
@browser = Browser.new
|
8
7
|
end
|
9
8
|
|
10
9
|
before :each do
|
11
10
|
@browser.goto(TEST_HOST + "/forms_with_input_elements.html")
|
12
11
|
end
|
13
12
|
|
14
|
-
describe "
|
13
|
+
describe "::new" do
|
15
14
|
it "should find elements matching the conditions when given a hash of :how => 'what' arguments" do
|
16
15
|
@browser.checkbox(:name => 'new_user_interests', :title => 'Dancing is fun!').value.should == 'dancing'
|
17
16
|
@browser.text_field(:class_name => 'name', :index => 2).id.should == 'new_user_last_name'
|
18
17
|
end
|
19
|
-
|
18
|
+
|
19
|
+
it "should raise UnknownObjectException with a sane error message when given a hash of :how => 'what' arguments (non-existing object)" do
|
20
20
|
conditions = {:index => 100, :name => "foo"}
|
21
21
|
lambda { @browser.text_field(conditions).id }.should raise_error(UnknownObjectException, /Unable to locate object, using (\{:name=>"foo", :index=>100\}|\{:index=>100, :name=>"foo"\})/)
|
22
22
|
end
|
23
|
+
|
24
|
+
it "should raise ArgumentError if given the wrong number of arguments" do
|
25
|
+
container = mock("container", :null_object => true)
|
26
|
+
lambda { Element.new(container, 1,2,3,4) }.should raise_error(ArgumentError, "wrong number of arguments (4 for 2)")
|
27
|
+
lambda { Element.new(container, "foo") }.should raise_error(ArgumentError, "wrong number of arguments (1 for 2)")
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#focus" do
|
33
|
+
it "should fire the onfocus event for the given element" do
|
34
|
+
tf = @browser.text_field(:id, "new_user_occupation")
|
35
|
+
tf.value.should == "Developer"
|
36
|
+
tf.focus
|
37
|
+
@browser.div(:id, "onfocus_test").text.should == "changed by onfocus event"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#parent" do
|
42
|
+
it "should get the parent of this element" do
|
43
|
+
@browser.text_field(:id, "new_user_email").parent.should be_instance_of(Form)
|
44
|
+
end
|
23
45
|
end
|
24
46
|
|
25
47
|
describe "#method_missing" do
|
26
48
|
it "should magically return the requested attribute if the attribute is defined in the attribute list" do
|
27
49
|
@browser.form(:index, 1).action.should == 'post_to_me'
|
28
50
|
end
|
51
|
+
|
29
52
|
it "should raise NoMethodError if the requested method isn't among the attributes" do
|
30
53
|
lambda { @browser.button(:index, 1).no_such_attribute_or_method }.should raise_error(NoMethodError)
|
31
54
|
end
|
32
55
|
end
|
33
56
|
|
34
57
|
describe "#html" do
|
35
|
-
it "should return the
|
58
|
+
it "should return the descriptive (actual) html for the image element" do
|
36
59
|
@browser.goto(TEST_HOST + "/images.html")
|
37
60
|
@browser.image(:id, 'non_self_closing').html.chomp.should == '<img src="images/1.gif" alt="1" id="non_self_closing"></img>'
|
38
61
|
@browser.goto(TEST_HOST + "/non_control_elements.html")
|
@@ -43,6 +66,13 @@ describe Element do
|
|
43
66
|
end
|
44
67
|
end
|
45
68
|
|
69
|
+
describe "#text" do
|
70
|
+
it "should return a text representation including newlines" do
|
71
|
+
@browser.goto(TEST_HOST + "/forms_with_input_elements.html")
|
72
|
+
@browser.form(:id, "delete_user").text.should == "Username Username 1 Username 2 Username 3 \nComment Default comment."
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
46
76
|
after :all do
|
47
77
|
@browser.close
|
48
78
|
end
|