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.
Files changed (93) hide show
  1. data/.gitignore +9 -0
  2. data/Gemfile +3 -3
  3. data/Rakefile +3 -28
  4. data/lib/watir-webdriver.rb +1 -0
  5. data/lib/watir-webdriver/version.rb +3 -0
  6. data/watir-webdriver.gemspec +23 -247
  7. metadata +34 -326
  8. data/VERSION +0 -1
  9. data/spec/watirspec/area_spec.rb +0 -77
  10. data/spec/watirspec/areas_spec.rb +0 -45
  11. data/spec/watirspec/browser_spec.rb +0 -274
  12. data/spec/watirspec/button_spec.rb +0 -255
  13. data/spec/watirspec/buttons_spec.rb +0 -58
  14. data/spec/watirspec/checkbox_spec.rb +0 -276
  15. data/spec/watirspec/checkboxes_spec.rb +0 -47
  16. data/spec/watirspec/collections_spec.rb +0 -20
  17. data/spec/watirspec/dd_spec.rb +0 -127
  18. data/spec/watirspec/dds_spec.rb +0 -45
  19. data/spec/watirspec/del_spec.rb +0 -145
  20. data/spec/watirspec/dels_spec.rb +0 -45
  21. data/spec/watirspec/div_spec.rb +0 -221
  22. data/spec/watirspec/divs_spec.rb +0 -45
  23. data/spec/watirspec/dl_spec.rb +0 -137
  24. data/spec/watirspec/dls_spec.rb +0 -46
  25. data/spec/watirspec/dt_spec.rb +0 -127
  26. data/spec/watirspec/dts_spec.rb +0 -45
  27. data/spec/watirspec/element_spec.rb +0 -149
  28. data/spec/watirspec/em_spec.rb +0 -101
  29. data/spec/watirspec/ems_spec.rb +0 -46
  30. data/spec/watirspec/filefield_spec.rb +0 -156
  31. data/spec/watirspec/filefields_spec.rb +0 -46
  32. data/spec/watirspec/font_spec.rb +0 -32
  33. data/spec/watirspec/form_spec.rb +0 -63
  34. data/spec/watirspec/forms_spec.rb +0 -47
  35. data/spec/watirspec/frame_spec.rb +0 -144
  36. data/spec/watirspec/frames_spec.rb +0 -83
  37. data/spec/watirspec/hidden_spec.rb +0 -103
  38. data/spec/watirspec/hiddens_spec.rb +0 -46
  39. data/spec/watirspec/hn_spec.rb +0 -97
  40. data/spec/watirspec/hns_spec.rb +0 -42
  41. data/spec/watirspec/image_spec.rb +0 -208
  42. data/spec/watirspec/images_spec.rb +0 -45
  43. data/spec/watirspec/ins_spec.rb +0 -146
  44. data/spec/watirspec/inses_spec.rb +0 -45
  45. data/spec/watirspec/label_spec.rb +0 -81
  46. data/spec/watirspec/labels_spec.rb +0 -45
  47. data/spec/watirspec/li_spec.rb +0 -116
  48. data/spec/watirspec/lib/guards.rb +0 -59
  49. data/spec/watirspec/lib/implementation.rb +0 -48
  50. data/spec/watirspec/lib/runner.rb +0 -83
  51. data/spec/watirspec/lib/server.rb +0 -194
  52. data/spec/watirspec/lib/watirspec.rb +0 -75
  53. data/spec/watirspec/link_spec.rb +0 -174
  54. data/spec/watirspec/links_spec.rb +0 -49
  55. data/spec/watirspec/lis_spec.rb +0 -45
  56. data/spec/watirspec/map_spec.rb +0 -80
  57. data/spec/watirspec/maps_spec.rb +0 -46
  58. data/spec/watirspec/meta_spec.rb +0 -24
  59. data/spec/watirspec/metas_spec.rb +0 -43
  60. data/spec/watirspec/ol_spec.rb +0 -90
  61. data/spec/watirspec/ols_spec.rb +0 -45
  62. data/spec/watirspec/option_spec.rb +0 -152
  63. data/spec/watirspec/p_spec.rb +0 -132
  64. data/spec/watirspec/pre_spec.rb +0 -116
  65. data/spec/watirspec/pres_spec.rb +0 -45
  66. data/spec/watirspec/ps_spec.rb +0 -45
  67. data/spec/watirspec/radio_spec.rb +0 -262
  68. data/spec/watirspec/radios_spec.rb +0 -46
  69. data/spec/watirspec/select_list_spec.rb +0 -335
  70. data/spec/watirspec/select_lists_spec.rb +0 -49
  71. data/spec/watirspec/span_spec.rb +0 -146
  72. data/spec/watirspec/spans_spec.rb +0 -45
  73. data/spec/watirspec/spec_helper.rb +0 -20
  74. data/spec/watirspec/strong_spec.rb +0 -93
  75. data/spec/watirspec/strongs_spec.rb +0 -46
  76. data/spec/watirspec/table_nesting_spec.rb +0 -50
  77. data/spec/watirspec/table_spec.rb +0 -150
  78. data/spec/watirspec/tables_spec.rb +0 -47
  79. data/spec/watirspec/tbody_spec.rb +0 -97
  80. data/spec/watirspec/tbodys_spec.rb +0 -65
  81. data/spec/watirspec/td_spec.rb +0 -72
  82. data/spec/watirspec/tds_spec.rb +0 -60
  83. data/spec/watirspec/text_field_spec.rb +0 -283
  84. data/spec/watirspec/text_fields_spec.rb +0 -49
  85. data/spec/watirspec/tfoot_spec.rb +0 -92
  86. data/spec/watirspec/tfoots_spec.rb +0 -71
  87. data/spec/watirspec/thead_spec.rb +0 -92
  88. data/spec/watirspec/theads_spec.rb +0 -71
  89. data/spec/watirspec/tr_spec.rb +0 -88
  90. data/spec/watirspec/trs_spec.rb +0 -68
  91. data/spec/watirspec/ul_spec.rb +0 -80
  92. data/spec/watirspec/uls_spec.rb +0 -44
  93. data/spec/watirspec/window_switching_spec.rb +0 -164
@@ -1,58 +0,0 @@
1
- # encoding: utf-8
2
- require File.expand_path("../spec_helper", __FILE__)
3
-
4
- describe "Buttons" 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.buttons(:name => "new_user_button").to_a.should == [browser.button(:name => "new_user_button")]
14
- end
15
- end
16
- end
17
-
18
- describe "#length" do
19
- it "returns the number of buttons" do
20
- browser.buttons.length.should == 8
21
- end
22
- end
23
-
24
- describe "#[]" do
25
- it "returns the button at the given index" do
26
- browser.buttons[0].title.should == "Submit the form"
27
- end
28
- end
29
-
30
- describe "#first" do
31
- it "returns the first element in the collection" do
32
- browser.buttons.first.value.should == browser.buttons[0].value
33
- end
34
- end
35
-
36
- describe "#last" do
37
- it "returns the last element in the collection" do
38
- browser.buttons.last.value.should == browser.buttons[-1].value
39
- end
40
- end
41
-
42
- describe "#each" do
43
- it "iterates through buttons correctly" do
44
- count = 0
45
-
46
- browser.buttons.each_with_index do |b, index|
47
- b.name.should == browser.button(:index, index).name
48
- b.id.should == browser.button(:index, index).id
49
- b.value.should == browser.button(:index, index).value
50
-
51
- count += 1
52
- end
53
-
54
- count.should > 0
55
- end
56
- end
57
-
58
- end
@@ -1,276 +0,0 @@
1
- # encoding: utf-8
2
- require File.expand_path("../spec_helper", __FILE__)
3
-
4
- describe "CheckBox" do
5
-
6
- before :each do
7
- browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
8
- end
9
-
10
- # Exists method
11
-
12
- describe "#exists?" do
13
- it "returns true if the checkbox button exists" do
14
- browser.checkbox(:id, "new_user_interests_books").should exist
15
- browser.checkbox(:id, /new_user_interests_books/).should exist
16
- browser.checkbox(:name, "new_user_interests").should exist
17
- browser.checkbox(:name, /new_user_interests/).should exist
18
- browser.checkbox(:value, "books").should exist
19
- browser.checkbox(:value, /books/).should exist
20
- # not sure what :text is supposed to represent here
21
- # browser.checkbox(:text, "books").should exist
22
- # browser.checkbox(:text, /books/).should exist
23
- browser.checkbox(:class, "fun").should exist
24
- browser.checkbox(:class, /fun/).should exist
25
- browser.checkbox(:index, 0).should exist
26
- browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").should exist
27
- end
28
-
29
- it "returns true if the checkbox button exists (search by name and value)" do
30
- browser.checkbox(:name => "new_user_interests", :value => 'cars').should exist
31
- browser.checkbox(:xpath, "//input[@name='new_user_interests' and @value='cars']").set
32
- end
33
-
34
- it "returns the first checkbox if given no args" do
35
- browser.checkbox.should exist
36
- end
37
-
38
- it "returns false if the checkbox button does not exist" do
39
- browser.checkbox(:id, "no_such_id").should_not exist
40
- browser.checkbox(:id, /no_such_id/).should_not exist
41
- browser.checkbox(:name, "no_such_name").should_not exist
42
- browser.checkbox(:name, /no_such_name/).should_not exist
43
- browser.checkbox(:value, "no_such_value").should_not exist
44
- browser.checkbox(:value, /no_such_value/).should_not exist
45
- browser.checkbox(:text, "no_such_text").should_not exist
46
- browser.checkbox(:text, /no_such_text/).should_not exist
47
- browser.checkbox(:class, "no_such_class").should_not exist
48
- browser.checkbox(:class, /no_such_class/).should_not exist
49
- browser.checkbox(:index, 1337).should_not exist
50
- browser.checkbox(:xpath, "//input[@id='no_such_id']").should_not exist
51
- end
52
-
53
- it "returns false if the checkbox button does not exist (search by name and value)" do
54
- browser.checkbox(:name => "new_user_interests", :value => 'no_such_value').should_not exist
55
- browser.checkbox(:xpath, "//input[@name='new_user_interests' and @value='no_such_value']").should_not exist
56
- browser.checkbox(:name => "no_such_name", :value => 'cars').should_not exist
57
- browser.checkbox(:xpath, "//input[@name='no_such_name' and @value='cars']").should_not exist
58
- end
59
-
60
- it "returns true for checkboxs with a string value" do
61
- browser.checkbox(:name => 'new_user_interests', :value => 'books').should exist
62
- browser.checkbox(:name => 'new_user_interests', :value => 'cars').should exist
63
- end
64
-
65
- it "raises TypeError when 'what' argument is invalid" do
66
- lambda { browser.checkbox(:id, 3.14).exists? }.should raise_error(TypeError)
67
- end
68
-
69
- it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
70
- lambda { browser.checkbox(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
71
- end
72
- end
73
-
74
- # Attribute methods
75
-
76
- describe "#class_name" do
77
- it "returns the class name if the checkbox exists and has an attribute" do
78
- browser.checkbox(:id, "new_user_interests_dancing").class_name.should == "fun"
79
- end
80
-
81
- it "returns an emptry string if the checkbox exists and the attribute doesn't" do
82
- browser.checkbox(:id, "new_user_interests_books").class_name.should == ""
83
- end
84
-
85
- it "raises UnknownObjectException if the checkbox doesn't exist" do
86
- lambda { browser.checkbox(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
87
- end
88
- end
89
-
90
- describe "#id" do
91
- it "returns the id attribute if the checkbox exists and has an attribute" do
92
- browser.checkbox(:index, 0).id.should == "new_user_interests_books"
93
- end
94
-
95
- it "returns an emptry string if the checkbox exists and the attribute doesn't" do
96
- browser.checkbox(:index, 1).id.should == ""
97
- end
98
-
99
- it "raises UnknownObjectException if the checkbox doesn't exist" do
100
- lambda { browser.checkbox(:index, 1337).id }.should raise_error(UnknownObjectException)
101
- end
102
- end
103
-
104
- describe "#name" do
105
- it "returns the name attribute if the checkbox exists" do
106
- browser.checkbox(:id, 'new_user_interests_books').name.should == "new_user_interests"
107
- end
108
-
109
- it "returns an empty string if the checkbox exists and the attribute doesn't" do
110
- browser.checkbox(:id, 'new_user_interests_food').name.should == ""
111
- end
112
-
113
- it "raises UnknownObjectException if the checkbox doesn't exist" do
114
- lambda { browser.checkbox(:index, 1337).name }.should raise_error(UnknownObjectException)
115
- end
116
- end
117
-
118
- describe "#title" do
119
- it "returns the title attribute if the checkbox exists" do
120
- browser.checkbox(:id, "new_user_interests_dancing").title.should == "Dancing is fun!"
121
- end
122
-
123
- it "returns an emptry string if the checkbox exists and the attribute doesn't" do
124
- browser.checkbox(:id, "new_user_interests_books").title.should == ""
125
- end
126
-
127
- it "raises UnknownObjectException if the checkbox doesn't exist" do
128
- lambda { browser.checkbox(:index, 1337).title }.should raise_error(UnknownObjectException)
129
- end
130
- end
131
-
132
- describe "#type" do
133
- it "returns the type attribute if the checkbox exists" do
134
- browser.checkbox(:index, 0).type.should == "checkbox"
135
- end
136
-
137
- it "raises UnknownObjectException if the checkbox doesn't exist" do
138
- lambda { browser.checkbox(:index, 1337).type }.should raise_error(UnknownObjectException)
139
- end
140
- end
141
-
142
- describe "#value" do
143
- it "returns the value attribute if the checkbox exists" do
144
- browser.checkbox(:id, 'new_user_interests_books').value.should == 'books'
145
- end
146
-
147
- it "raises UnknownObjectException if the checkbox doesn't exist" do
148
- lambda { browser.checkbox(:index, 1337).value}.should raise_error(UnknownObjectException)
149
- end
150
- end
151
-
152
- describe "#respond_to?" do
153
- it "returns true for all attribute methods" do
154
- browser.checkbox(:index, 0).should respond_to(:class_name)
155
- browser.checkbox(:index, 0).should respond_to(:id)
156
- browser.checkbox(:index, 0).should respond_to(:name)
157
- browser.checkbox(:index, 0).should respond_to(:title)
158
- browser.checkbox(:index, 0).should respond_to(:type)
159
- browser.checkbox(:index, 0).should respond_to(:value)
160
- end
161
- end
162
-
163
- # Access methods
164
-
165
- describe "#enabled?" do
166
- it "returns true if the checkbox button is enabled" do
167
- browser.checkbox(:id, "new_user_interests_books").should be_enabled
168
- browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").should be_enabled
169
- end
170
-
171
- it "returns false if the checkbox button is disabled" do
172
- browser.checkbox(:id, "new_user_interests_dentistry").should_not be_enabled
173
- browser.checkbox(:xpath,"//input[@id='new_user_interests_dentistry']").should_not be_enabled
174
- end
175
-
176
- it "raises UnknownObjectException if the checkbox button doesn't exist" do
177
- lambda { browser.checkbox(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
178
- lambda { browser.checkbox(:xpath, "//input[@id='no_such_id']").enabled? }.should raise_error(UnknownObjectException)
179
- end
180
- end
181
-
182
- describe "#disabled?" do
183
- it "returns true if the checkbox is disabled" do
184
- browser.checkbox(:id, 'new_user_interests_dentistry').should be_disabled
185
- end
186
-
187
- it "returns false if the checkbox is enabled" do
188
- browser.checkbox(:id, 'new_user_interests_books').should_not be_disabled
189
- end
190
-
191
- it "raises UnknownObjectException if the checkbox doesn't exist" do
192
- lambda { browser.checkbox(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
193
- end
194
- end
195
-
196
- # Manipulation methods
197
-
198
- describe "#clear" do
199
- it "raises ObjectDisabledException if the checkbox is disabled" do
200
- browser.checkbox(:id, "new_user_interests_dentistry").should_not be_set
201
- lambda { browser.checkbox(:id, "new_user_interests_dentistry").clear }.should raise_error(ObjectDisabledException)
202
- lambda { browser.checkbox(:xpath, "//input[@id='new_user_interests_dentistry']").clear }.should raise_error(ObjectDisabledException)
203
- end
204
-
205
- it "clears the checkbox button if it is set" do
206
- browser.checkbox(:id, "new_user_interests_books").clear
207
- browser.checkbox(:id, "new_user_interests_books").should_not be_set
208
- end
209
-
210
- it "clears the checkbox button when found by :xpath" do
211
- browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").clear
212
- browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").should_not be_set
213
- end
214
-
215
- it "raises UnknownObjectException if the checkbox button doesn't exist" do
216
- lambda { browser.checkbox(:name, "no_such_id").clear }.should raise_error(UnknownObjectException)
217
- lambda { browser.checkbox(:xpath, "//input[@id='no_such_id']").clear }.should raise_error(UnknownObjectException)
218
- end
219
- end
220
-
221
- describe "#set" do
222
- it "sets the checkbox button" do
223
- browser.checkbox(:id, "new_user_interests_cars").set
224
- browser.checkbox(:id, "new_user_interests_cars").should be_set
225
- end
226
-
227
- it "sets the checkbox button when found by :xpath" do
228
- browser.checkbox(:xpath, "//input[@id='new_user_interests_cars']").set
229
- browser.checkbox(:xpath, "//input[@id='new_user_interests_cars']").should be_set
230
- end
231
-
232
- it "fires the onclick event" do
233
- browser.button(:id, "disabled_button").should be_disabled
234
- browser.checkbox(:id, "toggle_button_checkbox").set
235
- browser.button(:id, "disabled_button").should_not be_disabled
236
- browser.checkbox(:id, "toggle_button_checkbox").clear
237
- browser.button(:id, "disabled_button").should be_disabled
238
- end
239
-
240
- it "raises UnknownObjectException if the checkbox button doesn't exist" do
241
- lambda { browser.checkbox(:name, "no_such_name").set }.should raise_error(UnknownObjectException)
242
- lambda { browser.checkbox(:xpath, "//input[@name='no_such_name']").set }.should raise_error(UnknownObjectException)
243
- end
244
-
245
- it "raises ObjectDisabledException if the checkbox is disabled" do
246
- lambda { browser.checkbox(:id, "new_user_interests_dentistry").set }.should raise_error(ObjectDisabledException)
247
- lambda { browser.checkbox(:xpath, "//input[@id='new_user_interests_dentistry']").set }.should raise_error(ObjectDisabledException )
248
- end
249
- end
250
-
251
- # Other
252
-
253
- describe '#set?' do
254
- it "returns true if the checkbox button is set" do
255
- browser.checkbox(:id, "new_user_interests_books").should be_set
256
- end
257
-
258
- it "returns false if the checkbox button unset" do
259
- browser.checkbox(:id, "new_user_interests_cars").should_not be_set
260
- end
261
-
262
- it "returns the state for checkboxs with string values" do
263
- browser.checkbox(:name => "new_user_interests", :value => 'cars').should_not be_set
264
- browser.checkbox(:name => "new_user_interests", :value => 'cars').set
265
- browser.checkbox(:name => "new_user_interests", :value => 'cars').should be_set
266
- browser.checkbox(:name => "new_user_interests", :value => 'cars').clear
267
- browser.checkbox(:name => "new_user_interests", :value => 'cars').should_not be_set
268
- end
269
-
270
- it "raises UnknownObjectException if the checkbox button doesn't exist" do
271
- lambda { browser.checkbox(:id, "no_such_id").set? }.should raise_error(UnknownObjectException)
272
- lambda { browser.checkbox(:xpath, "//input[@id='no_such_id']").set? }.should raise_error(UnknownObjectException)
273
- end
274
- end
275
-
276
- end
@@ -1,47 +0,0 @@
1
- # encoding: utf-8
2
- require File.expand_path("../spec_helper", __FILE__)
3
-
4
- describe "CheckBoxes" 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.checkboxes(:value => "books").to_a.should == [browser.checkbox(:value => "books")]
14
- end
15
- end
16
- end
17
-
18
- describe "#length" do
19
- it "returns the number of checkboxes" do
20
- browser.checkboxes.length.should == 7
21
- end
22
- end
23
-
24
- describe "#[]" do
25
- it "returns the checkbox at the given index" do
26
- browser.checkboxes[0].id.should == "new_user_interests_books"
27
- end
28
- end
29
-
30
- describe "#each" do
31
- it "iterates through checkboxes correctly" do
32
- count = 0
33
-
34
- browser.checkboxes.each_with_index do |c, index|
35
- c.should be_instance_of(CheckBox)
36
- c.name.should == browser.checkbox(:index, index).name
37
- c.id.should == browser.checkbox(:index, index).id
38
- c.value.should == browser.checkbox(:index, index).value
39
-
40
- count += 1
41
- end
42
-
43
- count.should > 0
44
- end
45
- end
46
-
47
- end
@@ -1,20 +0,0 @@
1
- # encoding: utf-8
2
- require File.expand_path("../spec_helper", __FILE__)
3
-
4
- describe "Collections" do
5
-
6
- before :each do
7
- browser.goto(WatirSpec.files + "/collections.html")
8
- end
9
-
10
- it "returns inner elements of parent element having different html tag" do
11
- browser.span(:id => "a_span").divs.size.should == 2
12
- end
13
-
14
- bug "http://code.google.com/p/selenium/issues/detail?id=695", [:webdriver, :ie] do
15
- it "returns inner elements of parent element having same html tag" do
16
- browser.span(:id => "a_span").spans.size.should == 2
17
- end
18
- end
19
-
20
- end
@@ -1,127 +0,0 @@
1
- # encoding: utf-8
2
- require File.expand_path("../spec_helper", __FILE__)
3
-
4
- describe "Dd" do
5
-
6
- before :each do
7
- browser.goto(WatirSpec.files + "/definition_lists.html")
8
- end
9
-
10
- # Exists method
11
- describe "#exists?" do
12
- it "returns true if the element exists" do
13
- browser.dd(:id, "someone").should exist
14
- browser.dd(:class, "name").should exist
15
- browser.dd(:xpath, "//dd[@id='someone']").should exist
16
- browser.dd(:index, 0).should exist
17
- end
18
-
19
- it "returns the first dd if given no args" do
20
- browser.dd.should exist
21
- end
22
-
23
- it "returns false if the element does not exist" do
24
- browser.dd(:id, "no_such_id").should_not exist
25
- end
26
-
27
- it "raises TypeError when 'what' argument is invalid" do
28
- lambda { browser.dd(:id, 3.14).exists? }.should raise_error(TypeError)
29
- end
30
-
31
- it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
32
- lambda { browser.dd(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
33
- end
34
- end
35
-
36
- # Attribute methods
37
- describe "#class_name" do
38
- it "returns the class attribute if the element exists" do
39
- browser.dd(:id, "someone").class_name.should == "name"
40
- end
41
-
42
- it "returns an empty string if the element exists but the attribute doesn't" do
43
- browser.dd(:id, "city").class_name.should == ""
44
- end
45
-
46
- it "raises UnknownObjectException if the element does not exist" do
47
- lambda { browser.dd(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
48
- lambda { browser.dd(:title, "no_such_title").class_name }.should raise_error(UnknownObjectException)
49
- lambda { browser.dd(:index, 1337).class_name }.should raise_error(UnknownObjectException)
50
- lambda { browser.dd(:xpath, "//dd[@id='no_such_id']").class_name }.should raise_error(UnknownObjectException)
51
- end
52
- end
53
-
54
- describe "#id" do
55
- it "returns the id attribute if the element exists" do
56
- browser.dd(:class, 'name').id.should == "someone"
57
- end
58
-
59
- it "returns an empty string if the element exists, but the attribute doesn't" do
60
- browser.dd(:class, 'address').id.should == ""
61
- end
62
-
63
- it "raises UnknownObjectException if the element does not exist" do
64
- lambda {browser.dd(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
65
- lambda {browser.dd(:title, "no_such_id").id }.should raise_error(UnknownObjectException)
66
- lambda {browser.dd(:index, 1337).id }.should raise_error(UnknownObjectException)
67
- end
68
- end
69
-
70
- describe "#title" do
71
- it "returns the title of the element" do
72
- browser.dd(:class, "name").title.should == "someone"
73
- end
74
- end
75
-
76
- describe "#text" do
77
- it "returns the text of the element" do
78
- browser.dd(:id, "someone").text.should == "John Doe"
79
- end
80
-
81
- it "returns an empty string if the element exists but contains no text" do
82
- browser.dd(:class, 'noop').text.should == ""
83
- end
84
-
85
- it "raises UnknownObjectException if the element does not exist" do
86
- lambda { browser.dd(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
87
- lambda { browser.dd(:title, "no_such_title").text }.should raise_error(UnknownObjectException)
88
- lambda { browser.dd(:index, 1337).text }.should raise_error(UnknownObjectException)
89
- lambda { browser.dd(:xpath, "//dd[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
90
- end
91
- end
92
-
93
- describe "#respond_to?" do
94
- it "returns true for all attribute methods" do
95
- browser.dd(:index, 0).should respond_to(:id)
96
- browser.dd(:index, 0).should respond_to(:class_name)
97
- browser.dd(:index, 0).should respond_to(:style)
98
- browser.dd(:index, 0).should respond_to(:text)
99
- browser.dd(:index, 0).should respond_to(:title)
100
- end
101
- end
102
-
103
- # Manipulation methods
104
- describe "#click" do
105
- it "fires events when clicked" do
106
- browser.dd(:title, 'education').text.should_not == 'changed'
107
- browser.dd(:title, 'education').click
108
- browser.dd(:title, 'education').text.should == 'changed'
109
- end
110
-
111
- it "raises UnknownObjectException if the element does not exist" do
112
- lambda { browser.dd(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
113
- lambda { browser.dd(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
114
- lambda { browser.dd(:index, 1337).click }.should raise_error(UnknownObjectException)
115
- lambda { browser.dd(:xpath, "//dd[@id='no_such_id']").click }.should raise_error(UnknownObjectException)
116
- end
117
- end
118
-
119
- describe "#html" do
120
- it "returns the HTML of the element" do
121
- html = browser.dd(:id, 'someone').html
122
- html.should =~ /John Doe/m
123
- html.should_not include('</body>')
124
- end
125
- end
126
-
127
- end