watir-webdriver 0.0.1.dev5 → 0.0.1.dev6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/Rakefile +13 -19
  2. data/VERSION +1 -1
  3. data/lib/watir-webdriver.rb +3 -1
  4. data/lib/watir-webdriver/base_element.rb +33 -27
  5. data/lib/watir-webdriver/browser.rb +2 -6
  6. data/lib/watir-webdriver/elements/font.rb +12 -0
  7. data/lib/watir-webdriver/elements/generated.rb +1027 -622
  8. data/lib/watir-webdriver/elements/select_list.rb +3 -3
  9. data/lib/watir-webdriver/locators/element_locator.rb +2 -2
  10. data/lib/watir-webdriver/xpath_support.rb +2 -2
  11. data/support/html5/html5.idl +942 -483
  12. data/support/html5/old/html5.idl +962 -0
  13. data/support/html5/{html5_extras.idl → old/html5_extras.idl} +0 -2
  14. data/support/html5/watir_visitor.rb +23 -19
  15. metadata +74 -100
  16. data/spec/watirspec/area_spec.rb +0 -78
  17. data/spec/watirspec/areas_spec.rb +0 -31
  18. data/spec/watirspec/browser_spec.rb +0 -274
  19. data/spec/watirspec/button_spec.rb +0 -242
  20. data/spec/watirspec/buttons_spec.rb +0 -48
  21. data/spec/watirspec/checkbox_spec.rb +0 -272
  22. data/spec/watirspec/checkboxes_spec.rb +0 -32
  23. data/spec/watirspec/dd_spec.rb +0 -123
  24. data/spec/watirspec/dds_spec.rb +0 -31
  25. data/spec/watirspec/div_spec.rb +0 -211
  26. data/spec/watirspec/divs_spec.rb +0 -31
  27. data/spec/watirspec/dl_spec.rb +0 -123
  28. data/spec/watirspec/dls_spec.rb +0 -32
  29. data/spec/watirspec/dt_spec.rb +0 -123
  30. data/spec/watirspec/dts_spec.rb +0 -31
  31. data/spec/watirspec/element_spec.rb +0 -89
  32. data/spec/watirspec/em_spec.rb +0 -97
  33. data/spec/watirspec/ems_spec.rb +0 -32
  34. data/spec/watirspec/filefield_spec.rb +0 -119
  35. data/spec/watirspec/filefields_spec.rb +0 -32
  36. data/spec/watirspec/form_spec.rb +0 -63
  37. data/spec/watirspec/forms_spec.rb +0 -33
  38. data/spec/watirspec/frame_spec.rb +0 -129
  39. data/spec/watirspec/frames_spec.rb +0 -62
  40. data/spec/watirspec/hidden_spec.rb +0 -102
  41. data/spec/watirspec/hiddens_spec.rb +0 -32
  42. data/spec/watirspec/hn_spec.rb +0 -93
  43. data/spec/watirspec/hns_spec.rb +0 -38
  44. data/spec/watirspec/image_spec.rb +0 -207
  45. data/spec/watirspec/images_spec.rb +0 -31
  46. data/spec/watirspec/label_spec.rb +0 -75
  47. data/spec/watirspec/labels_spec.rb +0 -31
  48. data/spec/watirspec/li_spec.rb +0 -112
  49. data/spec/watirspec/lib/guards.rb +0 -59
  50. data/spec/watirspec/lib/server.rb +0 -127
  51. data/spec/watirspec/lib/spec_helper.rb +0 -79
  52. data/spec/watirspec/lib/watirspec.rb +0 -72
  53. data/spec/watirspec/link_spec.rb +0 -168
  54. data/spec/watirspec/links_spec.rb +0 -35
  55. data/spec/watirspec/lis_spec.rb +0 -31
  56. data/spec/watirspec/map_spec.rb +0 -76
  57. data/spec/watirspec/maps_spec.rb +0 -32
  58. data/spec/watirspec/meta_spec.rb +0 -22
  59. data/spec/watirspec/metas_spec.rb +0 -30
  60. data/spec/watirspec/ol_spec.rb +0 -78
  61. data/spec/watirspec/ols_spec.rb +0 -31
  62. data/spec/watirspec/option_spec.rb +0 -173
  63. data/spec/watirspec/p_spec.rb +0 -128
  64. data/spec/watirspec/pre_spec.rb +0 -112
  65. data/spec/watirspec/pres_spec.rb +0 -31
  66. data/spec/watirspec/ps_spec.rb +0 -31
  67. data/spec/watirspec/radio_spec.rb +0 -255
  68. data/spec/watirspec/radios_spec.rb +0 -32
  69. data/spec/watirspec/select_list_spec.rb +0 -318
  70. data/spec/watirspec/select_lists_spec.rb +0 -35
  71. data/spec/watirspec/span_spec.rb +0 -142
  72. data/spec/watirspec/spans_spec.rb +0 -31
  73. data/spec/watirspec/spec_helper.rb +0 -17
  74. data/spec/watirspec/strong_spec.rb +0 -89
  75. data/spec/watirspec/strongs_spec.rb +0 -32
  76. data/spec/watirspec/table_bodies_spec.rb +0 -45
  77. data/spec/watirspec/table_body_spec.rb +0 -98
  78. data/spec/watirspec/table_cell_spec.rb +0 -68
  79. data/spec/watirspec/table_cells_spec.rb +0 -47
  80. data/spec/watirspec/table_footer_spec.rb +0 -85
  81. data/spec/watirspec/table_footers_spec.rb +0 -47
  82. data/spec/watirspec/table_header_spec.rb +0 -85
  83. data/spec/watirspec/table_headers_spec.rb +0 -45
  84. data/spec/watirspec/table_row_spec.rb +0 -87
  85. data/spec/watirspec/table_rows_spec.rb +0 -50
  86. data/spec/watirspec/table_spec.rb +0 -160
  87. data/spec/watirspec/tables_spec.rb +0 -33
  88. data/spec/watirspec/text_field_spec.rb +0 -276
  89. data/spec/watirspec/text_fields_spec.rb +0 -35
  90. data/spec/watirspec/ul_spec.rb +0 -76
  91. data/spec/watirspec/uls_spec.rb +0 -33
  92. data/support/html5/idl_extractor.rb +0 -73
@@ -1,32 +0,0 @@
1
- # encoding: utf-8
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- describe "Radios" do
5
-
6
- before :each do
7
- browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
8
- end
9
-
10
- describe "#length" do
11
- it "returns the number of radios" do
12
- browser.radios.length.should == 5
13
- end
14
- end
15
-
16
- describe "#[]" do
17
- it "returns the radio button at the given index" do
18
- browser.radios[0].id.should == "new_user_newsletter_yes"
19
- end
20
- end
21
-
22
- describe "#each" do
23
- it "iterates through radio buttons correctly" do
24
- browser.radios.each_with_index do |r, index|
25
- r.name.should == browser.radio(:index, index).name
26
- r.id.should == browser.radio(:index, index).id
27
- r.value.should == browser.radio(:index, index).value
28
- end
29
- end
30
- end
31
-
32
- end
@@ -1,318 +0,0 @@
1
- # encoding: utf-8
2
- require File.dirname(__FILE__) + '/spec_helper'
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
- # TODO: check behaviour in Watir
18
- # browser.select_list(:value, 'Norway').should exist
19
- # browser.select_list(:value, /Norway/).should exist
20
- browser.select_list(:text, 'Norway').should exist
21
- browser.select_list(:text, /Norway/).should exist
22
- browser.select_list(:class, 'country').should exist
23
- browser.select_list(:class, /country/).should exist
24
- browser.select_list(:index, 0).should exist
25
- browser.select_list(:xpath, "//select[@id='new_user_country']").should exist
26
- end
27
-
28
- it "returns false if the select list doesn't exist" do
29
- browser.select_list(:id, 'no_such_id').should_not exist
30
- browser.select_list(:id, /no_such_id/).should_not exist
31
- browser.select_list(:name, 'no_such_name').should_not exist
32
- browser.select_list(:name, /no_such_name/).should_not exist
33
- browser.select_list(:value, 'no_such_value').should_not exist
34
- browser.select_list(:value, /no_such_value/).should_not exist
35
- browser.select_list(:text, 'no_such_text').should_not exist
36
- browser.select_list(:text, /no_such_text/).should_not exist
37
- browser.select_list(:class, 'no_such_class').should_not exist
38
- browser.select_list(:class, /no_such_class/).should_not exist
39
- browser.select_list(:index, 1337).should_not exist
40
- browser.select_list(:xpath, "//select[@id='no_such_id']").should_not exist
41
- end
42
-
43
- it "raises TypeError when 'what' argument is invalid" do
44
- lambda { browser.select_list(:id, 3.14).exists? }.should raise_error(TypeError)
45
- end
46
-
47
- it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
48
- lambda { browser.select_list(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
49
- end
50
- end
51
-
52
- # Attribute methods
53
- describe "#class_name" do
54
- it "returns the class name of the select list" do
55
- browser.select_list(:name, 'new_user_country').class_name.should == 'country'
56
- end
57
-
58
- it "raises UnknownObjectException if the select list doesn't exist" do
59
- lambda { browser.select_list(:name, 'no_such_name').class_name }.should raise_error(UnknownObjectException)
60
- end
61
- end
62
-
63
- describe "#id" do
64
- it "returns the id of the element" do
65
- browser.select_list(:index, 0).id.should == "new_user_country"
66
- end
67
-
68
- it "raises UnknownObjectException if the select list doesn't exist" do
69
- lambda { browser.select_list(:index, 1337).id }.should raise_error(UnknownObjectException)
70
- end
71
- end
72
-
73
- describe "#name" do
74
- it "returns the name of the element" do
75
- browser.select_list(:index, 0).name.should == "new_user_country"
76
- end
77
-
78
- it "raises UnknownObjectException if the select list doesn't exist" do
79
- lambda { browser.select_list(:index, 1337).name }.should raise_error(UnknownObjectException)
80
- end
81
- end
82
-
83
- describe "#multiple?" do
84
- it "knows whether the select list allows multiple slections" do
85
- browser.select_list(:index, 0).should_not be_multiple
86
- browser.select_list(:index, 1).should be_multiple
87
- end
88
-
89
- it "raises UnknownObjectException if the select list doesn't exist" do
90
- lambda { browser.select_list(:index, 1337).multiple? }.should raise_error(UnknownObjectException)
91
- end
92
- end
93
-
94
- describe "#value" do
95
- it "returns the value of the selected option" do
96
- browser.select_list(:index, 0).value.should == "2"
97
- browser.select_list(:index, 0).select(/Sweden/)
98
- browser.select_list(:index, 0).value.should == "3"
99
- end
100
-
101
- it "raises UnknownObjectException if the select list doesn't exist" do
102
- lambda { browser.select_list(:index, 1337).value }.should raise_error(UnknownObjectException)
103
- end
104
- end
105
-
106
- describe "#respond_to?" do
107
- it "returns true for all attribute methods" do
108
- browser.select_list(:index, 0).should respond_to(:class_name)
109
- browser.select_list(:index, 0).should respond_to(:id)
110
- browser.select_list(:index, 0).should respond_to(:name)
111
- browser.select_list(:index, 0).should respond_to(:value)
112
- end
113
- end
114
-
115
- # Access methods
116
- describe "#enabled?" do
117
- it "returns true if the select list is enabled" do
118
- browser.select_list(:name, 'new_user_country').should be_enabled
119
- end
120
-
121
- it "returns false if the select list is disabled" do
122
- browser.select_list(:name, 'new_user_role').should_not be_enabled
123
- end
124
-
125
- it "raises UnknownObjectException if the select_list doesn't exist" do
126
- lambda { browser.select_list(:name, 'no_such_name').enabled? }.should raise_error(UnknownObjectException)
127
- end
128
- end
129
-
130
- describe "#disabled?" do
131
- it "returns true if the select list is disabled" do
132
- browser.select_list(:index, 2).should be_disabled
133
- end
134
-
135
- it "returns false if the select list is enabled" do
136
- browser.select_list(:index, 0).should_not be_disabled
137
- end
138
-
139
- it "shoulds raise UnknownObjectException when the select list does not exist" do
140
- lambda { browser.select_list(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
141
- end
142
- end
143
-
144
- # Other
145
- describe "#option" do
146
- it "returns an instance of Option" do
147
- option = browser.select_list(:name, "new_user_country").option(:text, "Denmark")
148
- option.should be_instance_of(Option)
149
- option.value.should == "1"
150
- end
151
- end
152
-
153
- describe "#options" do
154
- it "shoulds raise UnknownObjectException if the select list doesn't exist" do
155
- lambda { browser.select_list(:name, 'no_such_name').options }.should raise_error(UnknownObjectException)
156
- end
157
-
158
- bug "WTR-339", :watir do
159
- it "returns all the options as an Array" do
160
- browser.select_list(:name, "new_user_country").options.should == ["Denmark" ,"Norway" , "Sweden" , "United Kingdom", "USA", "Germany"]
161
- end
162
- end
163
- end
164
-
165
- describe "#selected_options" do
166
- it "shoulds raise UnknownObjectException if the select list doesn't exist" do
167
- lambda { browser.select_list(:name, 'no_such_name').selected_options }.should raise_error(UnknownObjectException)
168
- end
169
-
170
- it "gets the currently selected item(s)" do
171
- browser.select_list(:name, "new_user_country").selected_options.should == ["Norway"]
172
- browser.select_list(:name, "new_user_languages").selected_options.should == ["English", "Norwegian"]
173
- end
174
- end
175
-
176
- describe "#clear" do
177
- it "clears the selection when possible" do
178
- browser.select_list(:name, "new_user_languages").clear
179
- browser.select_list(:name, "new_user_languages").selected_options.should be_empty
180
- end
181
-
182
- it "does not clear selections when not possible" do
183
- lambda { browser.select_list(:name , "new_user_country").clear }.should raise_error
184
- browser.select_list(:name, "new_user_country").selected_options.should == ["Norway"]
185
- end
186
-
187
- it "raises UnknownObjectException if the select list doesn't exist" do
188
- lambda { browser.select_list(:name, 'no_such_name').clear }.should raise_error(UnknownObjectException)
189
- end
190
- end
191
-
192
- describe "#includes?" do
193
- it "returns true if the given option exists" do
194
- browser.select_list(:name, 'new_user_country').includes?('Denmark').should be_true
195
- end
196
-
197
- it "returns false if the given option doesn't exist" do
198
- browser.select_list(:name, 'new_user_country').includes?('Ireland').should be_false
199
- end
200
- end
201
-
202
- describe "#selected?" do
203
- it "returns true if the given option is selected" do
204
- browser.select_list(:name, 'new_user_country').select('Denmark')
205
- browser.select_list(:name, 'new_user_country').selected?('Denmark').should be_true
206
- end
207
-
208
- it "returns false if the given option is not selected" do
209
- browser.select_list(:name, 'new_user_country').selected?('Sweden').should be_false
210
- end
211
-
212
- it "raises UnknonwObjectException if the option doesn't exist" do
213
- lambda { browser.select_list(:name, 'new_user_country').selected?('missing_option') }.should raise_error(UnknownObjectException)
214
- end
215
- end
216
-
217
- describe "#select" do
218
- it "selects the given item when given a String" do
219
- browser.select_list(:name, "new_user_country").select("Denmark")
220
- browser.select_list(:name, "new_user_country").selected_options.should == ["Denmark"]
221
- end
222
-
223
- it "selects options by label" do
224
- browser.select_list(:name, "new_user_country").select("Germany")
225
- browser.select_list(:name, "new_user_country").selected_options.should == ["Germany"]
226
- end
227
-
228
- it "selects the given item when given a Regexp" do
229
- browser.select_list(:name, "new_user_country").select(/Denmark/)
230
- browser.select_list(:name, "new_user_country").selected_options.should == ["Denmark"]
231
- end
232
-
233
- it "selects the given item when given an Xpath" do
234
- browser.select_list(:xpath, "//select[@name='new_user_country']").select("Denmark")
235
- browser.select_list(:xpath, "//select[@name='new_user_country']").selected_options.should == ["Denmark"]
236
- end
237
-
238
- it "selects multiple items using :name and a String" do
239
- browser.select_list(:name, "new_user_languages").clear
240
- browser.select_list(:name, "new_user_languages").select("Danish")
241
- browser.select_list(:name, "new_user_languages").select("Swedish")
242
- browser.select_list(:name, "new_user_languages").selected_options.should == ["Danish", "Swedish"]
243
- end
244
-
245
- bug "WTR-362", :watir do
246
- it "selects multiple items using :name and a Regexp" do
247
- browser.select_list(:name, "new_user_languages").clear
248
- browser.select_list(:name, "new_user_languages").select(/ish/)
249
- browser.select_list(:name, "new_user_languages").selected_options.should == ["Danish", "English", "Swedish"]
250
- end
251
-
252
- it "selects multiple items using :xpath" do
253
- browser.select_list(:xpath, "//select[@name='new_user_languages']").clear
254
- browser.select_list(:xpath, "//select[@name='new_user_languages']").select(/ish/)
255
- browser.select_list(:xpath, "//select[@name='new_user_languages']").selected_options.should == ["Danish", "English", "Swedish"]
256
- end
257
- end
258
-
259
- it "selects empty options" do
260
- browser.select_list(:id, "delete_user_username").select("")
261
- browser.select_list(:id, "delete_user_username").selected_options.should == [""]
262
- end
263
-
264
- bug "WTR-363", :watir do
265
- it "returns the value selected" do
266
- browser.select_list(:name, "new_user_languages").select("Danish").should == "Danish"
267
- end
268
-
269
- it "returns the first matching value if there are multiple matches" do
270
- browser.select_list(:name, "new_user_languages").select(/ish/).should == "Danish"
271
- end
272
- end
273
-
274
- it "fires onchange event when selecting an item" do
275
- browser.select_list(:id, "new_user_languages").select("Danish")
276
- messages.should == ['changed language']
277
- end
278
-
279
- bug "WTR-364", :watir do
280
- it "doesn't fire onchange event when selecting an already selected item" do
281
- browser.select_list(:id, "new_user_languages").clear # removes the two pre-selected options
282
- browser.select_list(:id, "new_user_languages").select("English")
283
- messages.size.should == 3
284
-
285
- browser.select_list(:id, "new_user_languages").select("English")
286
- messages.size.should == 3
287
- end
288
- end
289
-
290
- it "raises NoValueFoundException if the option doesn't exist" do
291
- lambda { browser.select_list(:name, "new_user_country").select("missing_option") }.should raise_error(NoValueFoundException)
292
- lambda { browser.select_list(:name, "new_user_country").select(/missing_option/) }.should raise_error(NoValueFoundException)
293
- end
294
- end
295
-
296
- # deprecate?
297
- describe "#select_value" do
298
- it "selects the item by value string" do
299
- browser.select_list(:name, "new_user_languages").clear
300
- browser.select_list(:name, "new_user_languages").select_value("2")
301
- browser.select_list(:name, "new_user_languages").selected_options.should == %w[English]
302
- end
303
-
304
- bug "WTR-362", :watir do
305
- it "selects the items by value regexp" do
306
- browser.select_list(:name, "new_user_languages").clear
307
- browser.select_list(:name, "new_user_languages").select_value(/1|3/)
308
- browser.select_list(:name, "new_user_languages").selected_options.should == %w[Danish Norwegian]
309
- end
310
- end
311
-
312
- it "raises NoValueFoundException if the option doesn't exist" do
313
- lambda { browser.select_list(:name, "new_user_languages").select_value("no_such_option") }.should raise_error(NoValueFoundException)
314
- lambda { browser.select_list(:name, "new_user_languages").select_value(/no_such_option/) }.should raise_error(NoValueFoundException)
315
- end
316
- end
317
-
318
- end
@@ -1,35 +0,0 @@
1
- # encoding: utf-8
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- describe "SelectLists" do
5
-
6
- before :each do
7
- browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
8
- end
9
-
10
- describe "#length" do
11
- it "returns the correct number of select lists on the page" do
12
- browser.select_lists.length.should == 4
13
- end
14
- end
15
-
16
- describe "#[]" do
17
- it "returns the correct item" do
18
- browser.select_lists[0].value.should == "2"
19
- browser.select_lists[0].name.should == "new_user_country"
20
- browser.select_lists[0].should_not be_multiple
21
- browser.select_lists[1].should be_multiple
22
- end
23
- end
24
-
25
- describe "#each" do
26
- it "iterates through the select lists correctly" do
27
- browser.select_lists.each_with_index do |l, index|
28
- browser.select_list(:index, index).name.should == l.name
29
- browser.select_list(:index, index).id.should == l.id
30
- browser.select_list(:index, index).value.should == l.value
31
- end
32
- end
33
- end
34
-
35
- end
@@ -1,142 +0,0 @@
1
- # encoding: utf-8
2
- require File.dirname(__FILE__) + '/spec_helper'
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 false if the element doesn't exist" do
24
- browser.span(:id, "no_such_id").should_not exist
25
- browser.span(:id, /no_such_id/).should_not exist
26
- browser.span(:text, "no_such_text").should_not exist
27
- browser.span(:text, /no_such_text/).should_not exist
28
- browser.span(:class, "no_such_class").should_not exist
29
- browser.span(:class, /no_such_class/).should_not exist
30
- browser.span(:index, 1337).should_not exist
31
- browser.span(:xpath, "//span[@id='no_such_id']").should_not exist
32
- end
33
-
34
- it "raises TypeError when 'what' argument is invalid" do
35
- lambda { browser.span(:id, 3.14).exists? }.should raise_error(TypeError)
36
- end
37
-
38
- it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
39
- lambda { browser.span(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
40
- end
41
- end
42
-
43
- # Attribute methods
44
- describe "#class_name" do
45
- it "returns the class attribute" do
46
- browser.span(:index, 0).class_name.should == 'lead'
47
- end
48
-
49
- it "returns an empty string if the element exists and the attribute doesn't" do
50
- browser.span(:index, 2).class_name.should == ''
51
- end
52
-
53
- it "raises UnknownObjectException if the span doesn't exist" do
54
- lambda { browser.span(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
55
- end
56
- end
57
-
58
- describe "#id" do
59
- it "returns the id attribute" do
60
- browser.span(:index, 0).id.should == "lead"
61
- end
62
-
63
- it "returns an empty string if the element exists and the attribute doesn't" do
64
- browser.span(:index, 2).id.should == ''
65
- end
66
-
67
- it "raises UnknownObjectException if the span doesn't exist" do
68
- lambda { browser.span(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
69
- lambda { browser.span(:index, 1337).id }.should raise_error(UnknownObjectException)
70
- end
71
- end
72
-
73
- describe "#title" do
74
- it "returns the title attribute" do
75
- browser.span(:index, 0).title.should == 'Lorem ipsum'
76
- end
77
-
78
- it "returns an empty string if the element exists and the attribute doesn't" do
79
- browser.span(:index, 2).title.should == ''
80
- end
81
-
82
- it "raises UnknownObjectException if the span doesn't exist" do
83
- lambda { browser.span(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
84
- lambda { browser.span(:xpath, "//span[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
85
- end
86
- end
87
-
88
- describe "#text" do
89
- it "returns the text of the span" do
90
- 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.'
91
- end
92
-
93
- it "returns an empty string if the element doesn't contain any text" do
94
- browser.span(:index, 4).text.should == ''
95
- end
96
-
97
- it "raises UnknownObjectException if the span doesn't exist" do
98
- lambda { browser.span(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
99
- lambda { browser.span(:xpath , "//span[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
100
- end
101
- end
102
-
103
- describe "#value" do
104
- it "returns the value attribute" do
105
- browser.span(:index, 1).value.should == "invalid_attribute"
106
- end
107
-
108
- it "returns an empty string if the element exists and the attribute doesn't" do
109
- browser.span(:index, 2).value.should == ''
110
- end
111
-
112
- it "raises UnknownObjectException if the span doesn't exist" do
113
- lambda { browser.span(:id , "no_such_id").value }.should raise_error(UnknownObjectException)
114
- lambda { browser.span(:index , 1337).value }.should raise_error(UnknownObjectException)
115
- end
116
- end
117
-
118
- describe "#respond_to?" do
119
- it "returns true for all attribute methods" do
120
- browser.span(:index, 0).should respond_to(:class_name)
121
- browser.span(:index, 0).should respond_to(:id)
122
- browser.span(:index, 0).should respond_to(:title)
123
- browser.span(:index, 0).should respond_to(:text)
124
- browser.span(:index, 0).should respond_to(:value)
125
- end
126
- end
127
-
128
- # Other
129
- describe "#click" do
130
- it "fires events" do
131
- browser.span(:class, 'footer').text.should_not include('Javascript')
132
- browser.span(:class, 'footer').click
133
- browser.span(:class, 'footer').text.should include('Javascript')
134
- end
135
-
136
- it "raises UnknownObjectException if the span doesn't exist" do
137
- lambda { browser.span(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
138
- lambda { browser.span(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
139
- end
140
- end
141
-
142
- end