celerity 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. data/History.txt +33 -0
  2. data/README.txt +19 -9
  3. data/Rakefile +9 -3
  4. data/lib/celerity.rb +39 -39
  5. data/lib/celerity/browser.rb +538 -153
  6. data/lib/celerity/clickable_element.rb +48 -7
  7. data/lib/celerity/collections.rb +155 -131
  8. data/lib/celerity/container.rb +766 -385
  9. data/lib/celerity/default_viewer.rb +10 -0
  10. data/lib/celerity/disabled_element.rb +19 -2
  11. data/lib/celerity/element.rb +152 -83
  12. data/lib/celerity/element_collection.rb +106 -0
  13. data/lib/celerity/element_locator.rb +89 -66
  14. data/lib/celerity/elements/button.rb +23 -13
  15. data/lib/celerity/elements/file_field.rb +17 -5
  16. data/lib/celerity/elements/form.rb +21 -16
  17. data/lib/celerity/elements/frame.rb +75 -53
  18. data/lib/celerity/elements/image.rb +76 -63
  19. data/lib/celerity/elements/label.rb +4 -2
  20. data/lib/celerity/elements/link.rb +30 -18
  21. data/lib/celerity/elements/meta.rb +6 -0
  22. data/lib/celerity/{non_control_elements.rb → elements/non_control_elements.rb} +106 -76
  23. data/lib/celerity/elements/option.rb +16 -2
  24. data/lib/celerity/elements/radio_check.rb +55 -20
  25. data/lib/celerity/elements/select_list.rb +65 -29
  26. data/lib/celerity/elements/table.rb +141 -94
  27. data/lib/celerity/elements/table_cell.rb +13 -6
  28. data/lib/celerity/elements/{table_body.rb → table_elements.rb} +20 -8
  29. data/lib/celerity/elements/table_row.rb +23 -7
  30. data/lib/celerity/elements/text_field.rb +89 -33
  31. data/lib/celerity/exception.rb +77 -41
  32. data/lib/celerity/extra/method_generator.rb +42 -24
  33. data/lib/celerity/htmlunit.rb +49 -0
  34. data/lib/celerity/htmlunit/commons-collections-3.2.1.jar +0 -0
  35. data/lib/celerity/htmlunit/htmlunit-2.5-SNAPSHOT.jar +0 -0
  36. data/lib/celerity/htmlunit/htmlunit-core-js-2.5-SNAPSHOT.jar +0 -0
  37. data/lib/celerity/htmlunit/nekohtml-1.9.12-20090308.130127-11.jar +0 -0
  38. data/lib/celerity/htmlunit/serializer-2.7.1.jar +0 -0
  39. data/lib/celerity/htmlunit/xalan-2.7.1.jar +0 -0
  40. data/lib/celerity/htmlunit/xml-apis-1.3.04.jar +0 -0
  41. data/lib/celerity/identifier.rb +3 -2
  42. data/lib/celerity/input_element.rb +5 -5
  43. data/lib/celerity/listener.rb +135 -0
  44. data/lib/celerity/resources/no_viewer.png +0 -0
  45. data/lib/celerity/util.rb +88 -0
  46. data/lib/celerity/version.rb +4 -3
  47. data/lib/celerity/watir_compatibility.rb +35 -25
  48. data/tasks/jar.rake +57 -0
  49. metadata +35 -142
  50. data.tar.gz.sig +0 -0
  51. data/Manifest.txt +0 -150
  52. data/lib/celerity/element_collections.rb +0 -54
  53. data/lib/celerity/element_map.rb +0 -51
  54. data/lib/celerity/elements/table_footer.rb +0 -30
  55. data/lib/celerity/elements/table_header.rb +0 -30
  56. data/lib/celerity/htmlunit/commons-collections-3.2.jar +0 -0
  57. data/lib/celerity/htmlunit/download.sh +0 -23
  58. data/lib/celerity/htmlunit/htmlunit-2.2.jar +0 -0
  59. data/lib/celerity/htmlunit/htmlunit-core-js-2.2.jar +0 -0
  60. data/lib/celerity/htmlunit/nekohtml-1.9.8.jar +0 -0
  61. data/lib/celerity/htmlunit/xalan-2.7.0.jar +0 -0
  62. data/lib/celerity/htmlunit/xml-apis-1.0.b2.jar +0 -0
  63. data/spec/area_spec.rb +0 -97
  64. data/spec/areas_spec.rb +0 -40
  65. data/spec/browser_spec.rb +0 -266
  66. data/spec/button_spec.rb +0 -227
  67. data/spec/buttons_spec.rb +0 -39
  68. data/spec/checkbox_spec.rb +0 -302
  69. data/spec/checkboxes_spec.rb +0 -38
  70. data/spec/div_spec.rb +0 -207
  71. data/spec/divs_spec.rb +0 -39
  72. data/spec/element_spec.rb +0 -79
  73. data/spec/filefield_spec.rb +0 -123
  74. data/spec/filefields_spec.rb +0 -40
  75. data/spec/form_spec.rb +0 -59
  76. data/spec/forms_spec.rb +0 -41
  77. data/spec/frame_spec.rb +0 -121
  78. data/spec/frames_spec.rb +0 -71
  79. data/spec/hidden_spec.rb +0 -127
  80. data/spec/hiddens_spec.rb +0 -39
  81. data/spec/hn_spec.rb +0 -104
  82. data/spec/hns_spec.rb +0 -45
  83. data/spec/html/2000_spans.html +0 -2009
  84. data/spec/html/bug_duplicate_attributes.html +0 -14
  85. data/spec/html/bug_javascript_001.html +0 -11
  86. data/spec/html/form_js_bug.html +0 -11
  87. data/spec/html/forms_with_input_elements.html +0 -114
  88. data/spec/html/frame_1.html +0 -17
  89. data/spec/html/frame_2.html +0 -16
  90. data/spec/html/frames.html +0 -11
  91. data/spec/html/iframes.html +0 -12
  92. data/spec/html/images.html +0 -27
  93. data/spec/html/images/1.gif +0 -0
  94. data/spec/html/images/2.gif +0 -0
  95. data/spec/html/images/3.gif +0 -0
  96. data/spec/html/images/button.jpg +0 -0
  97. data/spec/html/images/circle.jpg +0 -0
  98. data/spec/html/images/map.gif +0 -0
  99. data/spec/html/images/map2.gif +0 -0
  100. data/spec/html/images/minus.gif +0 -0
  101. data/spec/html/images/originaltriangle.jpg +0 -0
  102. data/spec/html/images/plus.gif +0 -0
  103. data/spec/html/images/square.jpg +0 -0
  104. data/spec/html/images/triangle.jpg +0 -0
  105. data/spec/html/invalid_js.html +0 -11
  106. data/spec/html/latin1_text.html +0 -17
  107. data/spec/html/non_control_elements.html +0 -115
  108. data/spec/html/simple_ajax.html +0 -22
  109. data/spec/html/tables.html +0 -119
  110. data/spec/html/utf8_text.html +0 -15
  111. data/spec/htmlunit_spec.rb +0 -26
  112. data/spec/image_spec.rb +0 -220
  113. data/spec/images_spec.rb +0 -39
  114. data/spec/label_spec.rb +0 -79
  115. data/spec/labels_spec.rb +0 -40
  116. data/spec/li_spec.rb +0 -139
  117. data/spec/link_spec.rb +0 -189
  118. data/spec/links_spec.rb +0 -43
  119. data/spec/lis_spec.rb +0 -40
  120. data/spec/map_spec.rb +0 -102
  121. data/spec/maps_spec.rb +0 -40
  122. data/spec/meta_spec.rb +0 -8
  123. data/spec/ol_spec.rb +0 -87
  124. data/spec/ols_spec.rb +0 -40
  125. data/spec/option_spec.rb +0 -154
  126. data/spec/p_spec.rb +0 -171
  127. data/spec/pre_spec.rb +0 -135
  128. data/spec/pres_spec.rb +0 -40
  129. data/spec/ps_spec.rb +0 -40
  130. data/spec/radio_spec.rb +0 -299
  131. data/spec/radios_spec.rb +0 -42
  132. data/spec/select_list_spec.rb +0 -299
  133. data/spec/select_lists_spec.rb +0 -47
  134. data/spec/span_spec.rb +0 -184
  135. data/spec/spans_spec.rb +0 -64
  136. data/spec/spec.opts +0 -1
  137. data/spec/spec_helper.rb +0 -55
  138. data/spec/table_bodies_spec.rb +0 -57
  139. data/spec/table_body_spec.rb +0 -111
  140. data/spec/table_cell_spec.rb +0 -74
  141. data/spec/table_cells_spec.rb +0 -59
  142. data/spec/table_footer_spec.rb +0 -101
  143. data/spec/table_footers_spec.rb +0 -55
  144. data/spec/table_header_spec.rb +0 -101
  145. data/spec/table_headers_spec.rb +0 -55
  146. data/spec/table_row_spec.rb +0 -104
  147. data/spec/table_rows_spec.rb +0 -58
  148. data/spec/table_spec.rb +0 -160
  149. data/spec/tables_spec.rb +0 -42
  150. data/spec/text_field_spec.rb +0 -323
  151. data/spec/text_fields_spec.rb +0 -44
  152. data/spec/ul_spec.rb +0 -88
  153. data/spec/uls_spec.rb +0 -40
  154. data/spec/watir_compatibility_spec.rb +0 -260
  155. data/support/spec_server.rb +0 -73
  156. data/tasks/rspec.rake +0 -30
  157. data/tasks/specserver.rake +0 -21
  158. metadata.gz.sig +0 -0
data/spec/tables_spec.rb DELETED
@@ -1,42 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "Tables" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- before :each do
10
- @browser.goto(TEST_HOST + "/tables.html")
11
- end
12
-
13
- describe "#length" do
14
- it "should return the number of tables" do
15
- @browser.tables.length.should == 4
16
- end
17
- end
18
-
19
- describe "#[]" do
20
- it "should return the p at the given index" do
21
- @browser.tables[1].id.should == "axis_example"
22
- @browser.tables[2].id.should == "outer"
23
- @browser.tables[3].id.should == "inner"
24
- end
25
- end
26
-
27
- describe "#each" do
28
- it "should iterate through tables correctly" do
29
- @browser.tables.each_with_index do |t, index|
30
- t.name.should == @browser.table(:index, index+1).name
31
- t.id.should == @browser.table(:index, index+1).id
32
- t.value.should == @browser.table(:index, index+1).value
33
- end
34
- end
35
- end
36
-
37
- after :all do
38
- @browser.close
39
- end
40
-
41
- end
42
-
@@ -1,323 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "TextField" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- before :each do
10
- @browser.goto(TEST_HOST + "/forms_with_input_elements.html")
11
- end
12
-
13
- # Exists method
14
- describe "#exists?" do
15
- it "should return true if the element exists" do
16
- @browser.text_field(:id, 'new_user_email').should exist
17
- @browser.text_field(:id, /new_user_email/).should exist
18
- @browser.text_field(:name, 'new_user_email').should exist
19
- @browser.text_field(:name, /new_user_email/).should exist
20
- @browser.text_field(:value, 'Developer').should exist
21
- @browser.text_field(:value, /Developer/).should exist
22
- @browser.text_field(:text, 'Developer').should exist
23
- @browser.text_field(:text, /Developer/).should exist
24
- @browser.text_field(:class, 'name').should exist
25
- @browser.text_field(:class, /name/).should exist
26
- @browser.text_field(:index, 1).should exist
27
- @browser.text_field(:xpath, "//input[@id='new_user_email']").should exist
28
- end
29
-
30
- it "should return true if the element exists (default how = :name)" do
31
- @browser.text_field("new_user_email").should exist
32
- end
33
-
34
- it "should return true if the element exists (no type attribute)" do
35
- @browser.text_field(:id, 'new_user_first_name').should exist
36
- end
37
-
38
- it "should return true if the element exists (invalid type attribute)" do
39
- @browser.text_field(:id, 'new_user_last_name').should exist
40
- end
41
-
42
- it "should return false if the element does not exist" do
43
- @browser.text_field(:id, 'no_such_id').should_not exist
44
- @browser.text_field(:id, /no_such_id/).should_not exist
45
- @browser.text_field(:name, 'no_such_name').should_not exist
46
- @browser.text_field(:name, /no_such_name/).should_not exist
47
- @browser.text_field(:value, 'no_such_value').should_not exist
48
- @browser.text_field(:value, /no_such_value/).should_not exist
49
- @browser.text_field(:text, 'no_such_text').should_not exist
50
- @browser.text_field(:text, /no_such_text/).should_not exist
51
- @browser.text_field(:class, 'no_such_class').should_not exist
52
- @browser.text_field(:class, /no_such_class/).should_not exist
53
- @browser.text_field(:index, 1337).should_not exist
54
- @browser.text_field(:xpath, "//input[@id='no_such_id']").should_not exist
55
- end
56
-
57
- it "should raise ArgumentError when 'what' argument is invalid" do
58
- lambda { @browser.text_field(:id, 3.14).exists? }.should raise_error(ArgumentError)
59
- end
60
-
61
- it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
62
- lambda { @browser.text_field(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
63
- end
64
- end
65
-
66
- # Attribute methods
67
- describe "#id" do
68
- it "should return the id attribute if the text field exists" do
69
- @browser.text_field(:index, 4).id.should == "new_user_occupation"
70
- end
71
-
72
- it "should raise UnknownObjectException if the text field doesn't exist" do
73
- lambda { @browser.text_field(:index, 1337).id }.should raise_error(UnknownObjectException)
74
- end
75
- end
76
-
77
- describe "#name" do
78
- it "should return the name attribute if the text field exists" do
79
- @browser.text_field(:index, 4).name.should == "new_user_occupation"
80
- end
81
-
82
- it "should raise UnknownObjectException if the text field doesn't exist" do
83
- lambda { @browser.text_field(:index, 1337).name }.should raise_error(UnknownObjectException)
84
- end
85
- end
86
-
87
- describe "#title" do
88
- it "should return the title attribute if the text field exists" do
89
- @browser.text_field(:id, "new_user_code").title.should == "Your personal code"
90
- end
91
-
92
- it "should raise UnknownObjectException if the text field doesn't exist" do
93
- lambda { @browser.text_field(:index, 1337).title }.should raise_error(UnknownObjectException)
94
- end
95
- end
96
-
97
- describe "#type" do
98
- it "should return the type attribute if the text field exists" do
99
- @browser.text_field(:index, 4).type.should == "text"
100
- end
101
-
102
- it "should return 'text' if the type attribute is invalid" do
103
- @browser.text_field(:id, 'new_user_last_name').type.should == "text"
104
- end
105
-
106
- it "should return 'text' if the type attribute does not exist" do
107
- @browser.text_field(:id, 'new_user_first_name').type.should == "text"
108
- end
109
-
110
- it "should raise UnknownObjectException if the text field doesn't exist" do
111
- lambda { @browser.text_field(:index, 1337).type }.should raise_error(UnknownObjectException)
112
- end
113
- end
114
-
115
- describe "#value" do
116
- it "should return the value attribute if the text field exists" do
117
- @browser.text_field(:name, "new_user_occupation").value.should == "Developer"
118
- @browser.text_field(:index, 4).value.should == "Developer"
119
- @browser.text_field(:name, /new_user_occupation/i).value.should == "Developer"
120
- end
121
-
122
- it "should raise UnknownObjectException if the text field doesn't exist" do
123
- lambda { @browser.text_field(:index, 1337).value }.should raise_error(UnknownObjectException)
124
- end
125
- end
126
-
127
- describe "#respond_to?" do
128
- it "should return true for all attribute methods" do
129
- @browser.text_field(:index, 1).should respond_to(:class_name)
130
- @browser.text_field(:index, 1).should respond_to(:id)
131
- @browser.text_field(:index, 1).should respond_to(:name)
132
- @browser.text_field(:index, 1).should respond_to(:title)
133
- @browser.text_field(:index, 1).should respond_to(:type)
134
- @browser.text_field(:index, 1).should respond_to(:value)
135
- end
136
- end
137
-
138
-
139
- # Access methods
140
- describe "#enabled?" do
141
- it "should return true for enabled text fields" do
142
- @browser.text_field(:name, "new_user_occupation").should be_enabled
143
- @browser.text_field(:id, "new_user_email").should be_enabled
144
- end
145
-
146
- it "should return false for disabled text fields" do
147
- @browser.text_field(:name, "new_user_species").should_not be_enabled
148
- end
149
-
150
- it "should raise UnknownObjectException if the text field doesn't exist" do
151
- lambda { @browser.text_field(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
152
- end
153
- end
154
-
155
- describe "#disabled?" do
156
- it "should return true if the text field is disabled" do
157
- @browser.text_field(:id, 'new_user_species').should be_disabled
158
- end
159
-
160
- it "should return false if the text field is enabled" do
161
- @browser.text_field(:index, 1).should_not be_disabled
162
- end
163
-
164
- it "should raise UnknownObjectException if the text field doesn't exist" do
165
- lambda { @browser.text_field(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
166
- end
167
- end
168
-
169
- describe "#readonly?" do
170
- it "should return true for read-only text fields" do
171
- @browser.text_field(:name, "new_user_code").should be_readonly
172
- @browser.text_field(:id, "new_user_code").should be_readonly
173
- end
174
-
175
- it "should return false for writeable text fields" do
176
- @browser.text_field(:name, "new_user_email").should_not be_readonly
177
- end
178
-
179
- it "should raise UnknownObjectException if the text field doesn't exist" do
180
- lambda { @browser.text_field(:id, 'no_such_id').readonly? }.should raise_error(UnknownObjectException)
181
- end
182
- end
183
-
184
-
185
- # Manipulation methods
186
- describe "#append" do
187
- it "should append the text to the text field" do
188
- @browser.text_field(:name, "new_user_occupation").append(" Append This")
189
- @browser.text_field(:name, "new_user_occupation").get_contents.should == "Developer Append This"
190
- end
191
-
192
- it "should append multi-byte characters" do
193
- @browser.text_field(:name, "new_user_occupation").append(" ijij")
194
- @browser.text_field(:name, "new_user_occupation").get_contents.should == "Developer ijij"
195
- end
196
-
197
- it "should raise ObjectReadOnlyException if the object is read only" do
198
- lambda { @browser.text_field(:id, "new_user_code").append("Append This") }.should raise_error(ObjectReadOnlyException)
199
- end
200
-
201
- it "should raise ObjectDisabledException if the object is disabled" do
202
- lambda { @browser.text_field(:name, "new_user_species").append("Append This") }.should raise_error(ObjectDisabledException)
203
- end
204
-
205
- it "should raise UnknownObjectException if the object doesn't exist" do
206
- lambda { @browser.text_field(:name, "no_such_name").append("Append This") }.should raise_error(UnknownObjectException)
207
- end
208
- end
209
-
210
- describe "#clear" do
211
- it "should remove all text from the text field" do
212
- @browser.text_field(:name, "new_user_occupation").clear
213
- @browser.text_field(:name, "new_user_occupation").get_contents.should be_empty
214
- @browser.text_field(:id, "delete_user_comment").clear
215
- @browser.text_field(:id, "delete_user_comment").get_contents.should be_empty
216
- end
217
-
218
- it "should raise UnknownObjectException if the text field doesn't exist" do
219
- lambda { @browser.text_field(:id, "no_such_id").clear }.should raise_error(UnknownObjectException)
220
- end
221
- end
222
-
223
- describe "#drag_contents_to" do
224
- it "should drag contents to another text field" do
225
- @browser.text_field(:name, "new_user_first_name").set("Smith")
226
- @browser.text_field(:name, "new_user_first_name").drag_contents_to(:name, "new_user_last_name")
227
- @browser.text_field(:name, "new_user_first_name").value.should be_empty
228
- @browser.text_field(:id, "new_user_last_name").value.should == "Smith"
229
- end
230
-
231
- it "should raise UnknownObjectException if either of the text fields doesn't exist" do
232
- lambda { @browser.text_field(:id, "no_such_id").drag_contents_to(:name, "new_user_last_name") }.should raise_error(UnknownObjectException)
233
- lambda { @browser.text_field(:name, "new_user_first_name").drag_contents_to(:id, "no_such_id") }.should raise_error(UnknownObjectException)
234
- end
235
- end
236
-
237
- describe "#get_contents" do
238
- it "should return the contents of the text field" do
239
- @browser.text_field(:name, "new_user_occupation").get_contents.should == "Developer"
240
- end
241
-
242
- it "should raise UnknownObjectException when accessing a non-existing element" do
243
- lambda { @browser.text_field(:name, "no_such_name").get_contents }.should raise_error(UnknownObjectException)
244
- end
245
-
246
- it "should raise UnknownObjectException if the text field doesn't exist" do
247
- lambda { @browser.text_field(:id, "no_such_id").get_contents }.should raise_error(UnknownObjectException)
248
- end
249
- end
250
-
251
- describe "#value=" do
252
- it "should set the value of the element" do
253
- @browser.text_field(:id, 'new_user_email').value = 'Hello Cruel World'
254
- @browser.text_field(:id, "new_user_email").value.should == 'Hello Cruel World'
255
- end
256
-
257
- it "should be able to set multi-byte characters" do
258
- @browser.text_field(:name, "new_user_occupation").value = "ijij"
259
- @browser.text_field(:name, "new_user_occupation").get_contents.should == "ijij"
260
- end
261
-
262
- it "should set the value of a textarea element" do
263
- @browser.text_field(:id, 'delete_user_comment').value = 'Hello Cruel World'
264
- @browser.text_field(:id, "delete_user_comment").value.should == 'Hello Cruel World'
265
- end
266
-
267
- it "should raise UnknownObjectException if the text field doesn't exist" do
268
- lambda { @browser.text_field(:name, "no_such_name").value = 'yo' }.should raise_error(UnknownObjectException)
269
- end
270
- end
271
-
272
- describe "#set" do
273
- it "should set the value of the element" do
274
- @browser.text_field(:id, 'new_user_email').set('Bye Cruel World')
275
- @browser.text_field(:id, "new_user_email").value.should == 'Bye Cruel World'
276
- end
277
-
278
- it "should set the value of a textarea element" do
279
- @browser.text_field(:id, 'delete_user_comment').set('Hello Cruel World')
280
- @browser.text_field(:id, "delete_user_comment").value.should == 'Hello Cruel World'
281
- end
282
-
283
- it "should fire events" do
284
- @browser.text_field(:id, "new_user_username").set("Hello World")
285
- @browser.span(:id, "current_length").text.should == "11"
286
- end
287
-
288
- it "should be able to set the value of a password field" do
289
- @browser.text_field(:name , 'new_user_password').set('secret')
290
- @browser.text_field(:name , 'new_user_password').value.should == 'secret'
291
- end
292
-
293
- it "should be able to set multi-byte characters" do
294
- @browser.text_field(:name, "new_user_occupation").set("ijij")
295
- @browser.text_field(:name, "new_user_occupation").get_contents.should == "ijij"
296
- end
297
-
298
- it "should raise UnknownObjectException if the text field doesn't exist" do
299
- lambda { @browser.text_field(:id, "no_such_id").set('secret') }.should raise_error(UnknownObjectException)
300
- end
301
- end
302
-
303
- describe "#verify_contains" do
304
- it "should verify that a text field contains its value" do
305
- @browser.text_field(:name, "new_user_occupation").verify_contains("Developer").should be_true
306
- @browser.text_field(:name, "new_user_occupation").verify_contains(/Developer/).should be_true
307
- end
308
-
309
- it "should not verify that a text field contains a non-existing value" do
310
- @browser.text_field(:name, "new_user_email").verify_contains("no_such_text").should be_false
311
- @browser.text_field(:name, "new_user_email").verify_contains(/no_such_text/).should be_false
312
- end
313
-
314
- it "should raise UnknownObjectException if the text field doesn't exist" do
315
- lambda { @browser.text_field(:id, "no_such_id").verify_contains("Developer") }.should raise_error(UnknownObjectException)
316
- end
317
- end
318
-
319
- after :all do
320
- @browser.close
321
- end
322
-
323
- end
@@ -1,44 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "TextFields" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- before :each do
10
- @browser.goto(TEST_HOST + "/forms_with_input_elements.html")
11
- end
12
-
13
- describe "#length" do
14
- it "should return the number of text fields" do
15
- @browser.text_fields.length.should == 9
16
- end
17
- end
18
-
19
- describe "#[]" do
20
- it "should return the text field at the given index" do
21
- @browser.text_fields[1].id.should == "new_user_first_name"
22
- @browser.text_fields[2].id.should == "new_user_last_name"
23
- @browser.text_fields[3].id.should == "new_user_email"
24
- end
25
- end
26
-
27
- describe "#each" do
28
- it "should iterate through text fields correctly" do
29
- index = 1
30
- @browser.text_fields.each do |r|
31
- r.name.should == @browser.text_field(:index, index).name
32
- r.id.should == @browser.text_field(:index, index).id
33
- r.value.should == @browser.text_field(:index, index).value
34
- index += 1
35
- end
36
- @browser.text_fields.length.should == index - 1
37
- end
38
- end
39
-
40
- after :all do
41
- @browser.close
42
- end
43
- end
44
-
data/spec/ul_spec.rb DELETED
@@ -1,88 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "Ul" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- before :each do
10
- @browser.goto(TEST_HOST + "/non_control_elements.html")
11
- end
12
-
13
- # Exists method
14
- describe "#exist?" do
15
- it "should return true if the 'ul' exists" do
16
- @browser.ul(:id, "navbar").should exist
17
- @browser.ul(:id, /navbar/).should exist
18
- @browser.ul(:index, 1).should exist
19
- @browser.ul(:xpath, "//ul[@id='navbar']").should exist
20
- end
21
-
22
- it "should return true if the element exists (default how = :id)" do
23
- @browser.ul("navbar").should exist
24
- end
25
-
26
- it "should return false if the 'ul' doesn't exist" do
27
- @browser.ul(:id, "no_such_id").should_not exist
28
- @browser.ul(:id, /no_such_id/).should_not exist
29
- @browser.ul(:text, "no_such_text").should_not exist
30
- @browser.ul(:text, /no_such_text/).should_not exist
31
- @browser.ul(:class, "no_such_class").should_not exist
32
- @browser.ul(:class, /no_such_class/).should_not exist
33
- @browser.ul(:index, 1337).should_not exist
34
- @browser.ul(:xpath, "//ul[@id='no_such_id']").should_not exist
35
- end
36
-
37
- it "should raise ArgumentError when 'what' argument is invalid" do
38
- lambda { @browser.ul(:id, 3.14).exists? }.should raise_error(ArgumentError)
39
- end
40
-
41
- it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
42
- lambda { @browser.ul(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
43
- end
44
- end
45
-
46
- # Attribute methods
47
- describe "#class_name" do
48
- it "should return the class attribute" do
49
- @browser.ul(:id, 'navbar').class_name.should == 'navigation'
50
- end
51
-
52
- it "should return an empty string if the element exists and the attribute doesn't" do
53
- @browser.ul(:index, 2).class_name.should == ''
54
- end
55
-
56
- it "should raise UnknownObjectException if the ul doesn't exist" do
57
- lambda { @browser.ul(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
58
- end
59
- end
60
-
61
- describe "#id" do
62
- it "should return the id attribute" do
63
- @browser.ul(:class, 'navigation').id.should == "navbar"
64
- end
65
-
66
- it "should return an empty string if the element exists and the attribute doesn't" do
67
- @browser.ul(:index, 2).id.should == ''
68
- end
69
-
70
- it "should raise UnknownObjectException if the ul doesn't exist" do
71
- lambda { @browser.ul(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
72
- lambda { @browser.ul(:index, 1337).id }.should raise_error(UnknownObjectException)
73
- end
74
- end
75
-
76
- describe "#respond_to?" do
77
- it "should return true for all attribute methods" do
78
- @browser.ul(:index, 1).should respond_to(:class_name)
79
- @browser.ul(:index, 1).should respond_to(:id)
80
- end
81
- end
82
-
83
-
84
- after :all do
85
- @browser.close
86
- end
87
-
88
- end