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,38 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "CheckBoxes" do
4
+ before :all do
5
+ @browser = Browser.new(BROWSER_OPTIONS)
6
+ end
7
+
8
+ before :each do
9
+ @browser.goto(HTML_DIR + "/forms_with_input_elements.html")
10
+ end
11
+
12
+ describe "#length" do
13
+ it "returns the number of checkboxes" do
14
+ @browser.checkboxes.length.should == 7
15
+ end
16
+ end
17
+
18
+ describe "#[]" do
19
+ it "returns the checkbox at the given index" do
20
+ @browser.checkboxes[1].id.should == "new_user_interests_books"
21
+ end
22
+ end
23
+
24
+ describe "#each" do
25
+ it "iterates through checkboxes correctly" do
26
+ @browser.checkboxes.each_with_index do |c, index|
27
+ c.name.should == @browser.checkbox(:index, index+1).name
28
+ c.id.should == @browser.checkbox(:index, index+1).id
29
+ c.value.should == @browser.checkbox(:index, index+1).value
30
+ end
31
+ end
32
+ end
33
+
34
+ after :all do
35
+ @browser.close
36
+ end
37
+
38
+ end
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "ClickableElement" do
4
+
5
+ before :all do
6
+ @browser = Browser.new(BROWSER_OPTIONS.merge(:log_level => :off))
7
+ end
8
+
9
+ before :each do
10
+ @browser.goto(HTML_DIR + "/non_control_elements.html")
11
+ end
12
+
13
+ describe "#click_and_attach" do
14
+ it 'opens a page in a new browser with the same options' do
15
+ browser = @browser.link(:name, /bad_attribute/).click_and_attach
16
+ browser.text.include?("User administration").should be_true # to make sure it is open.
17
+ browser.options.should == @browser.options
18
+ browser.cookies.should == @browser.cookies
19
+ end
20
+
21
+ it "opens the page in a new browser with the same cookies" do
22
+ @browser.add_cookie("localhost", "foo", "bar")
23
+ old_cookies = @browser.cookies
24
+ old_cookies.should_not be_empty
25
+
26
+ @browser.goto(HTML_DIR + "/non_control_elements.html")
27
+ browser = @browser.link(:name, /bad_attribute/).click_and_attach
28
+
29
+ browser.should_not == @browser
30
+ browser.cookies.should == old_cookies
31
+ end
32
+ end
33
+
34
+ describe "#download" do
35
+ it 'returns a click-opened page as io' do
36
+ expected = File.read "#{HTML_DIR}/forms_with_input_elements.html".sub("file://", '')
37
+
38
+ @browser.link(:name, /bad_attribute/).download.read.should == expected
39
+ @browser.link(:name, /bad_attribute/).should exist
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,143 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "Dd" do
4
+
5
+ before :all do
6
+ @browser = Browser.new(BROWSER_OPTIONS)
7
+ end
8
+
9
+ before :each do
10
+ @browser.goto(HTML_DIR + "/definition_lists.html")
11
+ end
12
+
13
+
14
+ # Exists method
15
+ describe "#exists?" do
16
+ it "returns true if the element exists" do
17
+ @browser.dd(:id, "someone").should exist
18
+ @browser.dd(:class, "name").should exist
19
+ @browser.dd(:xpath, "//dd[@id='someone']").should exist
20
+ @browser.dd(:index, 1).should exist
21
+ end
22
+
23
+ it "returns false if the element does not exist" do
24
+ @browser.dd(:id, "no_such_id").should_not exist
25
+ end
26
+
27
+ it "raises TypeError when 'what' argument is invalid" do
28
+ lambda { @browser.dd(:id, 3.14).exists? }.should raise_error(TypeError)
29
+ end
30
+
31
+ it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
32
+ lambda { @browser.dd(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
33
+ end
34
+ end
35
+
36
+ # Attribute methods
37
+ describe "#class_name" do
38
+ it "returns the class attribute if the element exists" do
39
+ @browser.dd(:id, "someone").class_name.should == "name"
40
+ end
41
+
42
+ it "returns an empty string if the element exists but the attribute doesn't" do
43
+ @browser.dd(:id, "city").class_name.should == ""
44
+ end
45
+
46
+ it "raises UnknownObjectException if the element does not exist" do
47
+ lambda { @browser.dd(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
48
+ lambda { @browser.dd(:title, "no_such_title").class_name }.should raise_error(UnknownObjectException)
49
+ lambda { @browser.dd(:index, 1337).class_name }.should raise_error(UnknownObjectException)
50
+ lambda { @browser.dd(:xpath, "//dd[@id='no_such_id']").class_name }.should raise_error(UnknownObjectException)
51
+ end
52
+ end
53
+
54
+ describe "#id" do
55
+ it "returns the id attribute if the element exists" do
56
+ @browser.dd(:class, 'name').id.should == "someone"
57
+ end
58
+
59
+ it "returns an empty string if the element exists, but the attribute doesn't" do
60
+ @browser.dd(:class, 'address').id.should == ""
61
+ end
62
+
63
+ it "raises UnknownObjectException if the element does not exist" do
64
+ lambda {@browser.dd(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
65
+ lambda {@browser.dd(:title, "no_such_id").id }.should raise_error(UnknownObjectException)
66
+ lambda {@browser.dd(:index, 1337).id }.should raise_error(UnknownObjectException)
67
+ end
68
+ end
69
+
70
+ describe "#title" do
71
+ it "returns the title of the element" do
72
+ @browser.dd(:class, "name").title.should == "someone"
73
+ end
74
+ end
75
+
76
+ describe "#text" do
77
+ it "returns the text of the element" do
78
+ @browser.dd(:id, "someone").text.should == "John Doe"
79
+ end
80
+
81
+ it "returns an empty string if the element exists but contains no text" do
82
+ @browser.dd(:class, 'noop').text.should == ""
83
+ end
84
+
85
+ it "raises UnknownObjectException if the element does not exist" do
86
+ lambda { @browser.dd(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
87
+ lambda { @browser.dd(:title, "no_such_title").text }.should raise_error(UnknownObjectException)
88
+ lambda { @browser.dd(:index, 1337).text }.should raise_error(UnknownObjectException)
89
+ lambda { @browser.dd(:xpath, "//dd[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
90
+ end
91
+ end
92
+
93
+ describe "#respond_to?" do
94
+ it "returns true for all attribute methods" do
95
+ @browser.dd(:index, 1).should respond_to(:id)
96
+ @browser.dd(:index, 1).should respond_to(:class_name)
97
+ @browser.dd(:index, 1).should respond_to(:style)
98
+ @browser.dd(:index, 1).should respond_to(:text)
99
+ @browser.dd(:index, 1).should respond_to(:title)
100
+ end
101
+ end
102
+
103
+ # Manipulation methods
104
+ describe "#click" do
105
+ it "fires events when clicked" do
106
+ @browser.dd(:title, 'education').text.should_not == 'changed'
107
+ @browser.dd(:title, 'education').click
108
+ @browser.dd(:title, 'education').text.should == 'changed'
109
+ end
110
+
111
+ it "raises UnknownObjectException if the element does not exist" do
112
+ lambda { @browser.dd(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
113
+ lambda { @browser.dd(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
114
+ lambda { @browser.dd(:index, 1337).click }.should raise_error(UnknownObjectException)
115
+ lambda { @browser.dd(:xpath, "//dd[@id='no_such_id']").click }.should raise_error(UnknownObjectException)
116
+ end
117
+ end
118
+
119
+ describe "#html" do
120
+ it "returns the HTML of the element" do
121
+ html = @browser.dd(:id, 'someone').html
122
+ html.should match(%r"John Doe"m)
123
+ html.should_not include('</body>')
124
+ end
125
+ end
126
+
127
+ describe "#to_s" do
128
+ it "returns a human readable representation of the element" do
129
+ @browser.dd(:id, 'someone').to_s.should ==
130
+ %q{tag: dd
131
+ id: someone
132
+ class: name
133
+ title: someone
134
+ text: John Doe}
135
+ end
136
+ end
137
+
138
+ after :all do
139
+ @browser.close
140
+ end
141
+
142
+ end
143
+
@@ -0,0 +1,39 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "Dds" do
4
+ before :all do
5
+ @browser = Browser.new(BROWSER_OPTIONS)
6
+ end
7
+
8
+ before :each do
9
+ @browser.goto(HTML_DIR + "/definition_lists.html")
10
+ end
11
+
12
+ describe "#length" do
13
+ it "returns the number of dds" do
14
+ @browser.dds.length.should == 11
15
+ end
16
+ end
17
+
18
+ describe "#[]" do
19
+ it "returns the dd at the given index" do
20
+ @browser.dds[2].title.should == "education"
21
+ end
22
+ end
23
+
24
+ describe "#each" do
25
+ it "iterates through dds correctly" do
26
+ @browser.dds.each_with_index do |d, index|
27
+ d.name.should == @browser.dd(:index, index+1).name
28
+ d.id.should == @browser.dd(:index, index+1).id
29
+ d.class_name.should == @browser.dd(:index, index+1).class_name
30
+ end
31
+ end
32
+ end
33
+
34
+ after :all do
35
+ @browser.close
36
+ end
37
+
38
+ end
39
+
@@ -0,0 +1,24 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "DefaultViewer" do
4
+
5
+ before :all do
6
+ @browser = Browser.new(BROWSER_OPTIONS)
7
+ @browser.goto(HTML_DIR + "/definition_lists.html")
8
+ end
9
+
10
+ describe ".save" do
11
+ it "saves the default image to the given path" do
12
+ fail("don't run specs with CelerityViewer") if @browser.viewer != Celerity::DefaultViewer
13
+ fname = File.expand_path "default_viewer_test.png"
14
+ default = "#{File.dirname(__FILE__)}/../lib/celerity/resources/no_viewer.png"
15
+
16
+ @browser.viewer.save(fname)
17
+ File.exist?(fname).should be_true
18
+ File.read(fname).should == File.read(default)
19
+
20
+ File.delete(fname)
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,235 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "Div" do
4
+
5
+ before :all do
6
+ @browser = Browser.new(BROWSER_OPTIONS)
7
+ end
8
+
9
+ before :each do
10
+ @browser.goto(HTML_DIR + "/non_control_elements.html")
11
+ end
12
+
13
+
14
+ # Exists method
15
+ describe "#exists?" do
16
+ it "returns true if the element exists" do
17
+ @browser.div(:id, "header").should exist
18
+ @browser.div(:id, /header/).should exist
19
+ @browser.div(:title, "Header and primary navigation").should exist
20
+ @browser.div(:title, /Header and primary navigation/).should exist
21
+ @browser.div(:text, "This is a footer.").should exist
22
+ @browser.div(:text, /This is a footer\./).should exist
23
+ @browser.div(:class, "profile").should exist
24
+ @browser.div(:class, /profile/).should exist
25
+ @browser.div(:index, 1).should exist
26
+ @browser.div(:xpath, "//div[@id='header']").should exist
27
+ end
28
+
29
+ it "returns true if the element exists (default how = :id)" do
30
+ @browser.div("header").should exist
31
+ end
32
+
33
+ it "returns false if the element does not exist" do
34
+ @browser.div(:id, "no_such_id").should_not exist
35
+ @browser.div(:id, /no_such_id/).should_not exist
36
+ @browser.div(:title, "no_such_title").should_not exist
37
+ @browser.div(:title, /no_such_title/).should_not exist
38
+ @browser.div(:text, "no_such_text").should_not exist
39
+ @browser.div(:text, /no_such_text/).should_not exist
40
+ @browser.div(:class, "no_such_class").should_not exist
41
+ @browser.div(:class, /no_such_class/).should_not exist
42
+ @browser.div(:index, 1337).should_not exist
43
+ @browser.div(:xpath, "//div[@id='no_such_id']").should_not exist
44
+ end
45
+
46
+ it "raises TypeError when 'what' argument is invalid" do
47
+ lambda { @browser.div(:id, 3.14).exists? }.should raise_error(TypeError)
48
+ end
49
+
50
+ it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
51
+ lambda { @browser.div(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
52
+ end
53
+ end
54
+
55
+ # Attribute methods
56
+ describe "#class_name" do
57
+ it "returns the class attribute if the element exists" do
58
+ @browser.div(:id , "footer").class_name.should == "profile"
59
+ end
60
+
61
+ it "returns an empty string if the element exists but the attribute doesn't" do
62
+ @browser.div(:id , "content").class_name.should == ""
63
+ end
64
+
65
+ it "raises UnknownObjectException if the element does not exist" do
66
+ lambda { @browser.div(:id, "no_such_id").class_name }.should raise_error(UnknownObjectException)
67
+ lambda { @browser.div(:title, "no_such_title").class_name }.should raise_error(UnknownObjectException)
68
+ lambda { @browser.div(:index, 1337).class_name }.should raise_error(UnknownObjectException)
69
+ lambda { @browser.div(:xpath, "//div[@id='no_such_id']").class_name }.should raise_error(UnknownObjectException)
70
+ end
71
+ end
72
+
73
+ describe "#id" do
74
+ it "returns the id attribute if the element exists" do
75
+ @browser.div(:index, 2).id.should == "outer_container"
76
+ end
77
+
78
+ it "returns an empty string if the element exists, but the attribute doesn't" do
79
+ @browser.div(:index, 1).id.should == ""
80
+ end
81
+
82
+ it "raises UnknownObjectException if the element does not exist" do
83
+ lambda {@browser.div(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
84
+ lambda {@browser.div(:title, "no_such_id").id }.should raise_error(UnknownObjectException)
85
+ lambda {@browser.div(:index, 1337).id }.should raise_error(UnknownObjectException)
86
+ end
87
+
88
+ it "should take all conditions into account when locating by id" do
89
+ @browser.goto HTML_DIR + "/multiple_ids.html"
90
+ @browser.div(:id => "multiple", :class => "bar").class_name.should == "bar"
91
+ end
92
+ end
93
+
94
+ describe "#name" do
95
+ it "returns the name attribute if the element exists" do
96
+ @browser.div(:id, 'promo').name.should == "invalid_attribute"
97
+ end
98
+
99
+ it "returns an empty string if the element exists but the attribute doesn't" do
100
+ @browser.div(:index, 1).name.should == ""
101
+ end
102
+
103
+ it "raises UnknownObjectException if the element does not exist" do
104
+ lambda {@browser.div(:id, "no_such_id").name }.should raise_error(UnknownObjectException)
105
+ lambda {@browser.div(:title, "no_such_title").name }.should raise_error(UnknownObjectException)
106
+ lambda {@browser.div(:index, 1337).name }.should raise_error(UnknownObjectException)
107
+ end
108
+ end
109
+
110
+ describe "#style" do
111
+ it "returns the style attribute if the element exists" do
112
+ @browser.div(:id, 'best_language').style.should == "color: red; text-decoration: underline; cursor: pointer;"
113
+ end
114
+
115
+ it "returns an empty string if the element exists but the attribute doesn't" do
116
+ @browser.div(:id, 'promo').style.should == ""
117
+ end
118
+
119
+ it "raises UnknownObjectException if the element does not exist" do
120
+ lambda {@browser.div(:id, "no_such_id").style }.should raise_error(UnknownObjectException)
121
+ end
122
+ end
123
+
124
+ describe "#text" do
125
+ it "returns the text of the div" do
126
+ @browser.div(:id, "footer").text.strip.should == "This is a footer."
127
+ @browser.div(:title, "Closing remarks").text.strip.should == "This is a footer."
128
+ @browser.div(:xpath, "//div[@id='footer']").text.strip.should == "This is a footer."
129
+ end
130
+
131
+ it "returns an empty string if the element exists but contains no text" do
132
+ @browser.div(:index, 1).text.strip.should == ""
133
+ end
134
+
135
+ it "returns an empty string if the div is hidden" do
136
+ @browser.div(:id, 'hidden').text.should == ""
137
+ end
138
+
139
+ it "raises UnknownObjectException if the element does not exist" do
140
+ lambda { @browser.div(:id, "no_such_id").text }.should raise_error(UnknownObjectException)
141
+ lambda { @browser.div(:title, "no_such_title").text }.should raise_error(UnknownObjectException)
142
+ lambda { @browser.div(:index, 1337).text }.should raise_error(UnknownObjectException)
143
+ lambda { @browser.div(:xpath, "//div[@id='no_such_id']").text }.should raise_error(UnknownObjectException)
144
+ end
145
+ end
146
+
147
+ describe "#value" do
148
+ it "returns the value attribute if the element exists" do
149
+ @browser.div(:id, 'promo').value.should == "invalid_attribute"
150
+ end
151
+
152
+ it "returns an empty string if the element exists but the attribute doesn't" do
153
+ @browser.div(:index, 1).value.should == ""
154
+ end
155
+
156
+ it "raises UnknownObjectException if the element does not exist" do
157
+ lambda {@browser.div(:id, "no_such_id").value }.should raise_error(UnknownObjectException)
158
+ lambda {@browser.div(:title, "no_such_title").value }.should raise_error(UnknownObjectException)
159
+ lambda {@browser.div(:index, 1337).value }.should raise_error(UnknownObjectException)
160
+ end
161
+ end
162
+
163
+ describe "#respond_to?" do
164
+ it "returns true for all attribute methods" do
165
+ @browser.div(:index, 1).should respond_to(:class_name)
166
+ @browser.div(:index, 1).should respond_to(:id)
167
+ @browser.div(:index, 1).should respond_to(:name)
168
+ @browser.div(:index, 1).should respond_to(:style)
169
+ @browser.div(:index, 1).should respond_to(:text)
170
+ @browser.div(:index, 1).should respond_to(:value)
171
+ end
172
+ end
173
+
174
+ # Manipulation methods
175
+ describe "#click" do
176
+ it "fires events when clicked" do
177
+ @browser.div(:id, 'best_language').text.should_not == 'Ruby!'
178
+ @browser.div(:id, 'best_language').click
179
+ @browser.div(:id, 'best_language').text.should == 'Ruby!'
180
+ end
181
+
182
+ it "raises UnknownObjectException if the element does not exist" do
183
+ lambda { @browser.div(:id, "no_such_id").click }.should raise_error(UnknownObjectException)
184
+ lambda { @browser.div(:title, "no_such_title").click }.should raise_error(UnknownObjectException)
185
+ lambda { @browser.div(:index, 1337).click }.should raise_error(UnknownObjectException)
186
+ lambda { @browser.div(:xpath, "//div[@id='no_such_id']").click }.should raise_error(UnknownObjectException)
187
+ end
188
+ end
189
+
190
+ describe "#double_click" do
191
+ it "fires the ondblclick event" do
192
+ double_clicked = false
193
+ @browser.add_listener(:alert) { double_clicked = true }
194
+ @browser.div(:id, 'html_test').double_click
195
+ double_clicked.should be_true
196
+ end
197
+ end
198
+
199
+ describe "#right_click" do
200
+ it "fires the oncontextmenu event" do
201
+ right_clicked = false
202
+ @browser.goto(HTML_DIR + "/right_click.html")
203
+ @browser.add_listener(:alert) { right_clicked = true }
204
+ @browser.div(:id, "click").right_click
205
+ right_clicked.should be_true
206
+ end
207
+ end
208
+
209
+ describe "#html" do
210
+ it "returns the HTML of the element" do
211
+ html = @browser.div(:id, 'footer').html
212
+ html.should include('<div id="footer" title="Closing remarks" class="profile">')
213
+ html.should include('This is a footer.')
214
+ html.should_not include('<div id="content">')
215
+ html.should_not include('</body>')
216
+ end
217
+ end
218
+
219
+ describe "#to_s" do
220
+ it "returns a human readable representation of the element" do
221
+ @browser.div(:id, 'footer').to_s.should ==
222
+ %q{tag: div
223
+ id: footer
224
+ title: Closing remarks
225
+ class: profile
226
+ text: This is a footer.}
227
+ end
228
+ end
229
+
230
+ after :all do
231
+ @browser.close
232
+ end
233
+
234
+ end
235
+