caius-celerity 0.0.6.10 → 0.0.6.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (279) hide show
  1. data/Manifest.txt +335 -0
  2. data/benchmark/bm_2000_spans.rb +48 -0
  3. data/benchmark/bm_digg.rb +26 -0
  4. data/benchmark/bm_google_images.rb +36 -0
  5. data/benchmark/bm_input_locator.rb +69 -0
  6. data/benchmark/bm_text_input.rb +19 -0
  7. data/benchmark/loader.rb +14 -0
  8. data/celerity.gemspec +33 -0
  9. data/config/hoe.rb +78 -0
  10. data/config/requirements.rb +9 -0
  11. data/lib/celerity/version.rb +1 -1
  12. data/spec/area_spec.rb +97 -0
  13. data/spec/areas_spec.rb +40 -0
  14. data/spec/browser_authentication_spec.rb +20 -0
  15. data/spec/browser_spec.rb +537 -0
  16. data/spec/button_spec.rb +244 -0
  17. data/spec/buttons_spec.rb +51 -0
  18. data/spec/checkbox_spec.rb +302 -0
  19. data/spec/checkboxes_spec.rb +38 -0
  20. data/spec/clickable_element_spec.rb +43 -0
  21. data/spec/dd_spec.rb +143 -0
  22. data/spec/dds_spec.rb +39 -0
  23. data/spec/default_viewer_spec.rb +24 -0
  24. data/spec/div_spec.rb +235 -0
  25. data/spec/divs_spec.rb +39 -0
  26. data/spec/dl_spec.rb +143 -0
  27. data/spec/dls_spec.rb +39 -0
  28. data/spec/dt_spec.rb +143 -0
  29. data/spec/dts_spec.rb +39 -0
  30. data/spec/element_spec.rb +150 -0
  31. data/spec/em_spec.rb +116 -0
  32. data/spec/ems_spec.rb +39 -0
  33. data/spec/filefield_spec.rb +133 -0
  34. data/spec/filefields_spec.rb +40 -0
  35. data/spec/form_spec.rb +59 -0
  36. data/spec/forms_spec.rb +41 -0
  37. data/spec/frame_spec.rb +139 -0
  38. data/spec/frames_spec.rb +71 -0
  39. data/spec/hidden_spec.rb +127 -0
  40. data/spec/hiddens_spec.rb +39 -0
  41. data/spec/hn_spec.rb +104 -0
  42. data/spec/hns_spec.rb +45 -0
  43. data/spec/html/2000_spans.html +2009 -0
  44. data/spec/html/bug_duplicate_attributes.html +14 -0
  45. data/spec/html/bug_javascript_001.html +11 -0
  46. data/spec/html/definition_lists.html +48 -0
  47. data/spec/html/euc-jp_text.html +17 -0
  48. data/spec/html/forms_with_input_elements.html +124 -0
  49. data/spec/html/frame_1.html +18 -0
  50. data/spec/html/frame_2.html +16 -0
  51. data/spec/html/frames.html +11 -0
  52. data/spec/html/iframes.html +12 -0
  53. data/spec/html/images.html +27 -0
  54. data/spec/html/images/1.gif +0 -0
  55. data/spec/html/images/2.gif +0 -0
  56. data/spec/html/images/3.gif +0 -0
  57. data/spec/html/images/button.jpg +0 -0
  58. data/spec/html/images/circle.jpg +0 -0
  59. data/spec/html/images/map.gif +0 -0
  60. data/spec/html/images/map2.gif +0 -0
  61. data/spec/html/images/minus.gif +0 -0
  62. data/spec/html/images/originaltriangle.jpg +0 -0
  63. data/spec/html/images/plus.gif +0 -0
  64. data/spec/html/images/square.jpg +0 -0
  65. data/spec/html/images/triangle.jpg +0 -0
  66. data/spec/html/iso-2022-jp_text.html +17 -0
  67. data/spec/html/jquery.html +29 -0
  68. data/spec/html/latin1_text.html +17 -0
  69. data/spec/html/multiple_ids.html +14 -0
  70. data/spec/html/non_control_elements.html +115 -0
  71. data/spec/html/right_click.html +16 -0
  72. data/spec/html/shift_jis_text.html +17 -0
  73. data/spec/html/tables.html +119 -0
  74. data/spec/html/timeout.html +16 -0
  75. data/spec/html/tiny_mce.html +29 -0
  76. data/spec/html/utf8_text.html +15 -0
  77. data/spec/htmlunit_spec.rb +47 -0
  78. data/spec/image_spec.rb +221 -0
  79. data/spec/images_spec.rb +39 -0
  80. data/spec/index_offset_spec.rb +26 -0
  81. data/spec/label_spec.rb +88 -0
  82. data/spec/labels_spec.rb +40 -0
  83. data/spec/li_spec.rb +139 -0
  84. data/spec/link_spec.rb +200 -0
  85. data/spec/links_spec.rb +47 -0
  86. data/spec/lis_spec.rb +40 -0
  87. data/spec/listener_spec.rb +142 -0
  88. data/spec/map_spec.rb +102 -0
  89. data/spec/maps_spec.rb +40 -0
  90. data/spec/meta_spec.rb +29 -0
  91. data/spec/metas_spec.rb +38 -0
  92. data/spec/ol_spec.rb +87 -0
  93. data/spec/ols_spec.rb +40 -0
  94. data/spec/option_spec.rb +156 -0
  95. data/spec/p_spec.rb +171 -0
  96. data/spec/pre_spec.rb +135 -0
  97. data/spec/pres_spec.rb +40 -0
  98. data/spec/ps_spec.rb +40 -0
  99. data/spec/radio_spec.rb +314 -0
  100. data/spec/radios_spec.rb +42 -0
  101. data/spec/select_list_spec.rb +320 -0
  102. data/spec/select_lists_spec.rb +47 -0
  103. data/spec/span_spec.rb +184 -0
  104. data/spec/spans_spec.rb +64 -0
  105. data/spec/spec.opts +1 -0
  106. data/spec/spec_helper.rb +66 -0
  107. data/spec/strong_spec.rb +101 -0
  108. data/spec/strongs_spec.rb +40 -0
  109. data/spec/table_bodies_spec.rb +57 -0
  110. data/spec/table_body_spec.rb +109 -0
  111. data/spec/table_cell_spec.rb +84 -0
  112. data/spec/table_cells_spec.rb +59 -0
  113. data/spec/table_footer_spec.rb +96 -0
  114. data/spec/table_footers_spec.rb +55 -0
  115. data/spec/table_header_spec.rb +101 -0
  116. data/spec/table_headers_spec.rb +55 -0
  117. data/spec/table_row_spec.rb +106 -0
  118. data/spec/table_rows_spec.rb +58 -0
  119. data/spec/table_spec.rb +169 -0
  120. data/spec/tables_spec.rb +42 -0
  121. data/spec/text_field_spec.rb +331 -0
  122. data/spec/text_fields_spec.rb +44 -0
  123. data/spec/ul_spec.rb +88 -0
  124. data/spec/uls_spec.rb +40 -0
  125. data/spec/watir_compatibility_spec.rb +268 -0
  126. data/support/spec_server.rb +122 -0
  127. data/tasks/benchmark.rake +4 -0
  128. data/tasks/deployment.rake +43 -0
  129. data/tasks/environment.rake +7 -0
  130. data/tasks/fix.rake +25 -0
  131. data/tasks/rspec.rake +31 -0
  132. data/tasks/simple_ci.rake +94 -0
  133. data/tasks/snapshot.rake +22 -0
  134. data/tasks/specserver.rake +21 -0
  135. data/tasks/website.rake +17 -0
  136. data/tasks/yard.rake +9 -0
  137. data/website/benchmarks.html +237 -0
  138. data/website/css/color.css +153 -0
  139. data/website/css/hacks.css +3 -0
  140. data/website/css/layout.css +179 -0
  141. data/website/css/screen.css +5 -0
  142. data/website/css/textmate.css +226 -0
  143. data/website/css/typography.css +72 -0
  144. data/website/gfx/body_bg.gif +0 -0
  145. data/website/gfx/button_bg.jpg +0 -0
  146. data/website/gfx/header_bg.jpg +0 -0
  147. data/website/gfx/header_left.jpg +0 -0
  148. data/website/gfx/header_right.jpg +0 -0
  149. data/website/gfx/nav_bg.jpg +0 -0
  150. data/website/index.html +133 -0
  151. data/website/yard/Celerity.html +50 -0
  152. data/website/yard/Celerity/Area.html +212 -0
  153. data/website/yard/Celerity/Areas.html +103 -0
  154. data/website/yard/Celerity/Browser.html +5594 -0
  155. data/website/yard/Celerity/Button.html +312 -0
  156. data/website/yard/Celerity/Buttons.html +103 -0
  157. data/website/yard/Celerity/CheckBox.html +347 -0
  158. data/website/yard/Celerity/CheckBoxes.html +103 -0
  159. data/website/yard/Celerity/ClickableElement.html +448 -0
  160. data/website/yard/Celerity/Container.html +7676 -0
  161. data/website/yard/Celerity/Dd.html +198 -0
  162. data/website/yard/Celerity/Dds.html +103 -0
  163. data/website/yard/Celerity/DefaultViewer.html +101 -0
  164. data/website/yard/Celerity/DisabledElement.html +252 -0
  165. data/website/yard/Celerity/Div.html +198 -0
  166. data/website/yard/Celerity/Divs.html +103 -0
  167. data/website/yard/Celerity/Dl.html +198 -0
  168. data/website/yard/Celerity/Dls.html +103 -0
  169. data/website/yard/Celerity/Dt.html +198 -0
  170. data/website/yard/Celerity/Dts.html +103 -0
  171. data/website/yard/Celerity/Element.html +1703 -0
  172. data/website/yard/Celerity/ElementCollection.html +725 -0
  173. data/website/yard/Celerity/ElementLocator.html +589 -0
  174. data/website/yard/Celerity/Em.html +198 -0
  175. data/website/yard/Celerity/Ems.html +103 -0
  176. data/website/yard/Celerity/Exception.html +23 -0
  177. data/website/yard/Celerity/Exception/CelerityException.html +32 -0
  178. data/website/yard/Celerity/Exception/MissingWayOfFindingObjectException.html +32 -0
  179. data/website/yard/Celerity/Exception/NavigationException.html +33 -0
  180. data/website/yard/Celerity/Exception/NoValueFoundException.html +33 -0
  181. data/website/yard/Celerity/Exception/ObjectDisabledException.html +33 -0
  182. data/website/yard/Celerity/Exception/ObjectReadOnlyException.html +33 -0
  183. data/website/yard/Celerity/Exception/UnexpectedPageException.html +33 -0
  184. data/website/yard/Celerity/Exception/UnknownCellException.html +33 -0
  185. data/website/yard/Celerity/Exception/UnknownFormException.html +33 -0
  186. data/website/yard/Celerity/Exception/UnknownFrameException.html +33 -0
  187. data/website/yard/Celerity/Exception/UnknownObjectException.html +33 -0
  188. data/website/yard/Celerity/Exception/UnknownRowException.html +33 -0
  189. data/website/yard/Celerity/FileField.html +289 -0
  190. data/website/yard/Celerity/FileFields.html +103 -0
  191. data/website/yard/Celerity/Form.html +284 -0
  192. data/website/yard/Celerity/Forms.html +103 -0
  193. data/website/yard/Celerity/Frame.html +527 -0
  194. data/website/yard/Celerity/Frames.html +103 -0
  195. data/website/yard/Celerity/H1.html +198 -0
  196. data/website/yard/Celerity/H1s.html +103 -0
  197. data/website/yard/Celerity/H2.html +198 -0
  198. data/website/yard/Celerity/H2s.html +103 -0
  199. data/website/yard/Celerity/H3.html +198 -0
  200. data/website/yard/Celerity/H3s.html +103 -0
  201. data/website/yard/Celerity/H4.html +198 -0
  202. data/website/yard/Celerity/H4s.html +103 -0
  203. data/website/yard/Celerity/H5.html +198 -0
  204. data/website/yard/Celerity/H5s.html +103 -0
  205. data/website/yard/Celerity/H6.html +198 -0
  206. data/website/yard/Celerity/H6s.html +103 -0
  207. data/website/yard/Celerity/Hidden.html +285 -0
  208. data/website/yard/Celerity/Hiddens.html +103 -0
  209. data/website/yard/Celerity/Image.html +645 -0
  210. data/website/yard/Celerity/Images.html +103 -0
  211. data/website/yard/Celerity/InputElement.html +271 -0
  212. data/website/yard/Celerity/Label.html +210 -0
  213. data/website/yard/Celerity/Labels.html +103 -0
  214. data/website/yard/Celerity/Li.html +198 -0
  215. data/website/yard/Celerity/Link.html +295 -0
  216. data/website/yard/Celerity/Links.html +103 -0
  217. data/website/yard/Celerity/Lis.html +103 -0
  218. data/website/yard/Celerity/Listener.html +821 -0
  219. data/website/yard/Celerity/Map.html +198 -0
  220. data/website/yard/Celerity/Maps.html +103 -0
  221. data/website/yard/Celerity/Meta.html +196 -0
  222. data/website/yard/Celerity/Metas.html +103 -0
  223. data/website/yard/Celerity/MethodGenerator.html +195 -0
  224. data/website/yard/Celerity/NonControlElement.html +212 -0
  225. data/website/yard/Celerity/Ol.html +198 -0
  226. data/website/yard/Celerity/Ols.html +103 -0
  227. data/website/yard/Celerity/Option.html +348 -0
  228. data/website/yard/Celerity/Options.html +103 -0
  229. data/website/yard/Celerity/P.html +198 -0
  230. data/website/yard/Celerity/Pre.html +198 -0
  231. data/website/yard/Celerity/Pres.html +103 -0
  232. data/website/yard/Celerity/Ps.html +103 -0
  233. data/website/yard/Celerity/Radio.html +339 -0
  234. data/website/yard/Celerity/RadioCheckCommon.html +453 -0
  235. data/website/yard/Celerity/Radios.html +103 -0
  236. data/website/yard/Celerity/SelectList.html +1122 -0
  237. data/website/yard/Celerity/SelectLists.html +103 -0
  238. data/website/yard/Celerity/ShortInspect.html +108 -0
  239. data/website/yard/Celerity/Span.html +198 -0
  240. data/website/yard/Celerity/Spans.html +103 -0
  241. data/website/yard/Celerity/Strong.html +198 -0
  242. data/website/yard/Celerity/Strongs.html +103 -0
  243. data/website/yard/Celerity/Table.html +1287 -0
  244. data/website/yard/Celerity/TableBodies.html +103 -0
  245. data/website/yard/Celerity/TableBody.html +203 -0
  246. data/website/yard/Celerity/TableCell.html +279 -0
  247. data/website/yard/Celerity/TableCells.html +103 -0
  248. data/website/yard/Celerity/TableElement.html +437 -0
  249. data/website/yard/Celerity/TableFooter.html +203 -0
  250. data/website/yard/Celerity/TableFooters.html +103 -0
  251. data/website/yard/Celerity/TableHeader.html +203 -0
  252. data/website/yard/Celerity/TableHeaders.html +103 -0
  253. data/website/yard/Celerity/TableRow.html +478 -0
  254. data/website/yard/Celerity/TableRows.html +103 -0
  255. data/website/yard/Celerity/Tables.html +103 -0
  256. data/website/yard/Celerity/TextField.html +938 -0
  257. data/website/yard/Celerity/TextFields.html +103 -0
  258. data/website/yard/Celerity/Th.html +208 -0
  259. data/website/yard/Celerity/Ul.html +209 -0
  260. data/website/yard/Celerity/Uls.html +103 -0
  261. data/website/yard/Celerity/Util.html +264 -0
  262. data/website/yard/Celerity/VERSION.html +44 -0
  263. data/website/yard/HtmlUnit.html +23 -0
  264. data/website/yard/HtmlUnit/Html.html +23 -0
  265. data/website/yard/HtmlUnit/Util.html +23 -0
  266. data/website/yard/Java/ComGargoylesoftwareHtmlunitHtml/HtmlPage.html +90 -0
  267. data/website/yard/Java/JavaLang/Iterable.html +103 -0
  268. data/website/yard/Java/OrgW3cDom/NamedNodeMap.html +97 -0
  269. data/website/yard/README.txt.html +116 -0
  270. data/website/yard/String.html +103 -0
  271. data/website/yard/all-files.html +22 -0
  272. data/website/yard/all-methods.html +3276 -0
  273. data/website/yard/all-namespaces.html +258 -0
  274. data/website/yard/app.js +18 -0
  275. data/website/yard/index.html +19 -0
  276. data/website/yard/jquery.js +11 -0
  277. data/website/yard/style.css +68 -0
  278. data/website/yard/syntax_highlight.css +21 -0
  279. metadata +285 -13
@@ -0,0 +1,244 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "Button" do
4
+
5
+ before :all do
6
+ @browser = Browser.new(BROWSER_OPTIONS)
7
+ end
8
+
9
+ before :each do
10
+ @browser.goto(HTML_DIR + "/forms_with_input_elements.html")
11
+ end
12
+
13
+ # Exists method
14
+ describe "#exists?" do
15
+ it "returns 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 "returns 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 "returns true if the button exists (default how = :value)" do
38
+ @browser.button("Submit").should exist
39
+ end
40
+
41
+ it "returns 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 "raises TypeError when 'what' argument is invalid" do
59
+ lambda { @browser.button(:id, 3.14).exists? }.should raise_error(TypeError)
60
+ end
61
+
62
+ it "raises 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 "returns the class name of the button" do
70
+ @browser.button(:name, "new_user_image").class_name.should == "image"
71
+ end
72
+
73
+ it "returns 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 "returns 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 "raises UnknownObjectException if button does not exist" do
86
+ lambda { @browser.button(:index, 1337).id }.should raise_error(UnknownObjectException, 'Unable to locate Button, using :index and 1337')
87
+ end
88
+ end
89
+
90
+ describe "#name" do
91
+ it "returns 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 "raises UnknownObjectException if the button does not exist" do
98
+ lambda { @browser.button(:name, "no_such_name").name }.should raise_error(UnknownObjectException, 'Unable to locate Button, using :name and "no_such_name"')
99
+ end
100
+ end
101
+
102
+ describe "#src" do
103
+ it "returns the url for the button image" do
104
+ @browser.button(:name, "new_user_image").src.should == "images/button.jpg"
105
+ end
106
+
107
+ it "raises UnknownObjectException if the button does not exist" do
108
+ lambda { @browser.button(:name, "no_such_name").src }.should raise_error(UnknownObjectException, 'Unable to locate Button, using :name and "no_such_name"')
109
+ end
110
+ end
111
+
112
+ describe "#style" do
113
+ it "returns 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 "returns 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 "raises UnknownObjectException if the button does not exist" do
122
+ lambda { @browser.button(:name, "no_such_name").style }.should raise_error(UnknownObjectException, 'Unable to locate Button, using :name and "no_such_name"')
123
+ end
124
+ end
125
+
126
+ describe "#title" do
127
+ it "returns the title of the button" do
128
+ @browser.button(:index, 1).title.should == 'Submit the form'
129
+ end
130
+
131
+ it "returns 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 "returns 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 "raises UnknownObjectException if button does not exist" do
144
+ lambda { @browser.button(:name, "no_such_name").type }.should raise_error(UnknownObjectException, 'Unable to locate Button, using :name and "no_such_name"')
145
+ end
146
+ end
147
+
148
+ describe "#value" do
149
+ it "returns 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 "raises UnknownObjectException if button does not exist" do
156
+ lambda { @browser.button(:name, "no_such_name").value }.should raise_error(UnknownObjectException, 'Unable to locate Button, using :name and "no_such_name"')
157
+ end
158
+ end
159
+
160
+ describe "#respond_to?" do
161
+ it "returns 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 "returns true if the button is enabled" do
176
+ @browser.button(:name, 'new_user_submit').should be_enabled
177
+ end
178
+
179
+ it "returns false if the button is disabled" do
180
+ @browser.button(:name, 'new_user_submit_disabled').should_not be_enabled
181
+ end
182
+
183
+ it "raises UnknownObjectException if the button doesn't exist" do
184
+ lambda { @browser.button(:name, "no_such_name").enabled? }.should raise_error(UnknownObjectException, 'Unable to locate Button, using :name and "no_such_name"')
185
+ end
186
+ end
187
+
188
+ describe "#disabled?" do
189
+ it "returns false when button is enabled" do
190
+ @browser.button(:name, 'new_user_submit').should_not be_disabled
191
+ end
192
+
193
+ it "returns true when button is disabled" do
194
+ @browser.button(:name, 'new_user_submit_disabled').should be_disabled
195
+ end
196
+
197
+ it "raises UnknownObjectException if button does not exist" do
198
+ lambda { @browser.button(:name, "no_such_name").disabled? }.should raise_error(UnknownObjectException, 'Unable to locate Button, using :name and "no_such_name"')
199
+ end
200
+ end
201
+
202
+ # Celerity API
203
+ describe "#click_and_attach" do
204
+ it "returns a new browser instance with the popup page" do
205
+ b = @browser.button(:name, 'new_popup_window').click_and_attach
206
+ b.should_not == @browser
207
+ b.title.should == "Tables"
208
+ @browser.title.should == "Forms with input elements"
209
+ end
210
+
211
+ it "returns a new browser with same log_level as original" do
212
+ b = @browser.button(:name, 'new_popup_window').click_and_attach
213
+ b.should_not == @browser
214
+ b.log_level.should == @browser.log_level
215
+ end
216
+ end
217
+
218
+ # Manipulation methods
219
+ describe "#click" do
220
+ it "clicks the button if it exists" do
221
+ @browser.goto(TEST_HOST + "/forms_with_input_elements.html")
222
+ @browser.button(:id, 'new_user_submit').click
223
+ @browser.text.should include("You posted the following content:")
224
+ end
225
+
226
+ it "fires events" do
227
+ @browser.button(:id, 'new_user_button').click
228
+ @browser.button(:id, 'new_user_button').value.should == 'new_value_set_by_onclick_event'
229
+ end
230
+
231
+ it "raises UnknownObjectException when clicking a button that doesn't exist" do
232
+ lambda { @browser.button(:value, "no_such_value").click }.should raise_error(UnknownObjectException, 'Unable to locate Button, using :value and "no_such_value"')
233
+ lambda { @browser.button(:id, "no_such_id").click }.should raise_error(UnknownObjectException, 'Unable to locate Button, using :id and "no_such_id"')
234
+ end
235
+
236
+ it "raises ObjectDisabledException when clicking a disabled button" do
237
+ lambda { @browser.button(:value, "Disabled").click }.should raise_error(ObjectDisabledException)
238
+ end
239
+ end
240
+
241
+ after :all do
242
+ @browser.close
243
+ end
244
+ end
@@ -0,0 +1,51 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "Buttons" do
4
+
5
+ before :all do
6
+ @browser = Browser.new(BROWSER_OPTIONS)
7
+ end
8
+
9
+ before :each do
10
+ @browser.goto(HTML_DIR + "/forms_with_input_elements.html")
11
+ end
12
+
13
+ describe "#length" do
14
+ it "returns the number of buttons" do
15
+ @browser.buttons.length.should == 8
16
+ end
17
+ end
18
+
19
+ describe "#[]" do
20
+ it "returns the button at the given index" do
21
+ @browser.buttons[1].title.should == "Submit the form"
22
+ end
23
+ end
24
+
25
+ describe "#first" do
26
+ it "returns the first element in the collection" do
27
+ @browser.buttons.first.value.should == @browser.buttons[1].value
28
+ end
29
+ end
30
+
31
+ describe "#last" do
32
+ it "returns the last element in the collection" do
33
+ @browser.buttons.last.value.should == @browser.buttons[0].value
34
+ end
35
+ end
36
+
37
+ describe "#each" do
38
+ it "iterates through buttons correctly" do
39
+ @browser.buttons.each_with_index do |b, index|
40
+ b.name.should == @browser.button(:index, index+1).name
41
+ b.id.should == @browser.button(:index, index+1).id
42
+ b.value.should == @browser.button(:index, index+1).value
43
+ end
44
+ end
45
+ end
46
+
47
+ after :all do
48
+ @browser.close
49
+ end
50
+
51
+ end
@@ -0,0 +1,302 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "CheckBox" do
4
+
5
+ before :all do
6
+ @browser = Browser.new(BROWSER_OPTIONS)
7
+ end
8
+
9
+ before :each do
10
+ @browser.goto(HTML_DIR + "/forms_with_input_elements.html")
11
+ end
12
+
13
+
14
+ # Exists method
15
+
16
+ describe "#exists?" do
17
+ it "returns 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 "returns true if the element exists (default how = :name)" do
34
+ @browser.checkbox("new_user_interests").should exist
35
+ end
36
+
37
+ it "returns 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 "returns 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 "returns 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 "returns 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 "raises TypeError when 'what' argument is invalid" do
70
+ lambda { @browser.checkbox(:id, 3.14).exists? }.should raise_error(TypeError)
71
+ end
72
+
73
+ it "raises 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 "returns 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 "returns 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 "raises 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 "returns 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 "returns 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 "raises 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 "returns 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 "returns 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 "raises 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 "returns 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 "returns 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 "raises 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 "returns the type attribute if the checkbox exists" do
139
+ @browser.checkbox(:index, 1).type.should == "checkbox"
140
+ end
141
+
142
+ it "raises 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 "returns the value attribute if the checkbox exists" do
149
+ @browser.checkbox(:id, 'new_user_interests_books').value.should == 'books'
150
+ end
151
+
152
+ it "raises 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 "returns 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 "returns 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 "returns 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 "raises 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 "returns true if the checkbox is disabled" do
189
+ @browser.checkbox(:id, 'new_user_interests_dentistry').should be_disabled
190
+ end
191
+
192
+ it "returns false if the checkbox is enabled" do
193
+ @browser.checkbox(:id, 'new_user_interests_books').should_not be_disabled
194
+ end
195
+
196
+ it "raises 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 "raises 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 "clears 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 "clears 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 "raises 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 "sets 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 "sets 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 "fires 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 "raises 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 "raises 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 "returns true if the checkbox button is set" do
262
+ @browser.checkbox(:id, "new_user_interests_books").should be_set
263
+ end
264
+
265
+ it "returns false if the checkbox button unset" do
266
+ @browser.checkbox(:id, "new_user_interests_cars").should_not be_set
267
+ end
268
+
269
+ it "returns 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 "raises 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 "returns 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 "returns 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 "raises 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
+