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/button_spec.rb DELETED
@@ -1,227 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "Button" 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 button exists" do
16
- @browser.button(:id, "new_user_submit").should exist
17
- @browser.button(:id, /new_user_submit/).should exist
18
- @browser.button(:name, "new_user_reset").should exist
19
- @browser.button(:name, /new_user_reset/).should exist
20
- @browser.button(:value, "Button 2").should exist
21
- @browser.button(:value, /Button 2/).should exist
22
- @browser.button(:src, "images/button.jpg").should exist
23
- @browser.button(:src, /button.jpg/).should exist
24
- @browser.button(:text, "Button 2").should exist
25
- @browser.button(:text, /Button 2/).should exist
26
- @browser.button(:class, "image").should exist
27
- @browser.button(:class, /image/).should exist
28
- @browser.button(:index, 1).should exist
29
- @browser.button(:xpath, "//input[@id='new_user_submit']").should exist
30
- end
31
-
32
- it "should return true if the button exists (how = :caption)" do
33
- @browser.button(:caption, "Button 2").should exist
34
- @browser.button(:caption, /Button 2/).should exist
35
- end
36
-
37
- it "should return true if the button exists (default how = :value)" do
38
- @browser.button("Submit").should exist
39
- end
40
-
41
- it "should return false if the button doesn't exist" do
42
- @browser.button(:id, "no_such_id").should_not exist
43
- @browser.button(:id, /no_such_id/).should_not exist
44
- @browser.button(:name, "no_such_name").should_not exist
45
- @browser.button(:name, /no_such_name/).should_not exist
46
- @browser.button(:value, "no_such_value").should_not exist
47
- @browser.button(:value, /no_such_value/).should_not exist
48
- @browser.button(:src, "no_such_src").should_not exist
49
- @browser.button(:src, /no_such_src/).should_not exist
50
- @browser.button(:text, "no_such_text").should_not exist
51
- @browser.button(:text, /no_such_text/).should_not exist
52
- @browser.button(:class, "no_such_class").should_not exist
53
- @browser.button(:class, /no_such_class/).should_not exist
54
- @browser.button(:index, 1337).should_not exist
55
- @browser.button(:xpath, "//input[@id='no_such_id']").should_not exist
56
- end
57
-
58
- it "should raise ArgumentError when 'what' argument is invalid" do
59
- lambda { @browser.button(:id, 3.14).exists? }.should raise_error(ArgumentError)
60
- end
61
-
62
- it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
63
- lambda { @browser.button(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
64
- end
65
- end
66
-
67
- # Attribute methods
68
- describe "#class_name" do
69
- it "should return the class name of the button" do
70
- @browser.button(:name, "new_user_image").class_name.should == "image"
71
- end
72
-
73
- it "should return an empty string if the button has no class name" do
74
- @browser.button(:name, "new_user_submit").class_name.should == ""
75
- end
76
- end
77
-
78
- describe "#id" do
79
- it "should return the id if the button exists" do
80
- @browser.button(:index, 1).id.should == 'new_user_submit'
81
- @browser.button(:index, 2).id.should == 'new_user_reset'
82
- @browser.button(:index, 3).id.should == 'new_user_button'
83
- end
84
-
85
- it "should raise UnknownObjectException if button does not exist" do
86
- lambda { @browser.button(:index, 1337).id }.should raise_error(UnknownObjectException, 'Unable to locate object, using :index and 1337')
87
- end
88
- end
89
-
90
- describe "#name" do
91
- it "should return the name if button exists" do
92
- @browser.button(:index, 1).name.should == 'new_user_submit'
93
- @browser.button(:index, 2).name.should == 'new_user_reset'
94
- @browser.button(:index, 3).name.should == 'new_user_button'
95
- end
96
-
97
- it "should raise UnknownObjectException if the button does not exist" do
98
- lambda { @browser.button(:name, "no_such_name").name }.should raise_error(UnknownObjectException, 'Unable to locate object, using :name and "no_such_name"')
99
- end
100
- end
101
-
102
- describe "#src" do
103
- it "should return the url for the button image" do
104
- @browser.button(:name, "new_user_image").src.should == "images/button.jpg"
105
- end
106
-
107
- it "should raise UnknownObjectException if the button does not exist" do
108
- lambda { @browser.button(:name, "no_such_name").src }.should raise_error(UnknownObjectException, 'Unable to locate object, using :name and "no_such_name"')
109
- end
110
- end
111
-
112
- describe "#style" do
113
- it "should return the style attribute if the button exists" do
114
- @browser.button(:id, 'delete_user_submit').style.should == "border: 4px solid red;"
115
- end
116
-
117
- it "should return an empty string if the element exists and the attribute doesn't" do
118
- @browser.button(:id, 'new_user_submit').style.should == ""
119
- end
120
-
121
- it "should raise UnknownObjectException if the button does not exist" do
122
- lambda { @browser.button(:name, "no_such_name").style }.should raise_error(UnknownObjectException, 'Unable to locate object, using :name and "no_such_name"')
123
- end
124
- end
125
-
126
- describe "#title" do
127
- it "should return the title of the button" do
128
- @browser.button(:index, 1).title.should == 'Submit the form'
129
- end
130
-
131
- it "should return an empty string for button without title" do
132
- @browser.button(:index, 2).title.should == ''
133
- end
134
- end
135
-
136
- describe "#type" do
137
- it "should return the type if button exists" do
138
- @browser.button(:index, 1).type.should == 'submit'
139
- @browser.button(:index, 2).type.should == 'reset'
140
- @browser.button(:index, 3).type.should == 'button'
141
- end
142
-
143
- it "should raise UnknownObjectException if button does not exist" do
144
- lambda { @browser.button(:name, "no_such_name").type }.should raise_error(UnknownObjectException, 'Unable to locate object, using :name and "no_such_name"')
145
- end
146
- end
147
-
148
- describe "#value" do
149
- it "should return the value if button exists" do
150
- @browser.button(:index, 1).value.should == 'Submit'
151
- @browser.button(:index, 2).value.should == 'Reset'
152
- @browser.button(:index, 3).value.should == 'Button'
153
- end
154
-
155
- it "should raise UnknownObjectException if button does not exist" do
156
- lambda { @browser.button(:name, "no_such_name").value }.should raise_error(UnknownObjectException, 'Unable to locate object, using :name and "no_such_name"')
157
- end
158
- end
159
-
160
- describe "#respond_to?" do
161
- it "should return true for all attribute methods" do
162
- @browser.button(:index, 1).should respond_to(:class_name)
163
- @browser.button(:index, 1).should respond_to(:id)
164
- @browser.button(:index, 1).should respond_to(:name)
165
- @browser.button(:index, 1).should respond_to(:src)
166
- @browser.button(:index, 1).should respond_to(:style)
167
- @browser.button(:index, 1).should respond_to(:title)
168
- @browser.button(:index, 1).should respond_to(:type)
169
- @browser.button(:index, 1).should respond_to(:value)
170
- end
171
- end
172
-
173
- # Access methods
174
- describe "#enabled?" do
175
- it "should return true if the button is enabled" do
176
- @browser.button(:name, 'new_user_submit').should be_enabled
177
- end
178
-
179
- it "should return false if the button is disabled" do
180
- @browser.button(:name, 'new_user_submit_disabled').should_not be_enabled
181
- end
182
-
183
- it "should raise UnknownObjectException if the button doesn't exist" do
184
- lambda { @browser.button(:name, "no_such_name").enabled? }.should raise_error(UnknownObjectException, 'Unable to locate object, using :name and "no_such_name"')
185
- end
186
- end
187
-
188
- describe "#disabled?" do
189
- it "should return false when button is enabled" do
190
- @browser.button(:name, 'new_user_submit').should_not be_disabled
191
- end
192
-
193
- it "should return true when button is disabled" do
194
- @browser.button(:name, 'new_user_submit_disabled').should be_disabled
195
- end
196
-
197
- it "should raise UnknownObjectException if button does not exist" do
198
- lambda { @browser.button(:name, "no_such_name").disabled? }.should raise_error(UnknownObjectException, 'Unable to locate object, using :name and "no_such_name"')
199
- end
200
- end
201
-
202
- # Manipulation methods
203
- describe "#click" do
204
- it "should click the button if it exists" do
205
- @browser.button(:id, 'new_user_submit').click
206
- @browser.text.should include("You posted the following content:")
207
- end
208
-
209
- it "should fire events" do
210
- @browser.button(:id, 'new_user_button').click
211
- @browser.button(:id, 'new_user_button').value.should == 'new_value_set_by_onclick_event'
212
- end
213
-
214
- it "should raise UnknownObjectException when clicking a button that doesn't exist" do
215
- lambda { @browser.button(:value, "no_such_value").click }.should raise_error(UnknownObjectException, 'Unable to locate object, using :value and "no_such_value"')
216
- lambda { @browser.button(:id, "no_such_id").click }.should raise_error(UnknownObjectException, 'Unable to locate object, using :id and "no_such_id"')
217
- end
218
-
219
- it "should raise ObjectDisabledException when clicking a disabled button" do
220
- lambda { @browser.button(:value, "Disabled").click }.should raise_error(ObjectDisabledException)
221
- end
222
- end
223
-
224
- after :all do
225
- @browser.close
226
- end
227
- end
data/spec/buttons_spec.rb DELETED
@@ -1,39 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "Buttons" 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 buttons" do
15
- @browser.buttons.length.should == 7
16
- end
17
- end
18
-
19
- describe "#[]" do
20
- it "should return the button at the given index" do
21
- @browser.buttons[1].title.should == "Submit the form"
22
- end
23
- end
24
-
25
- describe "#each" do
26
- it "should iterate through buttons correctly" do
27
- @browser.buttons.each_with_index do |b, index|
28
- b.name.should == @browser.button(:index, index+1).name
29
- b.id.should == @browser.button(:index, index+1).id
30
- b.value.should == @browser.button(:index, index+1).value
31
- end
32
- end
33
- end
34
-
35
- after :all do
36
- @browser.close
37
- end
38
-
39
- end
@@ -1,302 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "CheckBox" 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
-
14
- # Exists method
15
-
16
- describe "#exists?" do
17
- it "should return true if the checkbox button exists" do
18
- @browser.checkbox(:id, "new_user_interests_books").should exist
19
- @browser.checkbox(:id, /new_user_interests_books/).should exist
20
- @browser.checkbox(:name, "new_user_interests").should exist
21
- @browser.checkbox(:name, /new_user_interests/).should exist
22
- @browser.checkbox(:value, "books").should exist
23
- @browser.checkbox(:value, /books/).should exist
24
- # not sure what :text is supposed to represent here
25
- # @browser.checkbox(:text, "books").should exist
26
- # @browser.checkbox(:text, /books/).should exist
27
- @browser.checkbox(:class, "fun").should exist
28
- @browser.checkbox(:class, /fun/).should exist
29
- @browser.checkbox(:index, 1).should exist
30
- @browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").should exist
31
- end
32
-
33
- it "should return true if the element exists (default how = :name)" do
34
- @browser.checkbox("new_user_interests").should exist
35
- end
36
-
37
- it "should return true if the checkbox button exists (search by name and value)" do
38
- @browser.checkbox(:name, "new_user_interests", 'cars').should exist
39
- @browser.checkbox(:xpath, "//input[@name='new_user_interests' and @value='cars']").set
40
- end
41
-
42
- it "should return false if the checkbox button does not exist" do
43
- @browser.checkbox(:id, "no_such_id").should_not exist
44
- @browser.checkbox(:id, /no_such_id/).should_not exist
45
- @browser.checkbox(:name, "no_such_name").should_not exist
46
- @browser.checkbox(:name, /no_such_name/).should_not exist
47
- @browser.checkbox(:value, "no_such_value").should_not exist
48
- @browser.checkbox(:value, /no_such_value/).should_not exist
49
- @browser.checkbox(:text, "no_such_text").should_not exist
50
- @browser.checkbox(:text, /no_such_text/).should_not exist
51
- @browser.checkbox(:class, "no_such_class").should_not exist
52
- @browser.checkbox(:class, /no_such_class/).should_not exist
53
- @browser.checkbox(:index, 1337).should_not exist
54
- @browser.checkbox(:xpath, "//input[@id='no_such_id']").should_not exist
55
- end
56
-
57
- it "should return false if the checkbox button does not exist (search by name and value)" do
58
- @browser.checkbox(:name, "new_user_interests", 'no_such_value').should_not exist
59
- @browser.checkbox(:xpath, "//input[@name='new_user_interests' and @value='no_such_value']").should_not exist
60
- @browser.checkbox(:name, "no_such_name", 'cars').should_not exist
61
- @browser.checkbox(:xpath, "//input[@name='no_such_name' and @value='cars']").should_not exist
62
- end
63
-
64
- it "should return true for checkboxs with a string value" do
65
- @browser.checkbox(:name, 'new_user_interests', 'books').should exist
66
- @browser.checkbox(:name, 'new_user_interests', 'cars').should exist
67
- end
68
-
69
- it "should raise ArgumentError when 'what' argument is invalid" do
70
- lambda { @browser.checkbox(:id, 3.14).exists? }.should raise_error(ArgumentError)
71
- end
72
-
73
- it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
74
- lambda { @browser.checkbox(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
75
- end
76
- end
77
-
78
-
79
- # Attribute methods
80
-
81
- describe "#class_name" do
82
- it "should return the class name if the checkbox exists and has an attribute" do
83
- @browser.checkbox(:id, "new_user_interests_dancing").class_name.should == "fun"
84
- end
85
-
86
- it "should return an emptry string if the checkbox exists and the attribute doesn't" do
87
- @browser.checkbox(:id, "new_user_interests_books").class_name.should == ""
88
- end
89
-
90
- it "should raise UnknownObjectException if the checkbox doesn't exist" do
91
- lambda { @browser.checkbox(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
92
- end
93
- end
94
-
95
- describe "#id" do
96
- it "should return the id attribute if the checkbox exists and has an attribute" do
97
- @browser.checkbox(:index, 1).id.should == "new_user_interests_books"
98
- end
99
-
100
- it "should return an emptry string if the checkbox exists and the attribute doesn't" do
101
- @browser.checkbox(:index, 2).id.should == ""
102
- end
103
-
104
- it "should raise UnknownObjectException if the checkbox doesn't exist" do
105
- lambda { @browser.checkbox(:index, 1337).id }.should raise_error(UnknownObjectException)
106
- end
107
- end
108
-
109
- describe "#name" do
110
- it "should return the name attribute if the checkbox exists" do
111
- @browser.checkbox(:id, 'new_user_interests_books').name.should == "new_user_interests"
112
- end
113
-
114
- it "should return an empty string if the checkbox exists and the attribute doesn't" do
115
- @browser.checkbox(:id, 'new_user_interests_food').name.should == ""
116
- end
117
-
118
- it "should raise UnknownObjectException if the checkbox doesn't exist" do
119
- lambda { @browser.checkbox(:index, 1337).name }.should raise_error(UnknownObjectException)
120
- end
121
- end
122
-
123
- describe "#title" do
124
- it "should return the title attribute if the checkbox exists" do
125
- @browser.checkbox(:id, "new_user_interests_dancing").title.should == "Dancing is fun!"
126
- end
127
-
128
- it "should return an emptry string if the checkbox exists and the attribute doesn't" do
129
- @browser.checkbox(:id, "new_user_interests_books").title.should == ""
130
- end
131
-
132
- it "should raise UnknownObjectException if the checkbox doesn't exist" do
133
- lambda { @browser.checkbox(:index, 1337).title }.should raise_error(UnknownObjectException)
134
- end
135
- end
136
-
137
- describe "#type" do
138
- it "should return the type attribute if the checkbox exists" do
139
- @browser.checkbox(:index, 1).type.should == "checkbox"
140
- end
141
-
142
- it "should raise UnknownObjectException if the checkbox doesn't exist" do
143
- lambda { @browser.checkbox(:index, 1337).type }.should raise_error(UnknownObjectException)
144
- end
145
- end
146
-
147
- describe "#value" do
148
- it "should return the value attribute if the checkbox exists" do
149
- @browser.checkbox(:id, 'new_user_interests_books').value.should == 'books'
150
- end
151
-
152
- it "should raise UnknownObjectException if the checkbox doesn't exist" do
153
- lambda { @browser.checkbox(:index, 1337).value}.should raise_error(UnknownObjectException)
154
- end
155
- end
156
-
157
- describe "#respond_to?" do
158
- it "should return true for all attribute methods" do
159
- @browser.checkbox(:index, 1).should respond_to(:class_name)
160
- @browser.checkbox(:index, 1).should respond_to(:id)
161
- @browser.checkbox(:index, 1).should respond_to(:name)
162
- @browser.checkbox(:index, 1).should respond_to(:title)
163
- @browser.checkbox(:index, 1).should respond_to(:type)
164
- @browser.checkbox(:index, 1).should respond_to(:value)
165
- end
166
- end
167
-
168
- # Access methods
169
-
170
- describe "#enabled?" do
171
- it "should return true if the checkbox button is enabled" do
172
- @browser.checkbox(:id, "new_user_interests_books").should be_enabled
173
- @browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").should be_enabled
174
- end
175
-
176
- it "should return false if the checkbox button is disabled" do
177
- @browser.checkbox(:id, "new_user_interests_dentistry").should_not be_enabled
178
- @browser.checkbox(:xpath,"//input[@id='new_user_interests_dentistry']").should_not be_enabled
179
- end
180
-
181
- it "should raise UnknownObjectException if the checkbox button doesn't exist" do
182
- lambda { @browser.checkbox(:id, "no_such_id").enabled? }.should raise_error(UnknownObjectException)
183
- lambda { @browser.checkbox(:xpath, "//input[@id='no_such_id']").enabled? }.should raise_error(UnknownObjectException)
184
- end
185
- end
186
-
187
- describe "#disabled?" do
188
- it "should return true if the checkbox is disabled" do
189
- @browser.checkbox(:id, 'new_user_interests_dentistry').should be_disabled
190
- end
191
-
192
- it "should return false if the checkbox is enabled" do
193
- @browser.checkbox(:id, 'new_user_interests_books').should_not be_disabled
194
- end
195
-
196
- it "should raise UnknownObjectException if the checkbox doesn't exist" do
197
- lambda { @browser.checkbox(:index, 1337).disabled? }.should raise_error(UnknownObjectException)
198
- end
199
- end
200
-
201
-
202
- # Manipulation methods
203
-
204
- describe "#clear" do
205
- it "should raise ObjectDisabledException if the checkbox is disabled" do
206
- @browser.checkbox(:id, "new_user_interests_dentistry").should_not be_set
207
- lambda { @browser.checkbox(:id, "new_user_interests_dentistry").clear }.should raise_error(ObjectDisabledException)
208
- lambda { @browser.checkbox(:xpath, "//input[@id='new_user_interests_dentistry']").clear }.should raise_error(ObjectDisabledException)
209
- end
210
-
211
- it "should clear the checkbox button if it is set" do
212
- @browser.checkbox(:id, "new_user_interests_books").clear
213
- @browser.checkbox(:id, "new_user_interests_books").should_not be_set
214
- end
215
-
216
- it "should clear the checkbox button when found by :xpath" do
217
- @browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").clear
218
- @browser.checkbox(:xpath, "//input[@id='new_user_interests_books']").should_not be_set
219
- end
220
-
221
- it "should raise UnknownObjectException if the checkbox button doesn't exist" do
222
- lambda { @browser.checkbox(:name, "no_such_id").clear }.should raise_error(UnknownObjectException)
223
- lambda { @browser.checkbox(:xpath, "//input[@id='no_such_id']").clear }.should raise_error(UnknownObjectException)
224
- end
225
- end
226
-
227
- describe "#set" do
228
- it "should set the checkbox button" do
229
- @browser.checkbox(:id, "new_user_interests_cars").set
230
- @browser.checkbox(:id, "new_user_interests_cars").should be_set
231
- end
232
-
233
- it "should set the checkbox button when found by :xpath" do
234
- @browser.checkbox(:xpath, "//input[@id='new_user_interests_cars']").set
235
- @browser.checkbox(:xpath, "//input[@id='new_user_interests_cars']").should be_set
236
- end
237
-
238
- it "should fire the onclick event" do
239
- @browser.button(:id, "disabled_button").should be_disabled
240
- @browser.checkbox(:id, "toggle_button_checkbox").set
241
- @browser.button(:id, "disabled_button").should_not be_disabled
242
- @browser.checkbox(:id, "toggle_button_checkbox").clear
243
- @browser.button(:id, "disabled_button").should be_disabled
244
- end
245
-
246
- it "should raise UnknownObjectException if the checkbox button doesn't exist" do
247
- lambda { @browser.checkbox(:name, "no_such_name").set }.should raise_error(UnknownObjectException)
248
- lambda { @browser.checkbox(:xpath, "//input[@name='no_such_name']").set }.should raise_error(UnknownObjectException)
249
- end
250
-
251
- it "should raise ObjectDisabledException if the checkbox is disabled" do
252
- lambda { @browser.checkbox(:id, "new_user_interests_dentistry").set }.should raise_error(ObjectDisabledException)
253
- lambda { @browser.checkbox(:xpath, "//input[@id='new_user_interests_dentistry']").set }.should raise_error(ObjectDisabledException )
254
- end
255
- end
256
-
257
-
258
- # Other
259
-
260
- describe '#set?' do
261
- it "should return true if the checkbox button is set" do
262
- @browser.checkbox(:id, "new_user_interests_books").should be_set
263
- end
264
-
265
- it "should return false if the checkbox button unset" do
266
- @browser.checkbox(:id, "new_user_interests_cars").should_not be_set
267
- end
268
-
269
- it "should return the state for checkboxs with string values" do
270
- @browser.checkbox(:name, "new_user_interests", 'cars').should_not be_set
271
- @browser.checkbox(:name, "new_user_interests", 'cars').set
272
- @browser.checkbox(:name, "new_user_interests", 'cars').should be_set
273
- @browser.checkbox(:name, "new_user_interests", 'cars').clear
274
- @browser.checkbox(:name, "new_user_interests", 'cars').should_not be_set
275
- end
276
-
277
- it "should raise UnknownObjectException if the checkbox button doesn't exist" do
278
- lambda { @browser.checkbox(:id, "no_such_id").set? }.should raise_error(UnknownObjectException)
279
- lambda { @browser.checkbox(:xpath, "//input[@id='no_such_id']").set? }.should raise_error(UnknownObjectException)
280
- end
281
- end
282
-
283
- describe "#get_state" do
284
- it "should return true if the checkbox is set" do
285
- @browser.checkbox(:id, "new_user_interests_books").get_state.should be_true
286
- end
287
-
288
- it "should return false if the checkbox is unset" do
289
- @browser.checkbox(:id, "new_user_interests_cars").get_state.should be_false
290
- end
291
-
292
- it "should raise UnknownObjectException if the checkbox doesn't exist" do
293
- lambda { @browser.checkbox(:name, "no_such_name").get_state }.should raise_error(UnknownObjectException)
294
- lambda { @browser.checkbox(:xpath, "//input[@name='no_such_name']").get_state }.should raise_error(UnknownObjectException)
295
- end
296
- end
297
-
298
- after :all do
299
- @browser.close
300
- end
301
- end
302
-