celerity 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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
@@ -1,119 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
- <head>
4
- <title>Tables</title>
5
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
- </head>
7
- <body>
8
- <h1>Tables</h1>
9
- <h2>Semantic table</h2>
10
- <table cellspacing="0" cellpadding="5" rules="groups" frame="box" border="1" id="axis_example" summary="Hugh Laurie made more money than Gregory House in both March and April of 2008.">
11
- <caption>Income tax information for Gregory House and Hugh Laurie</caption>
12
- <colgroup width="25%" align="left"></colgroup>
13
- <colgroup width="25%" span="3" align="right"></colgroup>
14
- <thead id="tax_headers">
15
- <tr style="border-bottom: 1px solid black;" class="dark">
16
- <th></th>
17
- <th id="before_tax" axis="cash" abbr="Before tax">Before income tax</th>
18
- <th id="tax" axis="cash" abbr="Tax">Income tax</th>
19
- <th id="after_tax" axis="cash" abbr="After tax">After income tax</th>
20
- </tr>
21
- </thead>
22
- <tfoot id="tax_totals">
23
- <tr class="dark">
24
- <th axis="sum">Sum</th>
25
- <td headers="before_tax">24 349</td>
26
- <td headers="tax">5 577</td>
27
- <td headers="after_tax">18 722</td>
28
- </tr>
29
- </tfoot>
30
- <tbody id="first">
31
- <tr>
32
- <th id="d1" axis="date" scope="rowgroup">March 2008</th>
33
- <th></th>
34
- <th></th>
35
- <th></th>
36
- </tr>
37
- <tr>
38
- <td id="p1" abbr="Dr. House">Gregory House</td>
39
- <td headers="before_tax p1 d1">5 934</td>
40
- <td headers="tax p1 d1">1 347</td>
41
- <td headers="after_tax p1 d1">4 587</td>
42
- </tr>
43
- <tr>
44
- <td id="p2" abbr="Laurie">Hugh Laurie</td>
45
- <td headers="before_tax p2 d1">6 300</td>
46
- <td headers="tax p2 d1">1 479</td>
47
- <td headers="after_tax p2 d1">4 821</td>
48
- </tr>
49
- </tbody>
50
- <tbody name="second" id="second">
51
- <tr>
52
- <th id="d2" axis="date" scope="rowgroup">April 2008</th>
53
- <th></th>
54
- <th></th>
55
- <th></th>
56
- </tr>
57
- <tr>
58
- <td id="p3" abbr="Dr. House">Gregory House</td>
59
- <td headers="before_tax p3 d2">5 863</td>
60
- <td headers="tax p3 d2">1 331</td>
61
- <td headers="after_tax p3 d2">4 532</td>
62
- </tr>
63
- <tr>
64
- <td id="p4" abbr="Laurie">Hugh Laurie</td>
65
- <td headers="before_tax p4 d2">6 252</td>
66
- <td headers="tax p4 d2">1 420</td>
67
- <td headers="after_tax p4 d2">4 832</td>
68
- </tr>
69
- </tbody>
70
- </table>
71
- <h2>Table inside a table</h2>
72
- <table border="1" id="outer">
73
- <tr id="outer_first">
74
- <td>
75
- Table 1, Row 1, Cell 1
76
- </td>
77
- <td>
78
- Table 1, Row 1, Cell 2
79
- </td>
80
- </tr>
81
- <tr>
82
- <td id="t1_r2_c1">
83
- Table 1, Row 2, Cell 1
84
- </td>
85
- <td>
86
- Table 1, Row 2, Cell 2
87
- <table border="1" id="inner">
88
- <tr id="inner_first">
89
- <td id="t2_r1_c1">
90
- Table 2, Row 1, Cell 1
91
- </td>
92
- <td>
93
- Table 2, Row 1, Cell 2
94
- </td>
95
- </tr>
96
- </table>
97
- </td>
98
- </tr>
99
- <tr id="outer_last">
100
- <td>
101
- Table 1, Row 3, Cell 1
102
- </td>
103
- <td>
104
- Table 1, Row 3, Cell 2
105
- </td>
106
- </tr>
107
- </table>
108
- <h2>Colspan</h2>
109
- <table border="1" id="colspan">
110
- <tr>
111
- <td colspan="2" id="colspan_2">Colspan 2</td>
112
- </tr>
113
- <tr>
114
- <td id="no_colspan">No colspan attribute</td>
115
- <td>No colspan attribute</td>
116
- </tr>
117
- </table>
118
- </body>
119
- </html>
@@ -1,15 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
- <html xmlns="http://www.w3.org/1999/xhtml">
4
- <head>
5
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
6
- <title>
7
- UTF-8
8
- </title>
9
- </head>
10
- <body>
11
- <p>
12
- æåø
13
- </p>
14
- </body>
15
- </html>
@@ -1,26 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "HtmlUnit bugs" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- describe "HtmlUnit bug 1968686: https://sourceforge.net/tracker/index.php?func=detail&aid=1968686&group_id=47038&atid=448266" do
10
- it "should not raise NativeException: java.lang.StackOverflowError when going to a page where Javascripts prints a <body> tag inside another <body> tag" do
11
- lambda { @browser.goto(TEST_HOST + "/bug_javascript_001.html") }.should_not raise_error(NativeException)
12
- end
13
- end
14
-
15
- describe "HtmlUnit bug 1968708: https://sourceforge.net/tracker/index.php?func=detail&aid=1968708&group_id=47038&atid=448266" do
16
- it "should only consider the first attribute if there are duplicate attributes" do
17
- @browser.goto(TEST_HOST + "/bug_duplicate_attributes.html")
18
- @browser.text_field(:index, 1).id.should == "org_id"
19
- end
20
- end
21
-
22
- after :all do
23
- @browser.close
24
- end
25
-
26
- end
data/spec/image_spec.rb DELETED
@@ -1,220 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "Image" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- before :each do
10
- @browser.goto(TEST_HOST + "/images.html")
11
- end
12
-
13
- # Exists method
14
- describe "#exists" do
15
- it "should return true when the image exists" do
16
- @browser.image(:id, 'square').should exist
17
- @browser.image(:id, /square/).should exist
18
- @browser.image(:name, 'circle').should exist
19
- @browser.image(:name, /circle/).should exist
20
- @browser.image(:src, 'images/circle.jpg').should exist
21
- @browser.image(:src, /circle/).should exist
22
- @browser.image(:alt, 'circle').should exist
23
- @browser.image(:alt, /cir/).should exist
24
- @browser.image(:title, 'Circle').should exist
25
- end
26
-
27
- it "should return true if the element exists (default how = :id)" do
28
- @browser.image("images/circle.jpg").should exist
29
- end
30
-
31
- it "should return false when the image exists" do
32
- @browser.image(:id, 'no_such_id').should_not exist
33
- @browser.image(:id, /no_such_id/).should_not exist
34
- @browser.image(:name, 'no_such_name').should_not exist
35
- @browser.image(:name, /no_such_name/).should_not exist
36
- @browser.image(:src, 'no_such_src').should_not exist
37
- @browser.image(:src, /no_such_src/).should_not exist
38
- @browser.image(:alt, 'no_such_alt').should_not exist
39
- @browser.image(:alt, /no_such_alt/).should_not exist
40
- @browser.image(:title, 'no_such_title').should_not exist
41
- @browser.image(:title, /no_such_title/).should_not exist
42
- end
43
-
44
- it "should raise ArgumentError when 'what' argument is invalid" do
45
- lambda { @browser.button(:id, 3.14).exists? }.should raise_error(ArgumentError)
46
- end
47
-
48
- it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
49
- lambda { @browser.button(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
50
- end
51
- end
52
-
53
- # Attribute methods
54
- describe "#alt" do
55
- it "should return the alt attribute of the image if the image exists" do
56
- @browser.image(:name, 'square').alt.should == "square"
57
- @browser.image(:name, 'circle').alt.should == 'circle'
58
- end
59
-
60
- it "should return an empty string if the image exists and the attribute doesn't" do
61
- @browser.image(:index, 1).alt.should == ""
62
- end
63
-
64
- it "should raise UnknownObjectException if the image doesn't exist" do
65
- lambda { @browser.image(:index, 1337).alt }.should raise_error(UnknownObjectException)
66
- end
67
- end
68
-
69
- describe "#id" do
70
- it "should return the id attribute of the image if the image exists" do
71
- @browser.image(:name, 'square').id.should == 'square'
72
- end
73
-
74
- it "should return an empty string if the image exists and the attribute doesn't" do
75
- @browser.image(:index, 1).id.should == ""
76
- end
77
-
78
- it "should raise UnknownObjectException if the image doesn't exist" do
79
- lambda { @browser.image(:index, 1337).id }.should raise_error(UnknownObjectException)
80
- end
81
- end
82
-
83
- describe "#name" do
84
- it "should return the name attribute of the image if the image exists" do
85
- @browser.image(:name, 'square').name.should == 'square'
86
- end
87
-
88
- it "should return an empty string if the image exists and the attribute doesn't" do
89
- @browser.image(:index, 1).name.should == ""
90
- end
91
-
92
- it "should raise UnknownObjectException if the image doesn't exist" do
93
- lambda { @browser.image(:index, 1337).name }.should raise_error(UnknownObjectException)
94
- end
95
- end
96
-
97
- describe "#src" do
98
- it "should return the src attribute of the image if the image exists" do
99
- @browser.image(:name, 'square').src.should match(/square\.jpg/i)
100
- end
101
-
102
- it "should return an empty string if the image exists and the attribute doesn't" do
103
- @browser.image(:index, 1).src.should == ""
104
- end
105
-
106
- it "should raise UnknownObjectException if the image doesn't exist" do
107
- lambda { @browser.image(:index, 1337).src }.should raise_error(UnknownObjectException)
108
- end
109
- end
110
-
111
- describe "#title" do
112
- it "should return the title attribute of the image if the image exists" do
113
- @browser.image(:id, 'square').title.should == 'Square'
114
- end
115
-
116
- it "should return an empty string if the image exists and the attribute doesn't" do
117
- @browser.image(:index, 1).title.should == ""
118
- end
119
-
120
- it "should raise UnknownObjectException if the image doesn't exist" do
121
- lambda { @browser.image(:index, 1337).title }.should raise_error(UnknownObjectException)
122
- end
123
- end
124
-
125
- describe "#respond_to?" do
126
- it "should return true for all attribute methods" do
127
- @browser.image(:index, 1).should respond_to(:class_name)
128
- @browser.image(:index, 1).should respond_to(:id)
129
- @browser.image(:index, 1).should respond_to(:name)
130
- @browser.image(:index, 1).should respond_to(:style)
131
- @browser.image(:index, 1).should respond_to(:text)
132
- @browser.image(:index, 1).should respond_to(:value)
133
- end
134
- end
135
-
136
-
137
- # Manipulation methods
138
- describe "#click" do
139
- it "should raise UnknownObjectException when the image doesn't exist" do
140
- lambda { @browser.image(:id, 'missing_attribute').click }.should raise_error(UnknownObjectException)
141
- lambda { @browser.image(:name, 'missing_attribute').click }.should raise_error(UnknownObjectException)
142
- lambda { @browser.image(:src, 'missing_attribute').click }.should raise_error(UnknownObjectException)
143
- lambda { @browser.image(:alt, 'missing_attribute').click }.should raise_error(UnknownObjectException)
144
- end
145
- end
146
-
147
- # File methods
148
- describe "#file_created_date" do
149
- it "should return the date the image was created as reported by the file system" do
150
- image = @browser.image(:index, 2)
151
- path = File.dirname(__FILE__) + "/html/#{image.src}"
152
- image.file_created_date.to_i.should == File.mtime(path).to_i
153
- end
154
- end
155
-
156
- describe "#file_size" do
157
- it "should return the file size of the image if the image exists" do
158
- @browser.image(:id, 'square').file_size.should == 788
159
- end
160
-
161
- it "should raise UnknownObjectException if the image doesn't exist" do
162
- lambda { @browser.image(:index, 1337).file_size }.should raise_error(UnknownObjectException)
163
- end
164
- end
165
-
166
- describe "#height" do
167
- it "should return the height of the image if the image exists" do
168
- @browser.image(:id, 'square').height.should == 88
169
- end
170
-
171
- it "should raise UnknownObjectException if the image doesn't exist" do
172
- lambda { @browser.image(:index, 1337).height }.should raise_error(UnknownObjectException)
173
- end
174
- end
175
-
176
- describe "#width" do
177
- it "should return the width of the image if the image exists" do
178
- @browser.image(:id, 'square').width.should == 88
179
- end
180
-
181
- it "should raise UnknownObjectException if the image doesn't exist" do
182
- lambda { @browser.image(:index, 1337).width }.should raise_error(UnknownObjectException)
183
- end
184
- end
185
-
186
- # Other
187
- describe "#loaded?" do
188
- it "should return true if the image has been loaded" do
189
- @browser.image(:name, 'circle').should be_loaded
190
- @browser.image(:alt, 'circle').should be_loaded
191
- @browser.image(:alt, /circle/).should be_loaded
192
- end
193
-
194
- it "should return false if the image has not been loaded" do
195
- @browser.image(:id, 'no_such_file').should_not be_loaded
196
- end
197
-
198
- it "should raise UnknownObjectException if the image doesn't exist" do
199
- lambda { @browser.image(:name, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
200
- lambda { @browser.image(:id, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
201
- lambda { @browser.image(:src, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
202
- lambda { @browser.image(:alt, 'no_such_image').loaded? }.should raise_error(UnknownObjectException)
203
- lambda { @browser.image(:index, 1337).loaded? }.should raise_error(UnknownObjectException)
204
- end
205
- end
206
-
207
- describe "#save" do
208
- it "should save an image to file" do
209
- file = "sample.img.dat"
210
- @browser.image(:index, 2).save(file)
211
- File.exist?(file).should be_true
212
- File.delete(file)
213
- end
214
- end
215
-
216
- after :all do
217
- @browser.close
218
- end
219
-
220
- end
data/spec/images_spec.rb DELETED
@@ -1,39 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "Images" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- before :each do
10
- @browser.goto(TEST_HOST + "/images.html")
11
- end
12
-
13
- describe "#length" do
14
- it "should return the number of images" do
15
- @browser.images.length.should == 9
16
- end
17
- end
18
-
19
- describe "#[]" do
20
- it "should return the image at the given index" do
21
- @browser.images[6].id.should == "square"
22
- end
23
- end
24
-
25
- describe "#each" do
26
- it "should iterate through images correctly" do
27
- @browser.images.each_with_index do |c, index|
28
- c.name.should == @browser.image(:index, index+1).name
29
- c.id.should == @browser.image(:index, index+1).id
30
- c.value.should == @browser.image(:index, index+1).value
31
- end
32
- end
33
- end
34
-
35
- after :all do
36
- @browser.close
37
- end
38
-
39
- end
data/spec/label_spec.rb DELETED
@@ -1,79 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "Label" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- before :each do
10
- @browser.goto(TEST_HOST + "/forms_with_input_elements.html")
11
- end
12
-
13
- # Exists method
14
- describe "#exists?" do
15
- it "should return true if the element exists" do
16
- @browser.label(:id, 'first_label').should exist
17
- @browser.label(:id, /first_label/).should exist
18
- @browser.label(:text, 'First name').should exist
19
- @browser.label(:text, /First name/).should exist
20
- @browser.label(:index, 1).should exist
21
- @browser.label(:xpath, "//label[@id='first_label']").should exist
22
- end
23
-
24
- it "should return true if the element exists (default how = :text)" do
25
- @browser.label("First name").should exist
26
- end
27
-
28
- it "should return false if the element does not exist" do
29
- @browser.label(:id, 'no_such_id').should_not exist
30
- @browser.label(:id, /no_such_id/).should_not exist
31
- @browser.label(:text, 'no_such_text').should_not exist
32
- @browser.label(:text, /no_such_text/).should_not exist
33
- @browser.label(:index, 1337).should_not exist
34
- @browser.label(:xpath, "//input[@id='no_such_id']").should_not exist
35
- end
36
-
37
- it "should raise ArgumentError when 'what' argument is invalid" do
38
- lambda { @browser.label(:id, 3.14).exists? }.should raise_error(ArgumentError)
39
- end
40
-
41
- it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
42
- lambda { @browser.label(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
43
- end
44
- end
45
-
46
- # Attribute methods
47
- describe "#id" do
48
- it "should return the id attribute if the label exists" do
49
- @browser.label(:index, 1).id.should == "first_label"
50
- end
51
-
52
- it "should raise UnknownObjectException if the label doesn't exist" do
53
- lambda { @browser.label(:index, 1337).id }.should raise_error(UnknownObjectException)
54
- end
55
- end
56
-
57
- describe "#for" do
58
- it "should return the 'for' attribute if the label exists" do
59
- @browser.label(:index, 1).for.should == "new_user_first_name"
60
- end
61
-
62
- it "should raise UnknownObjectException if the label doesn't exist" do
63
- lambda { @browser.label(:index, 1337).for }.should raise_error(UnknownObjectException)
64
- end
65
- end
66
-
67
- describe "#respond_to?" do
68
- it "should return true for all attribute methods" do
69
- @browser.label(:index, 1).should respond_to(:id)
70
- @browser.label(:index, 1).should respond_to(:for)
71
- end
72
- end
73
-
74
-
75
- after :all do
76
- @browser.close
77
- end
78
- end
79
-