watir-webdriver 0.1.4 → 0.1.5
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/.gitignore +9 -0
- data/Gemfile +3 -3
- data/Rakefile +3 -28
- data/lib/watir-webdriver.rb +1 -0
- data/lib/watir-webdriver/version.rb +3 -0
- data/watir-webdriver.gemspec +23 -247
- metadata +34 -326
- data/VERSION +0 -1
- data/spec/watirspec/area_spec.rb +0 -77
- data/spec/watirspec/areas_spec.rb +0 -45
- data/spec/watirspec/browser_spec.rb +0 -274
- data/spec/watirspec/button_spec.rb +0 -255
- data/spec/watirspec/buttons_spec.rb +0 -58
- data/spec/watirspec/checkbox_spec.rb +0 -276
- data/spec/watirspec/checkboxes_spec.rb +0 -47
- data/spec/watirspec/collections_spec.rb +0 -20
- data/spec/watirspec/dd_spec.rb +0 -127
- data/spec/watirspec/dds_spec.rb +0 -45
- data/spec/watirspec/del_spec.rb +0 -145
- data/spec/watirspec/dels_spec.rb +0 -45
- data/spec/watirspec/div_spec.rb +0 -221
- data/spec/watirspec/divs_spec.rb +0 -45
- data/spec/watirspec/dl_spec.rb +0 -137
- data/spec/watirspec/dls_spec.rb +0 -46
- data/spec/watirspec/dt_spec.rb +0 -127
- data/spec/watirspec/dts_spec.rb +0 -45
- data/spec/watirspec/element_spec.rb +0 -149
- data/spec/watirspec/em_spec.rb +0 -101
- data/spec/watirspec/ems_spec.rb +0 -46
- data/spec/watirspec/filefield_spec.rb +0 -156
- data/spec/watirspec/filefields_spec.rb +0 -46
- data/spec/watirspec/font_spec.rb +0 -32
- data/spec/watirspec/form_spec.rb +0 -63
- data/spec/watirspec/forms_spec.rb +0 -47
- data/spec/watirspec/frame_spec.rb +0 -144
- data/spec/watirspec/frames_spec.rb +0 -83
- data/spec/watirspec/hidden_spec.rb +0 -103
- data/spec/watirspec/hiddens_spec.rb +0 -46
- data/spec/watirspec/hn_spec.rb +0 -97
- data/spec/watirspec/hns_spec.rb +0 -42
- data/spec/watirspec/image_spec.rb +0 -208
- data/spec/watirspec/images_spec.rb +0 -45
- data/spec/watirspec/ins_spec.rb +0 -146
- data/spec/watirspec/inses_spec.rb +0 -45
- data/spec/watirspec/label_spec.rb +0 -81
- data/spec/watirspec/labels_spec.rb +0 -45
- data/spec/watirspec/li_spec.rb +0 -116
- data/spec/watirspec/lib/guards.rb +0 -59
- data/spec/watirspec/lib/implementation.rb +0 -48
- data/spec/watirspec/lib/runner.rb +0 -83
- data/spec/watirspec/lib/server.rb +0 -194
- data/spec/watirspec/lib/watirspec.rb +0 -75
- data/spec/watirspec/link_spec.rb +0 -174
- data/spec/watirspec/links_spec.rb +0 -49
- data/spec/watirspec/lis_spec.rb +0 -45
- data/spec/watirspec/map_spec.rb +0 -80
- data/spec/watirspec/maps_spec.rb +0 -46
- data/spec/watirspec/meta_spec.rb +0 -24
- data/spec/watirspec/metas_spec.rb +0 -43
- data/spec/watirspec/ol_spec.rb +0 -90
- data/spec/watirspec/ols_spec.rb +0 -45
- data/spec/watirspec/option_spec.rb +0 -152
- data/spec/watirspec/p_spec.rb +0 -132
- data/spec/watirspec/pre_spec.rb +0 -116
- data/spec/watirspec/pres_spec.rb +0 -45
- data/spec/watirspec/ps_spec.rb +0 -45
- data/spec/watirspec/radio_spec.rb +0 -262
- data/spec/watirspec/radios_spec.rb +0 -46
- data/spec/watirspec/select_list_spec.rb +0 -335
- data/spec/watirspec/select_lists_spec.rb +0 -49
- data/spec/watirspec/span_spec.rb +0 -146
- data/spec/watirspec/spans_spec.rb +0 -45
- data/spec/watirspec/spec_helper.rb +0 -20
- data/spec/watirspec/strong_spec.rb +0 -93
- data/spec/watirspec/strongs_spec.rb +0 -46
- data/spec/watirspec/table_nesting_spec.rb +0 -50
- data/spec/watirspec/table_spec.rb +0 -150
- data/spec/watirspec/tables_spec.rb +0 -47
- data/spec/watirspec/tbody_spec.rb +0 -97
- data/spec/watirspec/tbodys_spec.rb +0 -65
- data/spec/watirspec/td_spec.rb +0 -72
- data/spec/watirspec/tds_spec.rb +0 -60
- data/spec/watirspec/text_field_spec.rb +0 -283
- data/spec/watirspec/text_fields_spec.rb +0 -49
- data/spec/watirspec/tfoot_spec.rb +0 -92
- data/spec/watirspec/tfoots_spec.rb +0 -71
- data/spec/watirspec/thead_spec.rb +0 -92
- data/spec/watirspec/theads_spec.rb +0 -71
- data/spec/watirspec/tr_spec.rb +0 -88
- data/spec/watirspec/trs_spec.rb +0 -68
- data/spec/watirspec/ul_spec.rb +0 -80
- data/spec/watirspec/uls_spec.rb +0 -44
- data/spec/watirspec/window_switching_spec.rb +0 -164
@@ -1,46 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path("../spec_helper", __FILE__)
|
3
|
-
|
4
|
-
describe "Radios" do
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
8
|
-
end
|
9
|
-
|
10
|
-
bug "http://github.com/jarib/celerity/issues#issue/25", :celerity do
|
11
|
-
describe "with selectors" do
|
12
|
-
it "returns the matching elements" do
|
13
|
-
browser.radios(:value => "yes").to_a.should == [browser.radio(:value => "yes")]
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "#length" do
|
19
|
-
it "returns the number of radios" do
|
20
|
-
browser.radios.length.should == 5
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#[]" do
|
25
|
-
it "returns the radio button at the given index" do
|
26
|
-
browser.radios[0].id.should == "new_user_newsletter_yes"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "#each" do
|
31
|
-
it "iterates through radio buttons correctly" do
|
32
|
-
count = 0
|
33
|
-
|
34
|
-
browser.radios.each_with_index do |r, index|
|
35
|
-
r.name.should == browser.radio(:index, index).name
|
36
|
-
r.id.should == browser.radio(:index, index).id
|
37
|
-
r.value.should == browser.radio(:index, index).value
|
38
|
-
|
39
|
-
count += 1
|
40
|
-
end
|
41
|
-
|
42
|
-
count.should > 0
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
@@ -1,335 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path("../spec_helper", __FILE__)
|
3
|
-
|
4
|
-
describe "SelectList" do
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
8
|
-
end
|
9
|
-
|
10
|
-
# Exists method
|
11
|
-
describe "#exists?" do
|
12
|
-
it "returns true if the select list exists" do
|
13
|
-
browser.select_list(:id, 'new_user_country').should exist
|
14
|
-
browser.select_list(:id, /new_user_country/).should exist
|
15
|
-
browser.select_list(:name, 'new_user_country').should exist
|
16
|
-
browser.select_list(:name, /new_user_country/).should exist
|
17
|
-
|
18
|
-
not_compliant_on :webdriver do
|
19
|
-
browser.select_list(:text, 'Norway').should exist
|
20
|
-
browser.select_list(:text, /Norway/).should exist
|
21
|
-
end
|
22
|
-
|
23
|
-
browser.select_list(:class, 'country').should exist
|
24
|
-
browser.select_list(:class, /country/).should exist
|
25
|
-
browser.select_list(:index, 0).should exist
|
26
|
-
browser.select_list(:xpath, "//select[@id='new_user_country']").should exist
|
27
|
-
end
|
28
|
-
|
29
|
-
it "returns the first select if given no args" do
|
30
|
-
browser.select_list.should exist
|
31
|
-
end
|
32
|
-
|
33
|
-
it "returns false if the select list doesn't exist" do
|
34
|
-
browser.select_list(:id, 'no_such_id').should_not exist
|
35
|
-
browser.select_list(:id, /no_such_id/).should_not exist
|
36
|
-
browser.select_list(:name, 'no_such_name').should_not exist
|
37
|
-
browser.select_list(:name, /no_such_name/).should_not exist
|
38
|
-
browser.select_list(:value, 'no_such_value').should_not exist
|
39
|
-
browser.select_list(:value, /no_such_value/).should_not exist
|
40
|
-
browser.select_list(:text, 'no_such_text').should_not exist
|
41
|
-
browser.select_list(:text, /no_such_text/).should_not exist
|
42
|
-
browser.select_list(:class, 'no_such_class').should_not exist
|
43
|
-
browser.select_list(:class, /no_such_class/).should_not exist
|
44
|
-
browser.select_list(:index, 1337).should_not exist
|
45
|
-
browser.select_list(:xpath, "//select[@id='no_such_id']").should_not exist
|
46
|
-
end
|
47
|
-
|
48
|
-
it "raises TypeError when 'what' argument is invalid" do
|
49
|
-
lambda { browser.select_list(:id, 3.14).exists? }.should raise_error(TypeError)
|
50
|
-
end
|
51
|
-
|
52
|
-
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
53
|
-
lambda { browser.select_list(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# Attribute methods
|
58
|
-
describe "#class_name" do
|
59
|
-
it "returns the class name of the select list" do
|
60
|
-
browser.select_list(:name, 'new_user_country').class_name.should == 'country'
|
61
|
-
end
|
62
|
-
|
63
|
-
it "raises UnknownObjectException if the select list doesn't exist" do
|
64
|
-
lambda { browser.select_list(:name, 'no_such_name').class_name }.should raise_error(UnknownObjectException)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "#id" do
|
69
|
-
it "returns the id of the element" do
|
70
|
-
browser.select_list(:index, 0).id.should == "new_user_country"
|
71
|
-
end
|
72
|
-
|
73
|
-
it "raises UnknownObjectException if the select list doesn't exist" do
|
74
|
-
lambda { browser.select_list(:index, 1337).id }.should raise_error(UnknownObjectException)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe "#name" do
|
79
|
-
it "returns the name of the element" do
|
80
|
-
browser.select_list(:index, 0).name.should == "new_user_country"
|
81
|
-
end
|
82
|
-
|
83
|
-
it "raises UnknownObjectException if the select list doesn't exist" do
|
84
|
-
lambda { browser.select_list(:index, 1337).name }.should raise_error(UnknownObjectException)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe "#multiple?" do
|
89
|
-
it "knows whether the select list allows multiple slections" do
|
90
|
-
browser.select_list(:index, 0).should_not be_multiple
|
91
|
-
browser.select_list(:index, 1).should be_multiple
|
92
|
-
end
|
93
|
-
|
94
|
-
it "raises UnknownObjectException if the select list doesn't exist" do
|
95
|
-
lambda { browser.select_list(:index, 1337).multiple? }.should raise_error(UnknownObjectException)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
describe "#value" do
|
100
|
-
it "returns the value of the selected option" do
|
101
|
-
browser.select_list(:index, 0).value.should == "2"
|
102
|
-
browser.select_list(:index, 0).select(/Sweden/)
|
103
|
-
browser.select_list(:index, 0).value.should == "3"
|
104
|
-
end
|
105
|
-
|
106
|
-
it "raises UnknownObjectException if the select list doesn't exist" do
|
107
|
-
lambda { browser.select_list(:index, 1337).value }.should raise_error(UnknownObjectException)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe "#respond_to?" do
|
112
|
-
it "returns true for all attribute methods" do
|
113
|
-
browser.select_list(:index, 0).should respond_to(:class_name)
|
114
|
-
browser.select_list(:index, 0).should respond_to(:id)
|
115
|
-
browser.select_list(:index, 0).should respond_to(:name)
|
116
|
-
browser.select_list(:index, 0).should respond_to(:value)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
# Access methods
|
121
|
-
describe "#enabled?" do
|
122
|
-
it "returns true if the select list is enabled" do
|
123
|
-
browser.select_list(:name, 'new_user_country').should be_enabled
|
124
|
-
end
|
125
|
-
|
126
|
-
it "returns false if the select list is disabled" do
|
127
|
-
browser.select_list(:name, 'new_user_role').should_not be_enabled
|
128
|
-
end
|
129
|
-
|
130
|
-
it "raises UnknownObjectException if the select_list doesn't exist" do
|
131
|
-
lambda { browser.select_list(:name, 'no_such_name').enabled? }.should raise_error(UnknownObjectException)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
describe "#disabled?" do
|
136
|
-
it "returns true if the select list is disabled" do
|
137
|
-
browser.select_list(:index, 2).should be_disabled
|
138
|
-
end
|
139
|
-
|
140
|
-
it "returns false if the select list is enabled" do
|
141
|
-
browser.select_list(:index, 0).should_not be_disabled
|
142
|
-
end
|
143
|
-
|
144
|
-
it "should raise UnknownObjectException when the select list does not exist" do
|
145
|
-
lambda { browser.select_list(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
# Other
|
150
|
-
describe "#option" do
|
151
|
-
it "returns an instance of Option" do
|
152
|
-
option = browser.select_list(:name, "new_user_country").option(:text, "Denmark")
|
153
|
-
option.should be_instance_of(Option)
|
154
|
-
option.value.should == "1"
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
describe "#options" do
|
159
|
-
it "should raise UnknownObjectException if the select list doesn't exist" do
|
160
|
-
lambda { browser.select_list(:name, 'no_such_name').options }.should raise_error(UnknownObjectException)
|
161
|
-
end
|
162
|
-
|
163
|
-
#
|
164
|
-
# The correct behaviour here needs to be discussed.
|
165
|
-
#
|
166
|
-
|
167
|
-
not_compliant_on :webdriver do
|
168
|
-
it "returns all the options as an Array" do
|
169
|
-
browser.select_list(:name, "new_user_country").options.should == ["Denmark", "Norway", "Sweden", "United Kingdom", "USA", "Germany"]
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
deviates_on :webdriver do
|
174
|
-
it "returns all the options as a collection of Options" do
|
175
|
-
options = browser.select_list(:name, "new_user_country").options
|
176
|
-
options.should be_kind_of(OptionCollection)
|
177
|
-
options.map { |opt| opt.text }.should == ["Denmark", "Norway", "Sweden", "United Kingdom", "USA", "Germany"]
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
describe "#selected_options" do
|
183
|
-
it "should raise UnknownObjectException if the select list doesn't exist" do
|
184
|
-
lambda { browser.select_list(:name, 'no_such_name').selected_options }.should raise_error(UnknownObjectException)
|
185
|
-
end
|
186
|
-
|
187
|
-
it "gets the currently selected item(s)" do
|
188
|
-
browser.select_list(:name, "new_user_country").selected_options.should == ["Norway"]
|
189
|
-
browser.select_list(:name, "new_user_languages").selected_options.should == ["English", "Norwegian"]
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
describe "#clear" do
|
194
|
-
it "clears the selection when possible" do
|
195
|
-
browser.select_list(:name, "new_user_languages").clear
|
196
|
-
browser.select_list(:name, "new_user_languages").selected_options.should be_empty
|
197
|
-
end
|
198
|
-
|
199
|
-
it "does not clear selections when not possible" do
|
200
|
-
lambda { browser.select_list(:name, "new_user_country").clear }.should raise_error
|
201
|
-
browser.select_list(:name, "new_user_country").selected_options.should == ["Norway"]
|
202
|
-
end
|
203
|
-
|
204
|
-
it "raises UnknownObjectException if the select list doesn't exist" do
|
205
|
-
lambda { browser.select_list(:name, 'no_such_name').clear }.should raise_error(UnknownObjectException)
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
describe "#include?" do
|
210
|
-
it "returns true if the given option exists" do
|
211
|
-
browser.select_list(:name, 'new_user_country').should include('Denmark')
|
212
|
-
end
|
213
|
-
|
214
|
-
it "returns false if the given option doesn't exist" do
|
215
|
-
browser.select_list(:name, 'new_user_country').should_not include('Ireland')
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
describe "#selected?" do
|
220
|
-
it "returns true if the given option is selected" do
|
221
|
-
browser.select_list(:name, 'new_user_country').select('Denmark')
|
222
|
-
browser.select_list(:name, 'new_user_country').should be_selected('Denmark')
|
223
|
-
end
|
224
|
-
|
225
|
-
it "returns false if the given option is not selected" do
|
226
|
-
browser.select_list(:name, 'new_user_country').should_not be_selected('Sweden')
|
227
|
-
end
|
228
|
-
|
229
|
-
it "raises UnknonwObjectException if the option doesn't exist" do
|
230
|
-
lambda { browser.select_list(:name, 'new_user_country').selected?('missing_option') }.should raise_error(UnknownObjectException)
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
describe "#select" do
|
235
|
-
it "selects the given item when given a String" do
|
236
|
-
browser.select_list(:name, "new_user_country").select("Denmark")
|
237
|
-
browser.select_list(:name, "new_user_country").selected_options.should == ["Denmark"]
|
238
|
-
end
|
239
|
-
|
240
|
-
it "selects options by label" do
|
241
|
-
browser.select_list(:name, "new_user_country").select("Germany")
|
242
|
-
browser.select_list(:name, "new_user_country").selected_options.should == ["Germany"]
|
243
|
-
end
|
244
|
-
|
245
|
-
it "selects the given item when given a Regexp" do
|
246
|
-
browser.select_list(:name, "new_user_country").select(/Denmark/)
|
247
|
-
browser.select_list(:name, "new_user_country").selected_options.should == ["Denmark"]
|
248
|
-
end
|
249
|
-
|
250
|
-
it "selects the given item when given an Xpath" do
|
251
|
-
browser.select_list(:xpath, "//select[@name='new_user_country']").select("Denmark")
|
252
|
-
browser.select_list(:xpath, "//select[@name='new_user_country']").selected_options.should == ["Denmark"]
|
253
|
-
end
|
254
|
-
|
255
|
-
it "selects multiple items using :name and a String" do
|
256
|
-
browser.select_list(:name, "new_user_languages").clear
|
257
|
-
browser.select_list(:name, "new_user_languages").select("Danish")
|
258
|
-
browser.select_list(:name, "new_user_languages").select("Swedish")
|
259
|
-
browser.select_list(:name, "new_user_languages").selected_options.should == ["Danish", "Swedish"]
|
260
|
-
end
|
261
|
-
|
262
|
-
it "selects multiple items using :name and a Regexp" do
|
263
|
-
browser.select_list(:name, "new_user_languages").clear
|
264
|
-
browser.select_list(:name, "new_user_languages").select(/ish/)
|
265
|
-
browser.select_list(:name, "new_user_languages").selected_options.should == ["Danish", "English", "Swedish"]
|
266
|
-
end
|
267
|
-
|
268
|
-
it "selects multiple items using :xpath" do
|
269
|
-
browser.select_list(:xpath, "//select[@name='new_user_languages']").clear
|
270
|
-
browser.select_list(:xpath, "//select[@name='new_user_languages']").select(/ish/)
|
271
|
-
browser.select_list(:xpath, "//select[@name='new_user_languages']").selected_options.should == ["Danish", "English", "Swedish"]
|
272
|
-
end
|
273
|
-
|
274
|
-
it "selects empty options" do
|
275
|
-
browser.select_list(:id, "delete_user_username").select("")
|
276
|
-
browser.select_list(:id, "delete_user_username").selected_options.should == [""]
|
277
|
-
end
|
278
|
-
|
279
|
-
it "returns the value selected" do
|
280
|
-
browser.select_list(:name, "new_user_languages").select("Danish").should == "Danish"
|
281
|
-
end
|
282
|
-
|
283
|
-
it "returns the first matching value if there are multiple matches" do
|
284
|
-
browser.select_list(:name, "new_user_languages").select(/ish/).should == "Danish"
|
285
|
-
end
|
286
|
-
|
287
|
-
bug "http://code.google.com/p/selenium/issues/detail?id=695", [:webdriver, :ie] do
|
288
|
-
it "fires onchange event when selecting an item" do
|
289
|
-
browser.select_list(:id, "new_user_languages").select("Danish")
|
290
|
-
messages.should == ['changed language']
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
bug "http://code.google.com/p/selenium/issues/detail?id=695", [:webdriver, :ie] do
|
295
|
-
it "doesn't fire onchange event when selecting an already selected item" do
|
296
|
-
browser.select_list(:id, "new_user_languages").clear # removes the two pre-selected options
|
297
|
-
browser.select_list(:id, "new_user_languages").select("English")
|
298
|
-
messages.size.should == 3
|
299
|
-
|
300
|
-
browser.select_list(:id, "new_user_languages").select("English")
|
301
|
-
messages.size.should == 3
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
it "raises NoValueFoundException if the option doesn't exist" do
|
306
|
-
lambda { browser.select_list(:name, "new_user_country").select("missing_option") }.should raise_error(NoValueFoundException)
|
307
|
-
lambda { browser.select_list(:name, "new_user_country").select(/missing_option/) }.should raise_error(NoValueFoundException)
|
308
|
-
end
|
309
|
-
|
310
|
-
it "raises a TypeError if argument is not a String, Regexp or Numeric" do
|
311
|
-
lambda { browser.select_list(:id, "new_user_languages").select([]) }.should raise_error(TypeError)
|
312
|
-
end
|
313
|
-
end
|
314
|
-
|
315
|
-
# deprecate?
|
316
|
-
describe "#select_value" do
|
317
|
-
it "selects the item by value string" do
|
318
|
-
browser.select_list(:name, "new_user_languages").clear
|
319
|
-
browser.select_list(:name, "new_user_languages").select_value("2")
|
320
|
-
browser.select_list(:name, "new_user_languages").selected_options.should == %w[English]
|
321
|
-
end
|
322
|
-
|
323
|
-
it "selects the items by value regexp" do
|
324
|
-
browser.select_list(:name, "new_user_languages").clear
|
325
|
-
browser.select_list(:name, "new_user_languages").select_value(/1|3/)
|
326
|
-
browser.select_list(:name, "new_user_languages").selected_options.should == %w[Danish Norwegian]
|
327
|
-
end
|
328
|
-
|
329
|
-
it "raises NoValueFoundException if the option doesn't exist" do
|
330
|
-
lambda { browser.select_list(:name, "new_user_languages").select_value("no_such_option") }.should raise_error(NoValueFoundException)
|
331
|
-
lambda { browser.select_list(:name, "new_user_languages").select_value(/no_such_option/) }.should raise_error(NoValueFoundException)
|
332
|
-
end
|
333
|
-
end
|
334
|
-
|
335
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path("../spec_helper", __FILE__)
|
3
|
-
|
4
|
-
describe "SelectLists" do
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
|
8
|
-
end
|
9
|
-
|
10
|
-
bug "http://github.com/jarib/celerity/issues#issue/25", :celerity do
|
11
|
-
describe "with selectors" do
|
12
|
-
it "returns the matching elements" do
|
13
|
-
browser.select_lists(:name => "delete_user_username").to_a.should == [browser.select_list(:name => "delete_user_username")]
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "#length" do
|
19
|
-
it "returns the correct number of select lists on the page" do
|
20
|
-
browser.select_lists.length.should == 4
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#[]" do
|
25
|
-
it "returns the correct item" do
|
26
|
-
browser.select_lists[0].value.should == "2"
|
27
|
-
browser.select_lists[0].name.should == "new_user_country"
|
28
|
-
browser.select_lists[0].should_not be_multiple
|
29
|
-
browser.select_lists[1].should be_multiple
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "#each" do
|
34
|
-
it "iterates through the select lists correctly" do
|
35
|
-
count = 0
|
36
|
-
|
37
|
-
browser.select_lists.each_with_index do |l, index|
|
38
|
-
browser.select_list(:index, index).name.should == l.name
|
39
|
-
browser.select_list(:index, index).id.should == l.id
|
40
|
-
browser.select_list(:index, index).value.should == l.value
|
41
|
-
|
42
|
-
count += 1
|
43
|
-
end
|
44
|
-
|
45
|
-
count.should > 0
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
data/spec/watirspec/span_spec.rb
DELETED
@@ -1,146 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require File.expand_path("../spec_helper", __FILE__)
|
3
|
-
|
4
|
-
describe "Span" do
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
browser.goto(WatirSpec.files + "/non_control_elements.html")
|
8
|
-
end
|
9
|
-
|
10
|
-
# Exists method
|
11
|
-
describe "#exist?" do
|
12
|
-
it "returns true if the 'span' exists" do
|
13
|
-
browser.span(:id, "lead").should exist
|
14
|
-
browser.span(:id, /lead/).should exist
|
15
|
-
browser.span(:text, "Dubito, ergo cogito, ergo sum.").should exist
|
16
|
-
browser.span(:text, /Dubito, ergo cogito, ergo sum/).should exist
|
17
|
-
browser.span(:class, "lead").should exist
|
18
|
-
browser.span(:class, /lead/).should exist
|
19
|
-
browser.span(:index, 0).should exist
|
20
|
-
browser.span(:xpath, "//span[@id='lead']").should exist
|
21
|
-
end
|
22
|
-
|
23
|
-
it "returns the first span if given no args" do
|
24
|
-
browser.span.should exist
|
25
|
-
end
|
26
|
-
|
27
|
-
it "returns false if the element doesn't exist" do
|
28
|
-
browser.span(:id, "no_such_id").should_not exist
|
29
|
-
browser.span(:id, /no_such_id/).should_not exist
|
30
|
-
browser.span(:text, "no_such_text").should_not exist
|
31
|
-
browser.span(:text, /no_such_text/).should_not exist
|
32
|
-
browser.span(:class, "no_such_class").should_not exist
|
33
|
-
browser.span(:class, /no_such_class/).should_not exist
|
34
|
-
browser.span(:index, 1337).should_not exist
|
35
|
-
browser.span(:xpath, "//span[@id='no_such_id']").should_not exist
|
36
|
-
end
|
37
|
-
|
38
|
-
it "raises TypeError when 'what' argument is invalid" do
|
39
|
-
lambda { browser.span(:id, 3.14).exists? }.should raise_error(TypeError)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
|
43
|
-
lambda { browser.span(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# Attribute methods
|
48
|
-
describe "#class_name" do
|
49
|
-
it "returns the class attribute" do
|
50
|
-
browser.span(:index, 0).class_name.should == 'lead'
|
51
|
-
end
|
52
|
-
|
53
|
-
it "returns an empty string if the element exists and the attribute doesn't" do
|
54
|
-
browser.span(:index, 2).class_name.should == ''
|
55
|
-
end
|
56
|
-
|
57
|
-
it "raises UnknownObjectException if the span doesn't exist" do
|
58
|
-
lambda { browser.span(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "#id" do
|
63
|
-
it "returns the id attribute" do
|
64
|
-
browser.span(:index, 0).id.should == "lead"
|
65
|
-
end
|
66
|
-
|
67
|
-
it "returns an empty string if the element exists and the attribute doesn't" do
|
68
|
-
browser.span(:index, 2).id.should == ''
|
69
|
-
end
|
70
|
-
|
71
|
-
it "raises UnknownObjectException if the span doesn't exist" do
|
72
|
-
lambda { browser.span(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
|
73
|
-
lambda { browser.span(:index, 1337).id }.should raise_error(UnknownObjectException)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe "#title" do
|
78
|
-
it "returns the title attribute" do
|
79
|
-
browser.span(:index, 0).title.should == 'Lorem ipsum'
|
80
|
-
end
|
81
|
-
|
82
|
-
it "returns an empty string if the element exists and the attribute doesn't" do
|
83
|
-
browser.span(:index, 2).title.should == ''
|
84
|
-
end
|
85
|
-
|
86
|
-
it "raises UnknownObjectException if the span doesn't exist" do
|
87
|
-
lambda { browser.span(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
|
88
|
-
lambda { browser.span(:xpath, "//span[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe "#text" do
|
93
|
-
it "returns the text of the span" do
|
94
|
-
browser.span(:index, 1).text.should == 'Sed pretium metus et quam. Nullam odio dolor, vestibulum non, tempor ut, vehicula sed, sapien. Vestibulum placerat ligula at quam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.'
|
95
|
-
end
|
96
|
-
|
97
|
-
it "returns an empty string if the element doesn't contain any text" do
|
98
|
-
browser.span(:index, 4).text.should == ''
|
99
|
-
end
|
100
|
-
|
101
|
-
it "raises UnknownObjectException if the span doesn't exist" do
|
102
|
-
lambda { browser.span(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
|
103
|
-
lambda { browser.span(:xpath , "//span[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe "#value" do
|
108
|
-
it "returns the value attribute" do
|
109
|
-
browser.span(:index, 1).value.should == "invalid_attribute"
|
110
|
-
end
|
111
|
-
|
112
|
-
it "returns an empty string if the element exists and the attribute doesn't" do
|
113
|
-
browser.span(:index, 2).value.should == ''
|
114
|
-
end
|
115
|
-
|
116
|
-
it "raises UnknownObjectException if the span doesn't exist" do
|
117
|
-
lambda { browser.span(:id , "no_such_id").value }.should raise_error(UnknownObjectException)
|
118
|
-
lambda { browser.span(:index , 1337).value }.should raise_error(UnknownObjectException)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe "#respond_to?" do
|
123
|
-
it "returns true for all attribute methods" do
|
124
|
-
browser.span(:index, 0).should respond_to(:class_name)
|
125
|
-
browser.span(:index, 0).should respond_to(:id)
|
126
|
-
browser.span(:index, 0).should respond_to(:title)
|
127
|
-
browser.span(:index, 0).should respond_to(:text)
|
128
|
-
browser.span(:index, 0).should respond_to(:value)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
# Other
|
133
|
-
describe "#click" do
|
134
|
-
it "fires events" do
|
135
|
-
browser.span(:class, 'footer').text.should_not include('Javascript')
|
136
|
-
browser.span(:class, 'footer').click
|
137
|
-
browser.span(:class, 'footer').text.should include('Javascript')
|
138
|
-
end
|
139
|
-
|
140
|
-
it "raises UnknownObjectException if the span doesn't exist" do
|
141
|
-
lambda { browser.span(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
|
142
|
-
lambda { browser.span(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
end
|