celerity 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/License.txt +621 -0
- data/README.txt +58 -0
- data/Rakefile +4 -0
- data/lib/celerity.rb +47 -0
- data/lib/celerity/clickable_element.rb +11 -0
- data/lib/celerity/collections.rb +99 -0
- data/lib/celerity/container.rb +369 -0
- data/lib/celerity/disabled_element.rb +20 -0
- data/lib/celerity/element.rb +114 -0
- data/lib/celerity/element_collections.rb +67 -0
- data/lib/celerity/elements/button.rb +13 -0
- data/lib/celerity/elements/file_field.rb +12 -0
- data/lib/celerity/elements/form.rb +15 -0
- data/lib/celerity/elements/frame.rb +44 -0
- data/lib/celerity/elements/image.rb +70 -0
- data/lib/celerity/elements/label.rb +10 -0
- data/lib/celerity/elements/link.rb +13 -0
- data/lib/celerity/elements/radio_check.rb +59 -0
- data/lib/celerity/elements/select_list.rb +84 -0
- data/lib/celerity/elements/table.rb +94 -0
- data/lib/celerity/elements/table_body.rb +38 -0
- data/lib/celerity/elements/table_cell.rb +30 -0
- data/lib/celerity/elements/table_row.rb +34 -0
- data/lib/celerity/elements/text_field.rb +80 -0
- data/lib/celerity/exception.rb +48 -0
- data/lib/celerity/htmlunit/commons-codec-1.3.jar +0 -0
- data/lib/celerity/htmlunit/commons-collections-3.2.jar +0 -0
- data/lib/celerity/htmlunit/commons-httpclient-3.1.jar +0 -0
- data/lib/celerity/htmlunit/commons-io-1.4.jar +0 -0
- data/lib/celerity/htmlunit/commons-lang-2.4.jar +0 -0
- data/lib/celerity/htmlunit/commons-logging-1.1.1.jar +0 -0
- data/lib/celerity/htmlunit/cssparser-0.9.5.jar +0 -0
- data/lib/celerity/htmlunit/htmlunit-2.2-SNAPSHOT.jar +0 -0
- data/lib/celerity/htmlunit/js-1.7R1.jar +0 -0
- data/lib/celerity/htmlunit/nekohtml-1.9.7.jar +0 -0
- data/lib/celerity/htmlunit/sac-1.3.jar +0 -0
- data/lib/celerity/htmlunit/xalan-2.7.0.jar +0 -0
- data/lib/celerity/htmlunit/xercesImpl-2.8.1.jar +0 -0
- data/lib/celerity/htmlunit/xml-apis-1.0.b2.jar +0 -0
- data/lib/celerity/ie.rb +126 -0
- data/lib/celerity/input_element.rb +29 -0
- data/lib/celerity/non_control_elements.rb +50 -0
- data/lib/celerity/version.rb +9 -0
- data/setup.rb +1585 -0
- data/spec/area_spec.rb +79 -0
- data/spec/areas_spec.rb +41 -0
- data/spec/button_spec.rb +171 -0
- data/spec/buttons_spec.rb +40 -0
- data/spec/checkbox_spec.rb +259 -0
- data/spec/checkboxes_spec.rb +39 -0
- data/spec/div_spec.rb +174 -0
- data/spec/divs_spec.rb +40 -0
- data/spec/element_spec.rb +29 -0
- data/spec/filefield_spec.rb +110 -0
- data/spec/filefields_spec.rb +41 -0
- data/spec/form_spec.rb +53 -0
- data/spec/forms_spec.rb +42 -0
- data/spec/frame_spec.rb +103 -0
- data/spec/hidden_spec.rb +105 -0
- data/spec/hiddens_spec.rb +40 -0
- data/spec/html/forms_with_input_elements.html +107 -0
- data/spec/html/frame_1.html +17 -0
- data/spec/html/frame_2.html +16 -0
- data/spec/html/frames.html +11 -0
- data/spec/html/iframes.html +12 -0
- data/spec/html/images.html +24 -0
- data/spec/html/images/1.gif +0 -0
- data/spec/html/images/2.gif +0 -0
- data/spec/html/images/3.gif +0 -0
- data/spec/html/images/button.jpg +0 -0
- data/spec/html/images/circle.jpg +0 -0
- data/spec/html/images/map.gif +0 -0
- data/spec/html/images/map2.gif +0 -0
- data/spec/html/images/minus.gif +0 -0
- data/spec/html/images/originaltriangle.jpg +0 -0
- data/spec/html/images/plus.gif +0 -0
- data/spec/html/images/square.jpg +0 -0
- data/spec/html/images/triangle.jpg +0 -0
- data/spec/html/non_control_elements.html +85 -0
- data/spec/html/tables.html +119 -0
- data/spec/ie_spec.rb +146 -0
- data/spec/image_spec.rb +210 -0
- data/spec/images_spec.rb +39 -0
- data/spec/label_spec.rb +65 -0
- data/spec/labels_spec.rb +41 -0
- data/spec/li_spec.rb +114 -0
- data/spec/link_spec.rb +147 -0
- data/spec/links_spec.rb +43 -0
- data/spec/lis_spec.rb +40 -0
- data/spec/map_spec.rb +83 -0
- data/spec/maps_spec.rb +41 -0
- data/spec/p_spec.rb +140 -0
- data/spec/pre_spec.rb +110 -0
- data/spec/pres_spec.rb +41 -0
- data/spec/ps_spec.rb +40 -0
- data/spec/radio_spec.rb +260 -0
- data/spec/radios_spec.rb +43 -0
- data/spec/select_list_spec.rb +286 -0
- data/spec/select_lists_spec.rb +47 -0
- data/spec/span_spec.rb +156 -0
- data/spec/spans_spec.rb +65 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +90 -0
- data/spec/table_bodies.rb +40 -0
- data/spec/table_bodies_spec.rb +42 -0
- data/spec/table_body_spec.rb +72 -0
- data/spec/table_cell_spec.rb +61 -0
- data/spec/table_cells_spec.rb +60 -0
- data/spec/table_row_spec.rb +59 -0
- data/spec/table_rows_spec.rb +57 -0
- data/spec/table_spec.rb +111 -0
- data/spec/tables_spec.rb +42 -0
- data/spec/text_field_spec.rb +234 -0
- data/spec/text_fields_spec.rb +45 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rspec.rake +23 -0
- data/tasks/simple_ci.rake +94 -0
- data/tasks/testserver.rake +17 -0
- metadata +174 -0
data/spec/ps_spec.rb
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "Ps" do
|
|
4
|
+
before :all do
|
|
5
|
+
@ie = IE.new
|
|
6
|
+
add_spec_checker(@ie)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
before :each do
|
|
10
|
+
@ie.goto(TEST_HOST + "/non_control_elements.html")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "#length" do
|
|
14
|
+
it "should return the number of ps" do
|
|
15
|
+
@ie.ps.length.should == 5
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe "#[]" do
|
|
20
|
+
it "should return the p at the given index" do
|
|
21
|
+
@ie.ps[1].id.should == "lead"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe "#each" do
|
|
26
|
+
it "should iterate through ps correctly" do
|
|
27
|
+
@ie.ps.each_with_index do |p, index|
|
|
28
|
+
p.name.should == @ie.p(:index, index+1).name
|
|
29
|
+
p.id.should == @ie.p(:index, index+1).id
|
|
30
|
+
p.value.should == @ie.p(:index, index+1).value
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
after :all do
|
|
36
|
+
@ie.close
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
|
data/spec/radio_spec.rb
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "Radio" do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@ie = IE.new
|
|
7
|
+
add_spec_checker(@ie)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
before :each do
|
|
11
|
+
@ie.goto(TEST_HOST + "/forms_with_input_elements.html")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# Exists method
|
|
16
|
+
|
|
17
|
+
describe "#exists?" do
|
|
18
|
+
it "should return true if the radio button exists" do
|
|
19
|
+
@ie.radio(:id, "new_user_newsletter_yes").should exist
|
|
20
|
+
@ie.radio(:id, /new_user_newsletter_yes/).should exist
|
|
21
|
+
@ie.radio(:name, "new_user_newsletter").should exist
|
|
22
|
+
@ie.radio(:name, /new_user_newsletter/).should exist
|
|
23
|
+
@ie.radio(:value, "yes").should exist
|
|
24
|
+
@ie.radio(:value, /yes/).should exist
|
|
25
|
+
# we need to figure out what :text means for a radio button
|
|
26
|
+
@ie.radio(:text, "yes").should exist
|
|
27
|
+
@ie.radio(:text, /yes/).should exist
|
|
28
|
+
@ie.radio(:class, "huge").should exist
|
|
29
|
+
@ie.radio(:class, /huge/).should exist
|
|
30
|
+
@ie.radio(:index, 1).should exist
|
|
31
|
+
@ie.radio(:xpath, "input[@id='new_user_newsletter_yes']").should exist
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should return true if the radio button exists (search by name and value)" do
|
|
35
|
+
@ie.radio(:name, "new_user_newsletter", 'yes').should exist
|
|
36
|
+
@ie.radio(:xpath, "//input[@name='new_user_newsletter' and @value='yes']").set
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should return false if the radio button does not exist" do
|
|
40
|
+
@ie.radio(:id, "no_such_id").should_not exist
|
|
41
|
+
@ie.radio(:id, /no_such_id/).should_not exist
|
|
42
|
+
@ie.radio(:name, "no_such_name").should_not exist
|
|
43
|
+
@ie.radio(:name, /no_such_name/).should_not exist
|
|
44
|
+
@ie.radio(:value, "no_such_value").should_not exist
|
|
45
|
+
@ie.radio(:value, /no_such_value/).should_not exist
|
|
46
|
+
@ie.radio(:text, "no_such_text").should_not exist
|
|
47
|
+
@ie.radio(:text, /no_such_text/).should_not exist
|
|
48
|
+
@ie.radio(:class, "no_such_class").should_not exist
|
|
49
|
+
@ie.radio(:class, /no_such_class/).should_not exist
|
|
50
|
+
@ie.radio(:index, 1337).should_not exist
|
|
51
|
+
@ie.radio(:xpath, "input[@id='no_such_id']").should_not exist
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should return false if the radio button does not exist (search by name and value)" do
|
|
55
|
+
@ie.radio(:name, "new_user_newsletter", 'no_such_value').should_not exist
|
|
56
|
+
@ie.radio(:xpath, "//input[@name='new_user_newsletter' and @value='no_such_value']").should_not exist
|
|
57
|
+
@ie.radio(:name, "no_such_name", 'yes').should_not exist
|
|
58
|
+
@ie.radio(:xpath, "//input[@name='no_such_name' and @value='yes']").should_not exist
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "should return true for radios with a string value" do
|
|
62
|
+
@ie.radio(:name, 'new_user_newsletter', 'yes').should exist
|
|
63
|
+
@ie.radio(:name, 'new_user_newsletter', 'no').should exist
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "should raise ArgumentError when what argument is invalid" do
|
|
67
|
+
lambda { @ie.radio(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
|
71
|
+
lambda { @ie.radio(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
# Attribute methods
|
|
77
|
+
|
|
78
|
+
describe "#class_name" do
|
|
79
|
+
it "should return the class name if the radio exists and has an attribute" do
|
|
80
|
+
@ie.radio(:id, "new_user_newsletter_yes").class_name.should == "huge"
|
|
81
|
+
end
|
|
82
|
+
it "should return an emptry string if the radio exists and the attribute doesn't" do
|
|
83
|
+
@ie.radio(:id, "new_user_newsletter_no").class_name.should == ""
|
|
84
|
+
end
|
|
85
|
+
it "should raise UnknownObjectException if the radio doesn't exist" do
|
|
86
|
+
lambda { @ie.radio(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
describe "#id" do
|
|
91
|
+
it "should return the id attribute if the radio exists and has an attribute" do
|
|
92
|
+
@ie.radio(:index, 1).id.should == "new_user_newsletter_yes"
|
|
93
|
+
end
|
|
94
|
+
it "should return an emptry string if the radio exists and the attribute doesn't" do
|
|
95
|
+
@ie.radio(:index, 3).id.should == ""
|
|
96
|
+
end
|
|
97
|
+
it "should raise UnknownObjectException if the radio doesn't exist" do
|
|
98
|
+
lambda { @ie.radio(:index, 1337).id }.should raise_error(UnknownObjectException)
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
describe "#name" do
|
|
103
|
+
it "should return the name attribute if the radio exists" do
|
|
104
|
+
@ie.radio(:id, 'new_user_newsletter_yes').name.should == "new_user_newsletter"
|
|
105
|
+
end
|
|
106
|
+
it "should return an empty string if the radio exists and the attribute doesn't" do
|
|
107
|
+
@ie.radio(:id, 'new_user_newsletter_absolutely').name.should == ""
|
|
108
|
+
end
|
|
109
|
+
it "should raise UnknownObjectException if the radio doesn't exist" do
|
|
110
|
+
lambda { @ie.radio(:index, 1337).name }.should raise_error(UnknownObjectException)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
describe "#title" do
|
|
115
|
+
it "should return the title attribute if the radio exists" do
|
|
116
|
+
@ie.radio(:id, "new_user_newsletter_no").title.should == "Traitor!"
|
|
117
|
+
end
|
|
118
|
+
it "should return an emptry string if the radio exists and the attribute doesn't" do
|
|
119
|
+
@ie.radio(:id, "new_user_newsletter_yes").title.should == ""
|
|
120
|
+
end
|
|
121
|
+
it "should raise UnknownObjectException if the radio doesn't exist" do
|
|
122
|
+
lambda { @ie.radio(:index, 1337).title }.should raise_error(UnknownObjectException)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
describe "#type" do
|
|
127
|
+
it "should return the type attribute if the radio exists" do
|
|
128
|
+
@ie.radio(:index, 1).type.should == "radio"
|
|
129
|
+
end
|
|
130
|
+
it "should raise UnknownObjectException if the radio doesn't exist" do
|
|
131
|
+
lambda { @ie.radio(:index, 1337).type }.should raise_error(UnknownObjectException)
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
describe "#value" do
|
|
136
|
+
it "should return the value attribute if the radio exists" do
|
|
137
|
+
@ie.radio(:id, 'new_user_newsletter_yes').value.should == 'yes'
|
|
138
|
+
end
|
|
139
|
+
it "should raise UnknownObjectException if the radio doesn't exist" do
|
|
140
|
+
lambda { @ie.radio(:index, 1337).value}.should raise_error(UnknownObjectException)
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
# Access methods
|
|
146
|
+
|
|
147
|
+
describe "#enabled?" do
|
|
148
|
+
it "should return true if the radio button is enabled" do
|
|
149
|
+
@ie.radio(:id, "new_user_newsletter_yes").should be_enabled
|
|
150
|
+
@ie.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should be_enabled
|
|
151
|
+
end
|
|
152
|
+
it "should return false if the radio button is disabled" do
|
|
153
|
+
@ie.radio(:id, "new_user_newsletter_nah").should_not be_enabled
|
|
154
|
+
@ie.radio(:xpath,"//input[@id='new_user_newsletter_nah']").should_not be_enabled
|
|
155
|
+
end
|
|
156
|
+
it "should raise UnknownObjectException if the radio button doesn't exist" do
|
|
157
|
+
lambda { @ie.radio(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
|
|
158
|
+
lambda { @ie.radio(:xpath, "//input[@id='no_such_id']").enabled? }.should raise_error(UnknownObjectException)
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
describe "#disabled?" do
|
|
163
|
+
it "should return true if the radio is disabled" do
|
|
164
|
+
@ie.radio(:id, 'new_user_newsletter_nah').should be_disabled
|
|
165
|
+
end
|
|
166
|
+
it "should return false if the radio is enabled" do
|
|
167
|
+
@ie.radio(:id, 'new_user_newsletter_yes').should_not be_disabled
|
|
168
|
+
end
|
|
169
|
+
it "should raise UnknownObjectException if the radio doesn't exist" do
|
|
170
|
+
lambda { @ie.radio(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
# Manipulation methods
|
|
176
|
+
|
|
177
|
+
describe "clear" do
|
|
178
|
+
it "should clear the radio button if it is set" do
|
|
179
|
+
@ie.radio(:id, "new_user_newsletter_yes").clear
|
|
180
|
+
@ie.radio(:id, "new_user_newsletter_yes").should_not be_set
|
|
181
|
+
end
|
|
182
|
+
it "should clear the radio button when found by :xpath" do
|
|
183
|
+
@ie.radio(:xpath, "//input[@id='new_user_newsletter_yes']").clear
|
|
184
|
+
@ie.radio(:xpath, "//input[@id='new_user_newsletter_yes']").should_not be_set
|
|
185
|
+
end
|
|
186
|
+
it "should raise UnknownObjectException if the radio button doesn't exist" do
|
|
187
|
+
lambda { @ie.radio(:name, "no_such_id").clear }.should raise_error(UnknownObjectException)
|
|
188
|
+
lambda { @ie.radio(:xpath, "//input[@id='no_such_id']").clear }.should raise_error(UnknownObjectException)
|
|
189
|
+
end
|
|
190
|
+
it "should raise ObjectDisabledException if the radio is disabled" do
|
|
191
|
+
@ie.radio(:id, "new_user_newsletter_nah").should_not be_set
|
|
192
|
+
lambda { @ie.radio(:id, "new_user_newsletter_nah").clear }.should raise_error(ObjectDisabledException)
|
|
193
|
+
lambda { @ie.radio(:xpath, "//input[@id='new_user_newsletter_nah']").clear }.should raise_error(ObjectDisabledException)
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
describe "#set" do
|
|
198
|
+
it "should set the radio button" do
|
|
199
|
+
@ie.radio(:id, "new_user_newsletter_no").set
|
|
200
|
+
@ie.radio(:id, "new_user_newsletter_no").should be_set
|
|
201
|
+
end
|
|
202
|
+
it "should set the radio button when found by :xpath" do
|
|
203
|
+
@ie.radio(:xpath, "//input[@id='new_user_newsletter_no']").set
|
|
204
|
+
@ie.radio(:xpath, "//input[@id='new_user_newsletter_no']").should be_set
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
it "should fire the onclick event"
|
|
208
|
+
|
|
209
|
+
it "should raise UnknownObjectException if the radio button doesn't exist" do
|
|
210
|
+
lambda { @ie.radio(:name, "no_such_name").set }.should raise_error(UnknownObjectException)
|
|
211
|
+
lambda { @ie.radio(:xpath, "//input[@name='no_such_name']").set }.should raise_error(UnknownObjectException)
|
|
212
|
+
end
|
|
213
|
+
it "should raise ObjectDisabledException if the radio is disabled" do
|
|
214
|
+
lambda { @ie.radio(:id, "new_user_newsletter_nah").set }.should raise_error(ObjectDisabledException)
|
|
215
|
+
lambda { @ie.radio(:xpath, "//input[@id='new_user_newsletter_nah']").set }.should raise_error(ObjectDisabledException )
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
# Other
|
|
221
|
+
|
|
222
|
+
describe '#set?' do
|
|
223
|
+
it "should return true if the radio button is set" do
|
|
224
|
+
@ie.radio(:id, "new_user_newsletter_yes").should be_set
|
|
225
|
+
end
|
|
226
|
+
it "should return false if the radio button unset" do
|
|
227
|
+
@ie.radio(:id, "new_user_newsletter_no").should_not be_set
|
|
228
|
+
end
|
|
229
|
+
it "should return the state for radios with string values" do
|
|
230
|
+
@ie.radio(:name, "new_user_newsletter", 'no').should_not be_set
|
|
231
|
+
@ie.radio(:name, "new_user_newsletter", 'no').set
|
|
232
|
+
@ie.radio(:name, "new_user_newsletter", 'no').should be_set
|
|
233
|
+
@ie.radio(:name, "new_user_newsletter", 'no').clear
|
|
234
|
+
@ie.radio(:name, "new_user_newsletter", 'no').should_not be_set
|
|
235
|
+
end
|
|
236
|
+
it "should raise UnknownObjectException if the radio button doesn't exist" do
|
|
237
|
+
lambda { @ie.radio(:id, "no_such_id").set? }.should raise_error(UnknownObjectException)
|
|
238
|
+
lambda { @ie.radio(:xpath, "//input[@id='no_such_id']").set? }.should raise_error(UnknownObjectException)
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
describe "#get_state" do
|
|
243
|
+
it "should return true if the radio is set" do
|
|
244
|
+
@ie.radio(:id, "new_user_newsletter_yes").get_state.should be_true
|
|
245
|
+
end
|
|
246
|
+
it "should return false if the radio is unset" do
|
|
247
|
+
@ie.radio(:id, "new_user_newsletter_no").get_state.should be_false
|
|
248
|
+
end
|
|
249
|
+
it "should raise UnknownObjectException if the radio doesn't exist" do
|
|
250
|
+
lambda { @ie.radio(:name, "no_such_name").get_state }.should raise_error(UnknownObjectException)
|
|
251
|
+
lambda { @ie.radio(:xpath, "//input[@name='no_such_name']").get_state }.should raise_error(UnknownObjectException)
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
after :all do
|
|
256
|
+
@ie.close
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
end
|
|
260
|
+
|
data/spec/radios_spec.rb
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "Radios" do
|
|
4
|
+
|
|
5
|
+
before :all do
|
|
6
|
+
@ie = IE.new
|
|
7
|
+
add_spec_checker(@ie)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
before :each do
|
|
11
|
+
@ie.goto(TEST_HOST + "/forms_with_input_elements.html")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "#length" do
|
|
15
|
+
it "should return the number of radios" do
|
|
16
|
+
@ie.radios.length.should == 5
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
describe "#[]" do
|
|
21
|
+
it "should return the radio button at the given index" do
|
|
22
|
+
@ie.radios[1].id.should == "new_user_newsletter_yes"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe "#each" do
|
|
27
|
+
it "should iterate through radio buttons correctly" do
|
|
28
|
+
index = 1
|
|
29
|
+
@ie.radios.each do |r|
|
|
30
|
+
r.name.should == @ie.radio(:index, index).name
|
|
31
|
+
r.id.should == @ie.radio(:index, index).id
|
|
32
|
+
r.value.should == @ie.radio(:index, index).value
|
|
33
|
+
index += 1
|
|
34
|
+
end
|
|
35
|
+
@ie.radios.length.should == index - 1
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
after :all do
|
|
40
|
+
@ie.close
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
|
2
|
+
|
|
3
|
+
describe "SelectList" do
|
|
4
|
+
before :all do
|
|
5
|
+
@ie = Celerity::IE.new
|
|
6
|
+
add_spec_checker(@ie)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
before :each do
|
|
10
|
+
@ie.goto(TEST_HOST + "/forms_with_input_elements.html")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# Exists method
|
|
15
|
+
|
|
16
|
+
describe "#exists?" do
|
|
17
|
+
it "should return true if the select list exists" do
|
|
18
|
+
@ie.select_list(:id, 'new_user_country').should exist
|
|
19
|
+
@ie.select_list(:id, /new_user_country/).should exist
|
|
20
|
+
@ie.select_list(:name, 'new_user_country').should exist
|
|
21
|
+
@ie.select_list(:name, /new_user_country/).should exist
|
|
22
|
+
|
|
23
|
+
# check behaviour in Watir
|
|
24
|
+
# @ie.select_list(:value, 'Norway').should exist
|
|
25
|
+
# @ie.select_list(:value, /Norway/).should exist
|
|
26
|
+
|
|
27
|
+
# not sure what :text is for input elements
|
|
28
|
+
# @ie.select_list(:text, 'Norway').should exist
|
|
29
|
+
# @ie.select_list(:text, /Norway/).should exist
|
|
30
|
+
@ie.select_list(:class, 'country').should exist
|
|
31
|
+
@ie.select_list(:class, /country/).should exist
|
|
32
|
+
@ie.select_list(:index, 1).should exist
|
|
33
|
+
@ie.select_list(:xpath, "//select[@id='new_user_country']").should exist
|
|
34
|
+
end
|
|
35
|
+
it "should return false if the select list doesn't exist" do
|
|
36
|
+
@ie.select_list(:id, 'no_such_id').should_not exist
|
|
37
|
+
@ie.select_list(:id, /no_such_id/).should_not exist
|
|
38
|
+
@ie.select_list(:name, 'no_such_name').should_not exist
|
|
39
|
+
@ie.select_list(:name, /no_such_name/).should_not exist
|
|
40
|
+
@ie.select_list(:value, 'no_such_value').should_not exist
|
|
41
|
+
@ie.select_list(:value, /no_such_value/).should_not exist
|
|
42
|
+
@ie.select_list(:text, 'no_such_text').should_not exist
|
|
43
|
+
@ie.select_list(:text, /no_such_text/).should_not exist
|
|
44
|
+
@ie.select_list(:class, 'no_such_class').should_not exist
|
|
45
|
+
@ie.select_list(:class, /no_such_class/).should_not exist
|
|
46
|
+
@ie.select_list(:index, 1337).should_not exist
|
|
47
|
+
@ie.select_list(:xpath, "//select[@id='no_such_id']").should_not exist
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should raise ArgumentError when what argument is invalid" do
|
|
51
|
+
lambda { @ie.select_list(:id, 3.14).exists? }.should raise_error(ArgumentError)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
|
|
55
|
+
lambda { @ie.select_list(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# Attribute methods
|
|
61
|
+
|
|
62
|
+
describe "#class_name" do
|
|
63
|
+
it "should return the class name of the select list" do
|
|
64
|
+
@ie.select_list(:name, 'new_user_country').class_name.should == 'country'
|
|
65
|
+
end
|
|
66
|
+
it "should raise UnknownObjectException if the select list doesn't exist" do
|
|
67
|
+
lambda { @ie.select_list(:name, 'no_such_name').class_name }.should raise_error(UnknownObjectException)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
describe "#id" do
|
|
72
|
+
it "should return the id of the element" do
|
|
73
|
+
@ie.select_list(:index, 1).id.should == "new_user_country"
|
|
74
|
+
end
|
|
75
|
+
it "should raise UnknownObjectException if the select list doesn't exist" do
|
|
76
|
+
lambda { @ie.select_list(:index, 1337).id }.should raise_error(UnknownObjectException)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
describe "#name" do
|
|
81
|
+
it "should return the name of the element" do
|
|
82
|
+
@ie.select_list(:index, 1).name.should == "new_user_country"
|
|
83
|
+
end
|
|
84
|
+
it "should raise UnknownObjectException if the select list doesn't exist" do
|
|
85
|
+
lambda { @ie.select_list(:index, 1337).name }.should raise_error(UnknownObjectException)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
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
|
+
describe "#type" do
|
|
94
|
+
it "should return the type of the element" do
|
|
95
|
+
@ie.select_list(:index, 1).type.should == "select-one"
|
|
96
|
+
@ie.select_list(:index, 2).type.should == "select-multiple"
|
|
97
|
+
end
|
|
98
|
+
it "should raise UnknownObjectException if the select list doesn't exist" do
|
|
99
|
+
lambda { @ie.select_list(:index, 1337).type }.should raise_error(UnknownObjectException)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
describe "#value" do
|
|
104
|
+
it "should return the value of the selected option" do
|
|
105
|
+
@ie.select_list(:index, 1).value.should == "Norway"
|
|
106
|
+
@ie.select_list(:index, 1).select(/Sweden/)
|
|
107
|
+
@ie.select_list(:index, 1).value.should == "Sweden"
|
|
108
|
+
end
|
|
109
|
+
it "should raise UnknownObjectException if the select list doesn't exist" do
|
|
110
|
+
lambda { @ie.select_list(:index, 1337).value }.should raise_error(UnknownObjectException)
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
# Access methods
|
|
116
|
+
|
|
117
|
+
describe "#enabled?" do
|
|
118
|
+
it "should return true if the select list is enabled" do
|
|
119
|
+
@ie.select_list(:name, 'new_user_country').should be_enabled
|
|
120
|
+
end
|
|
121
|
+
it "should return false if the select list is disabled" do
|
|
122
|
+
@ie.select_list(:name, 'new_user_role').should_not be_enabled
|
|
123
|
+
end
|
|
124
|
+
it "should raise UnknownObjectException if the select_list doesn't exist" do
|
|
125
|
+
lambda { @ie.select_list(:name, 'no_such_name').enabled? }.should raise_error(UnknownObjectException)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
describe "#disabled?" do
|
|
130
|
+
it "should return true if the select list is disabled" do
|
|
131
|
+
@ie.select_list(:index, 3).should be_disabled
|
|
132
|
+
end
|
|
133
|
+
it "should return false if the select list is enabled" do
|
|
134
|
+
@ie.select_list(:index, 1).should_not be_disabled
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
# Other
|
|
140
|
+
|
|
141
|
+
describe "#option" do
|
|
142
|
+
it "should return an instance of Option" do
|
|
143
|
+
@ie.select_list(:name, "new_user_country").option(:text, "Denmark").should be_instance_of(Celerity::Option)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# do we need a seperate spec for this object?
|
|
147
|
+
it "should should be able to select the chosen option" do
|
|
148
|
+
@ie.select_list(:name , "new_user_country").clear_selection
|
|
149
|
+
@ie.select_list(:name , "new_user_country").option(:text, "Denmark").select
|
|
150
|
+
@ie.select_list(:name, "new_user_country").get_selected_items.should == ["Denmark"]
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
it "should select the option when found by text" do
|
|
154
|
+
@ie.select_list(:name, 'new_user_country').option(:text, 'Sweden').select
|
|
155
|
+
@ie.select_list(:name, 'new_user_country').option(:text, 'Sweden').should be_selected
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
it "should raise UnknownObjectException if the option does not exist" do
|
|
159
|
+
lambda { @ie.select_list(:name, "new_user_country").option(:text, "no_such_text").select }.should raise_error(UnknownObjectException)
|
|
160
|
+
lambda { @ie.select_list(:name, "new_user_country").option(:text, /missing/).select }.should raise_error(UnknownObjectException)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it "should raise MissingWayOfFindingObjectException when given a bad 'how'" do
|
|
164
|
+
lambda { @ie.select_list(:name, "new_user_country").option(:missing, "Denmark").select }.should raise_error(MissingWayOfFindingObjectException)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
it "should be able to get attributes" do
|
|
168
|
+
@ie.select_list(:name, "new_user_country").option(:text , 'Sweden').class_name.should == "scandinavia"
|
|
169
|
+
lambda { @ie.select_list(:name, "new_user_country").option(:text, "no_such_text").class_name }.should raise_error(UnknownObjectException)
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
describe "#get_all_contents" do
|
|
174
|
+
it "should should raise UnknownObjectException if the select list doesn't exist" do
|
|
175
|
+
lambda { @ie.select_list(:name, 'no_such_name').get_all_contents }.should raise_error(UnknownObjectException)
|
|
176
|
+
end
|
|
177
|
+
it "should return all the options as an Array" do
|
|
178
|
+
@ie.select_list(:name, "new_user_country").get_all_contents.should == ["Denmark" ,"Norway" , "Sweden" , "United Kingdom", "USA"]
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
describe "#get_selected_items" do
|
|
183
|
+
it "should should raise UnknownObjectException if the select list doesn't exist" do
|
|
184
|
+
lambda { @ie.select_list(:name, 'no_such_name').get_selected_items }.should raise_error(UnknownObjectException)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
it "should get the currently selected item(s)" do
|
|
188
|
+
@ie.select_list(:name, "new_user_country").get_selected_items.should == ["Norway"]
|
|
189
|
+
@ie.select_list(:name, "new_user_languages").get_selected_items.should == ["English", "Norwegian"]
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
describe "#clear_selection" do
|
|
194
|
+
it "should clear the selection when possible" do
|
|
195
|
+
@ie.select_list(:name, "new_user_languages").clear_selection
|
|
196
|
+
@ie.select_list(:name, "new_user_languages").get_selected_items.should be_empty
|
|
197
|
+
end
|
|
198
|
+
it "should not clear selections when not possible" do
|
|
199
|
+
@ie.select_list(:name , "new_user_country").clear_selection
|
|
200
|
+
@ie.select_list(:name, "new_user_country").get_selected_items.should == ["Norway"]
|
|
201
|
+
end
|
|
202
|
+
it "should should raise UnknownObjectException if the select list doesn't exist" do
|
|
203
|
+
lambda { @ie.select_list(:name, 'no_such_name').clear_selection }.should raise_error(UnknownObjectException)
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
describe "#includes?" do
|
|
208
|
+
it "should return true if the given option exists" do
|
|
209
|
+
@ie.select_list(:name, 'new_user_country').includes?('Denmark').should be_true
|
|
210
|
+
end
|
|
211
|
+
it "should return false if the given option doesn't exist" do
|
|
212
|
+
@ie.select_list(:name, 'new_user_country').includes?('Ireland').should be_false
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
describe "#selected?" do
|
|
217
|
+
it "should return true if the given option is selected" do
|
|
218
|
+
@ie.select_list(:name, 'new_user_country').select('Denmark')
|
|
219
|
+
@ie.select_list(:name, 'new_user_country').selected?('Denmark').should be_true
|
|
220
|
+
end
|
|
221
|
+
it "should return false if the given option is not selected" do
|
|
222
|
+
@ie.select_list(:name, 'new_user_country').selected?('Sweden').should be_false
|
|
223
|
+
end
|
|
224
|
+
it "should raise UnknonwObjectException if the option doesn't exist" do
|
|
225
|
+
lambda { @ie.select_list(:name, 'new_user_country').selected?('missing_option') }.should raise_error(UnknownObjectException)
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
describe "#select" do
|
|
230
|
+
it "should select the given item when given a String" do
|
|
231
|
+
@ie.select_list(:name, "new_user_country").select("Denmark")
|
|
232
|
+
@ie.select_list(:name, "new_user_country").get_selected_items.should == ["Denmark"]
|
|
233
|
+
end
|
|
234
|
+
it "should select the given item when given a Regexp" do
|
|
235
|
+
@ie.select_list(:name, "new_user_country").select(/Denmark/)
|
|
236
|
+
@ie.select_list(:name, "new_user_country").get_selected_items.should == ["Denmark"]
|
|
237
|
+
end
|
|
238
|
+
it "should select the given item when given an Xpath" do
|
|
239
|
+
@ie.select_list(:xpath, "//select[@name='new_user_country']").select("Denmark")
|
|
240
|
+
@ie.select_list(:xpath, "//select[@name='new_user_country']").get_selected_items.should == ["Denmark"]
|
|
241
|
+
end
|
|
242
|
+
it "should be able to select multiple items using :name and a String" do
|
|
243
|
+
@ie.select_list(:name, "new_user_languages").clear_selection
|
|
244
|
+
@ie.select_list(:name, "new_user_languages").select("Danish")
|
|
245
|
+
@ie.select_list(:name, "new_user_languages").select("Swedish")
|
|
246
|
+
@ie.select_list(:name, "new_user_languages").get_selected_items.should == ["Danish", "Swedish"]
|
|
247
|
+
end
|
|
248
|
+
it "should be able to select multiple items using :name and a Regexp" do
|
|
249
|
+
@ie.select_list(:name, "new_user_languages").clear_selection
|
|
250
|
+
@ie.select_list(:name, "new_user_languages").select(/ish/)
|
|
251
|
+
@ie.select_list(:name, "new_user_languages").get_selected_items.should == ["Danish", "English", "Swedish"]
|
|
252
|
+
end
|
|
253
|
+
it "should be able to select multiple items using :xpath" do
|
|
254
|
+
@ie.select_list(:xpath, "//select[@name='new_user_languages']").clear_selection
|
|
255
|
+
@ie.select_list(:xpath, "//select[@name='new_user_languages']").select( /ish/ )
|
|
256
|
+
@ie.select_list(:xpath, "//select[@name='new_user_languages']").get_selected_items.should == ["Danish", "English", "Swedish"]
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
it "should fire onchange event when selecting an item"
|
|
260
|
+
|
|
261
|
+
it "should not fire onchange event when selecting an already selected item"
|
|
262
|
+
|
|
263
|
+
it "should raise NoValueFoundException if the option doesn't exist" do
|
|
264
|
+
lambda { @ie.select_list(:name, "new_user_country").select("missing_option") }.should raise_error(NoValueFoundException)
|
|
265
|
+
lambda { @ie.select_list(:name, "new_user_country").select(/missing_option/) }.should raise_error(NoValueFoundException)
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
describe "#select_value" do
|
|
270
|
+
it "should select the given item" do
|
|
271
|
+
@ie.select_list(:name, "new_user_languages").clear_selection
|
|
272
|
+
@ie.select_list(:name, "new_user_languages").select("Swedish")
|
|
273
|
+
@ie.select_list(:name, "new_user_languages").get_selected_items.should == ["Swedish"]
|
|
274
|
+
end
|
|
275
|
+
it "should raise NoValueFoundException if the option doesn't exist" do
|
|
276
|
+
lambda { @ie.select_list(:name, "new_user_languages").select_value("no_such_option") }.should raise_error(NoValueFoundException)
|
|
277
|
+
lambda { @ie.select_list(:name, "new_user_languages").select_value(/no_such_option/) }.should raise_error(NoValueFoundException)
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
after :all do
|
|
282
|
+
@ie.close
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
end
|
|
286
|
+
|