celerity 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. data/History.txt +33 -0
  2. data/README.txt +19 -9
  3. data/Rakefile +9 -3
  4. data/lib/celerity.rb +39 -39
  5. data/lib/celerity/browser.rb +538 -153
  6. data/lib/celerity/clickable_element.rb +48 -7
  7. data/lib/celerity/collections.rb +155 -131
  8. data/lib/celerity/container.rb +766 -385
  9. data/lib/celerity/default_viewer.rb +10 -0
  10. data/lib/celerity/disabled_element.rb +19 -2
  11. data/lib/celerity/element.rb +152 -83
  12. data/lib/celerity/element_collection.rb +106 -0
  13. data/lib/celerity/element_locator.rb +89 -66
  14. data/lib/celerity/elements/button.rb +23 -13
  15. data/lib/celerity/elements/file_field.rb +17 -5
  16. data/lib/celerity/elements/form.rb +21 -16
  17. data/lib/celerity/elements/frame.rb +75 -53
  18. data/lib/celerity/elements/image.rb +76 -63
  19. data/lib/celerity/elements/label.rb +4 -2
  20. data/lib/celerity/elements/link.rb +30 -18
  21. data/lib/celerity/elements/meta.rb +6 -0
  22. data/lib/celerity/{non_control_elements.rb → elements/non_control_elements.rb} +106 -76
  23. data/lib/celerity/elements/option.rb +16 -2
  24. data/lib/celerity/elements/radio_check.rb +55 -20
  25. data/lib/celerity/elements/select_list.rb +65 -29
  26. data/lib/celerity/elements/table.rb +141 -94
  27. data/lib/celerity/elements/table_cell.rb +13 -6
  28. data/lib/celerity/elements/{table_body.rb → table_elements.rb} +20 -8
  29. data/lib/celerity/elements/table_row.rb +23 -7
  30. data/lib/celerity/elements/text_field.rb +89 -33
  31. data/lib/celerity/exception.rb +77 -41
  32. data/lib/celerity/extra/method_generator.rb +42 -24
  33. data/lib/celerity/htmlunit.rb +49 -0
  34. data/lib/celerity/htmlunit/commons-collections-3.2.1.jar +0 -0
  35. data/lib/celerity/htmlunit/htmlunit-2.5-SNAPSHOT.jar +0 -0
  36. data/lib/celerity/htmlunit/htmlunit-core-js-2.5-SNAPSHOT.jar +0 -0
  37. data/lib/celerity/htmlunit/nekohtml-1.9.12-20090308.130127-11.jar +0 -0
  38. data/lib/celerity/htmlunit/serializer-2.7.1.jar +0 -0
  39. data/lib/celerity/htmlunit/xalan-2.7.1.jar +0 -0
  40. data/lib/celerity/htmlunit/xml-apis-1.3.04.jar +0 -0
  41. data/lib/celerity/identifier.rb +3 -2
  42. data/lib/celerity/input_element.rb +5 -5
  43. data/lib/celerity/listener.rb +135 -0
  44. data/lib/celerity/resources/no_viewer.png +0 -0
  45. data/lib/celerity/util.rb +88 -0
  46. data/lib/celerity/version.rb +4 -3
  47. data/lib/celerity/watir_compatibility.rb +35 -25
  48. data/tasks/jar.rake +57 -0
  49. metadata +35 -142
  50. data.tar.gz.sig +0 -0
  51. data/Manifest.txt +0 -150
  52. data/lib/celerity/element_collections.rb +0 -54
  53. data/lib/celerity/element_map.rb +0 -51
  54. data/lib/celerity/elements/table_footer.rb +0 -30
  55. data/lib/celerity/elements/table_header.rb +0 -30
  56. data/lib/celerity/htmlunit/commons-collections-3.2.jar +0 -0
  57. data/lib/celerity/htmlunit/download.sh +0 -23
  58. data/lib/celerity/htmlunit/htmlunit-2.2.jar +0 -0
  59. data/lib/celerity/htmlunit/htmlunit-core-js-2.2.jar +0 -0
  60. data/lib/celerity/htmlunit/nekohtml-1.9.8.jar +0 -0
  61. data/lib/celerity/htmlunit/xalan-2.7.0.jar +0 -0
  62. data/lib/celerity/htmlunit/xml-apis-1.0.b2.jar +0 -0
  63. data/spec/area_spec.rb +0 -97
  64. data/spec/areas_spec.rb +0 -40
  65. data/spec/browser_spec.rb +0 -266
  66. data/spec/button_spec.rb +0 -227
  67. data/spec/buttons_spec.rb +0 -39
  68. data/spec/checkbox_spec.rb +0 -302
  69. data/spec/checkboxes_spec.rb +0 -38
  70. data/spec/div_spec.rb +0 -207
  71. data/spec/divs_spec.rb +0 -39
  72. data/spec/element_spec.rb +0 -79
  73. data/spec/filefield_spec.rb +0 -123
  74. data/spec/filefields_spec.rb +0 -40
  75. data/spec/form_spec.rb +0 -59
  76. data/spec/forms_spec.rb +0 -41
  77. data/spec/frame_spec.rb +0 -121
  78. data/spec/frames_spec.rb +0 -71
  79. data/spec/hidden_spec.rb +0 -127
  80. data/spec/hiddens_spec.rb +0 -39
  81. data/spec/hn_spec.rb +0 -104
  82. data/spec/hns_spec.rb +0 -45
  83. data/spec/html/2000_spans.html +0 -2009
  84. data/spec/html/bug_duplicate_attributes.html +0 -14
  85. data/spec/html/bug_javascript_001.html +0 -11
  86. data/spec/html/form_js_bug.html +0 -11
  87. data/spec/html/forms_with_input_elements.html +0 -114
  88. data/spec/html/frame_1.html +0 -17
  89. data/spec/html/frame_2.html +0 -16
  90. data/spec/html/frames.html +0 -11
  91. data/spec/html/iframes.html +0 -12
  92. data/spec/html/images.html +0 -27
  93. data/spec/html/images/1.gif +0 -0
  94. data/spec/html/images/2.gif +0 -0
  95. data/spec/html/images/3.gif +0 -0
  96. data/spec/html/images/button.jpg +0 -0
  97. data/spec/html/images/circle.jpg +0 -0
  98. data/spec/html/images/map.gif +0 -0
  99. data/spec/html/images/map2.gif +0 -0
  100. data/spec/html/images/minus.gif +0 -0
  101. data/spec/html/images/originaltriangle.jpg +0 -0
  102. data/spec/html/images/plus.gif +0 -0
  103. data/spec/html/images/square.jpg +0 -0
  104. data/spec/html/images/triangle.jpg +0 -0
  105. data/spec/html/invalid_js.html +0 -11
  106. data/spec/html/latin1_text.html +0 -17
  107. data/spec/html/non_control_elements.html +0 -115
  108. data/spec/html/simple_ajax.html +0 -22
  109. data/spec/html/tables.html +0 -119
  110. data/spec/html/utf8_text.html +0 -15
  111. data/spec/htmlunit_spec.rb +0 -26
  112. data/spec/image_spec.rb +0 -220
  113. data/spec/images_spec.rb +0 -39
  114. data/spec/label_spec.rb +0 -79
  115. data/spec/labels_spec.rb +0 -40
  116. data/spec/li_spec.rb +0 -139
  117. data/spec/link_spec.rb +0 -189
  118. data/spec/links_spec.rb +0 -43
  119. data/spec/lis_spec.rb +0 -40
  120. data/spec/map_spec.rb +0 -102
  121. data/spec/maps_spec.rb +0 -40
  122. data/spec/meta_spec.rb +0 -8
  123. data/spec/ol_spec.rb +0 -87
  124. data/spec/ols_spec.rb +0 -40
  125. data/spec/option_spec.rb +0 -154
  126. data/spec/p_spec.rb +0 -171
  127. data/spec/pre_spec.rb +0 -135
  128. data/spec/pres_spec.rb +0 -40
  129. data/spec/ps_spec.rb +0 -40
  130. data/spec/radio_spec.rb +0 -299
  131. data/spec/radios_spec.rb +0 -42
  132. data/spec/select_list_spec.rb +0 -299
  133. data/spec/select_lists_spec.rb +0 -47
  134. data/spec/span_spec.rb +0 -184
  135. data/spec/spans_spec.rb +0 -64
  136. data/spec/spec.opts +0 -1
  137. data/spec/spec_helper.rb +0 -55
  138. data/spec/table_bodies_spec.rb +0 -57
  139. data/spec/table_body_spec.rb +0 -111
  140. data/spec/table_cell_spec.rb +0 -74
  141. data/spec/table_cells_spec.rb +0 -59
  142. data/spec/table_footer_spec.rb +0 -101
  143. data/spec/table_footers_spec.rb +0 -55
  144. data/spec/table_header_spec.rb +0 -101
  145. data/spec/table_headers_spec.rb +0 -55
  146. data/spec/table_row_spec.rb +0 -104
  147. data/spec/table_rows_spec.rb +0 -58
  148. data/spec/table_spec.rb +0 -160
  149. data/spec/tables_spec.rb +0 -42
  150. data/spec/text_field_spec.rb +0 -323
  151. data/spec/text_fields_spec.rb +0 -44
  152. data/spec/ul_spec.rb +0 -88
  153. data/spec/uls_spec.rb +0 -40
  154. data/spec/watir_compatibility_spec.rb +0 -260
  155. data/support/spec_server.rb +0 -73
  156. data/tasks/rspec.rake +0 -30
  157. data/tasks/specserver.rake +0 -21
  158. metadata.gz.sig +0 -0
@@ -1,55 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "TableFooters" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- before :each do
10
- @browser = Browser.new
11
- @browser.goto(TEST_HOST + "/tables.html")
12
- end
13
-
14
- describe "#length" do
15
- it "should return the correct number of table tfoots (page context)" do
16
- @browser.tfoots.length.should == 1
17
- end
18
-
19
- it "should return the correct number of table tfoots (table context)" do
20
- @browser.table(:index, 1).tfoots.length.should == 1
21
- end
22
- end
23
-
24
- describe "#[]" do
25
- it "should return the row at the given index (page context)" do
26
- @browser.tfoots[1].id.should == "tax_totals"
27
- end
28
-
29
- it "should return the row at the given index (table context)" do
30
- @browser.table(:index, 1).tfoots[1].id.should == "tax_totals"
31
- end
32
- end
33
-
34
- describe "#each" do
35
- it "should iterate through table tfoots correctly (page context)" do
36
- @browser.tfoots.each_with_index do |tfoot, index|
37
- tfoot.name.should == @browser.tfoot(:index, index+1).name
38
- tfoot.id.should == @browser.tfoot(:index, index+1).id
39
- end
40
- end
41
-
42
- it "should iterate through table tfoots correctly (table context)" do
43
- table = @browser.table(:index, 1)
44
- table.tfoots.each_with_index do |tfoot, index|
45
- tfoot.name.should == table.tfoot(:index, index+1).name
46
- tfoot.id.should == table.tfoot(:index, index+1).id
47
- end
48
- end
49
- end
50
-
51
- after :all do
52
- @browser.close
53
- end
54
-
55
- end
@@ -1,101 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "TableHeader" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- before :each do
10
- @browser = Browser.new
11
- @browser.goto(TEST_HOST + "/tables.html")
12
- end
13
-
14
- describe "#exists" do
15
- it "should return true if the table theader exists (page context)" do
16
- @browser.thead(:id, 'tax_headers').should exist
17
- @browser.thead(:id, /tax_headers/).should exist
18
- @browser.thead(:index, 1).should exist
19
- @browser.thead(:xpath, "//thead[@id='tax_headers']").should exist
20
- end
21
-
22
- it "should return true if the table theader exists (table context)" do
23
- @browser.table(:index, 1).thead(:id, 'tax_headers').should exist
24
- @browser.table(:index, 1).thead(:id, /tax_headers/).should exist
25
- @browser.table(:index, 1).thead(:index, 1).should exist
26
- @browser.table(:index, 1).thead(:xpath, "//thead[@id='tax_headers']").should exist
27
- end
28
-
29
- it "should return true if the element exists (default how = :id)" do
30
- @browser.thead("tax_headers").should exist
31
- @browser.table(:index, 1).thead("tax_headers").should exist
32
- end
33
-
34
- it "should return false if the table theader exists (page context)" do
35
- @browser.thead(:id, 'no_such_id').should_not exist
36
- @browser.thead(:id, /no_such_id/).should_not exist
37
- @browser.thead(:index, 1337).should_not exist
38
- @browser.thead(:xpath, "//thead[@id='no_such_id']").should_not exist
39
- end
40
-
41
- it "should return false if the table theader exists (table context)" do
42
- @browser.table(:index, 1).thead(:id, 'no_such_id').should_not exist
43
- @browser.table(:index, 1).thead(:id, /no_such_id/).should_not exist
44
- @browser.table(:index, 1).thead(:index, 1337).should_not exist
45
- @browser.table(:index, 1).thead(:xpath, "//thead[@id='no_such_id']").should_not exist
46
- end
47
-
48
- it "should raise ArgumentError when 'what' argument is invalid" do
49
- lambda { @browser.thead(:id, 3.14).exists? }.should raise_error(ArgumentError)
50
- lambda { @browser.table(:index, 1).thead(:id, 3.14).exists? }.should raise_error(ArgumentError)
51
- end
52
-
53
- it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
54
- lambda { @browser.thead(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
55
- lambda { @browser.table(:index, 1).thead(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
56
- end
57
- end
58
-
59
- describe "#length" do
60
- it "should return the correct number of table bodies (page context)" do
61
- @browser.thead(:id, 'tax_headers').length.should == 1
62
- end
63
-
64
- it "should return the correct number of table bodies (table context)" do
65
- @browser.table(:index, 1).thead(:id, 'tax_headers').length.should == 1
66
- end
67
- end
68
-
69
- describe "#[]" do
70
- it "should return the row at the given index (page context)" do
71
- @browser.thead(:id, 'tax_headers')[1].text.should == 'Before income tax Income tax After income tax'
72
- @browser.thead(:id, 'tax_headers')[1][2].text.should == 'Before income tax'
73
- @browser.thead(:id, 'tax_headers')[1][3].text.should == 'Income tax'
74
- end
75
-
76
- it "should return the row at the given index (table context)" do
77
- @browser.table(:index, 1).thead(:id, 'tax_headers')[1].text.should == 'Before income tax Income tax After income tax'
78
- @browser.table(:index, 1).thead(:id, 'tax_headers')[1][2].text.should == 'Before income tax'
79
- @browser.table(:index, 1).thead(:id, 'tax_headers')[1][3].text.should == 'Income tax'
80
- end
81
- end
82
-
83
- describe "#each" do
84
- it "should iterate through rows correctly" do
85
- theader = @browser.table(:index, 1).thead(:id, 'tax_headers')
86
- index = 1
87
- theader.each do |r|
88
- r.name.should == @browser.row(:index, index).name
89
- r.id.should == @browser.row(:index, index).id
90
- r.value.should == @browser.row(:index, index).value
91
- index += 1
92
- end
93
- index.should_not == 1
94
- end
95
- end
96
-
97
- after :all do
98
- @browser.close
99
- end
100
-
101
- end
@@ -1,55 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "TableHeaders" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- before :each do
10
- @browser = Browser.new
11
- @browser.goto(TEST_HOST + "/tables.html")
12
- end
13
-
14
- describe "#length" do
15
- it "should return the correct number of table theads (page context)" do
16
- @browser.theads.length.should == 1
17
- end
18
-
19
- it "should return the correct number of table theads (table context)" do
20
- @browser.table(:index, 1).theads.length.should == 1
21
- end
22
- end
23
-
24
- describe "#[]" do
25
- it "should return the row at the given index (page context)" do
26
- @browser.theads[1].id.should == "tax_headers"
27
- end
28
-
29
- it "should return the row at the given index (table context)" do
30
- @browser.table(:index, 1).theads[1].id.should == "tax_headers"
31
- end
32
- end
33
-
34
- describe "#each" do
35
- it "should iterate through table theads correctly (page context)" do
36
- @browser.theads.each_with_index do |thead, index|
37
- thead.name.should == @browser.thead(:index, index+1).name
38
- thead.id.should == @browser.thead(:index, index+1).id
39
- end
40
- end
41
-
42
- it "should iterate through table theads correctly (table context)" do
43
- table = @browser.table(:index, 1)
44
- table.theads.each_with_index do |thead, index|
45
- thead.name.should == table.thead(:index, index+1).name
46
- thead.id.should == table.thead(:index, index+1).id
47
- end
48
- end
49
- end
50
-
51
- after :all do
52
- @browser.close
53
- end
54
-
55
- end
@@ -1,104 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "TableRow" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- before :each do
10
- @browser = Browser.new
11
- @browser.goto(TEST_HOST + "/tables.html")
12
- end
13
-
14
- describe "#exists?" do
15
- it "should return true if the table row exists" do
16
- @browser.row(:id, "outer_first").should exist
17
- @browser.row(:id, /outer_first/).should exist
18
- @browser.row(:index, 1).should exist
19
- @browser.row(:xpath, "//tr[@id='outer_first']")
20
- end
21
-
22
- it "should return true if the element exists (default how = :id)" do
23
- @browser.row("outer_last").should exist
24
- end
25
-
26
- it "should return false if the table row exists" do
27
- @browser.row(:id, "no_such_id").should_not exist
28
- @browser.row(:id, /no_such_id/).should_not exist
29
- @browser.row(:index, 1337).should_not exist
30
- @browser.row(:xpath, "//tr[@id='no_such_id']")
31
- end
32
-
33
- it "should raise ArgumentError when 'what' argument is invalid" do
34
- lambda { @browser.row(:id, 3.14).exists? }.should raise_error(ArgumentError)
35
- end
36
-
37
- it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
38
- lambda { @browser.row(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
39
- end
40
- end
41
-
42
- describe "#column_count" do
43
- it "should return the number of columns (cells) in the row" do
44
- @browser.table(:id, 'outer').rows[1].column_count.should == 2
45
- @browser.table(:id, 'outer')[2].column_count.should == 2
46
- @browser.table(:id, 'colspan')[1].column_count.should == 1
47
- @browser.table(:id, 'colspan').rows[2].column_count.should == 2
48
- @browser.rows[1].column_count.should == 4
49
- end
50
- end
51
-
52
- describe "#length" do
53
- it "should return the number of rows" do
54
- @browser.table(:id, 'outer').rows.length.should == 3
55
- @browser.table(:id, 'inner').rows.length.should == 1
56
- end
57
- end
58
-
59
- describe "#[]" do
60
- it "should return the nth cell of the parent row" do
61
- @browser.table(:id, 'outer').row(:index, 1)[1].text.should == "Table 1, Row 1, Cell 1"
62
- @browser.table(:id, 'outer')[1][1].text.should == "Table 1, Row 1, Cell 1"
63
- @browser.table(:id, 'outer')[3][1].text.should == "Table 1, Row 3, Cell 1"
64
- end
65
-
66
- it "should raise UnknownCellException if the index is out of bounds" do
67
- lambda { @browser.table(:id, 'outer').row(:index, 1)[1337] }.should raise_error(UnknownCellException)
68
- lambda { @browser.table(:id, 'outer')[1][1337] }.should raise_error(UnknownCellException)
69
- end
70
- end
71
-
72
- describe "#child_cell" do
73
- it "should return the nth cell of the parent row" do
74
- @browser.table(:id, 'outer').row(:index, 1).child_cell(1).text.should == "Table 1, Row 1, Cell 1"
75
- @browser.table(:id, 'outer')[1].child_cell(1).text.should == "Table 1, Row 1, Cell 1"
76
- @browser.table(:id, 'outer')[3].child_cell(1).text.should == "Table 1, Row 3, Cell 1"
77
- end
78
-
79
- it "should raise UnknownCellException if the index is out of bounds" do
80
- lambda { @browser.table(:id, 'outer').row(:index, 1).child_cell(1337) }.should raise_error(UnknownCellException)
81
- lambda { @browser.table(:id, 'outer')[1].child_cell(1337) }.should raise_error(UnknownCellException)
82
- end
83
- end
84
-
85
- describe "#each" do
86
- it "should iterate correctly through the cells of the row" do
87
- index = 1
88
- @browser.table(:id, 'outer')[2].each do |c|
89
- case index
90
- when 1
91
- c.text.should == "Table 1, Row 2, Cell 1"
92
- when 2
93
- c.text.should == "Table 1, Row 2, Cell 2 Table 2, Row 1, Cell 1 Table 2, Row 1, Cell 2"
94
- end
95
- index += 1
96
- end
97
- end
98
- end
99
-
100
- after :all do
101
- @browser.close
102
- end
103
-
104
- end
@@ -1,58 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "TableRows" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- before :each do
10
- @browser = Browser.new
11
- @browser.goto(TEST_HOST + "/tables.html")
12
- end
13
-
14
- describe "#length" do
15
- it "should return the correct number of cells (table context)" do
16
- @browser.table(:id, 'inner').rows.length.should == 1
17
- @browser.table(:id, 'outer').rows.length.should == 3
18
- end
19
-
20
- it "should return the correct number of cells (page context)" do
21
- @browser.rows.length.should == 14
22
- end
23
- end
24
-
25
- describe "#[]" do
26
- it "should return the row at the given index (table context)" do
27
- @browser.table(:id, 'outer').rows[1].text.should == "Table 1, Row 1, Cell 1 Table 1, Row 1, Cell 2"
28
- end
29
-
30
- it "should return the row at the given index (page context)" do
31
- @browser.rows[1].text.should == "Before income tax Income tax After income tax"
32
- end
33
- end
34
-
35
- describe "#each" do
36
- it "should iterate through rows correctly" do
37
- # rows inside a table
38
- inner_table = @browser.table(:id, 'inner')
39
- inner_table.rows.each_with_index do |r, index|
40
- r.name.should == inner_table.row(:index, index+1).name
41
- r.id.should == inner_table.row(:index, index+1).id
42
- r.value.should == inner_table.row(:index, index+1).value
43
- end
44
- # rows inside a table (should not include rows inside a table inside a table)
45
- outer_table = @browser.table(:id, 'outer')
46
- outer_table.rows.each_with_index do |r, index|
47
- r.name.should == outer_table.row(:index, index+1).name
48
- r.id.should == outer_table.row(:index, index+1).id
49
- r.value.should == outer_table.row(:index, index+1).value
50
- end
51
- end
52
- end
53
-
54
- after :all do
55
- @browser.close
56
- end
57
-
58
- end
data/spec/table_spec.rb DELETED
@@ -1,160 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
-
3
- describe "Table" do
4
-
5
- before :all do
6
- @browser = Browser.new
7
- end
8
-
9
- before :each do
10
- @browser = Browser.new
11
- @browser.goto(TEST_HOST + "/tables.html")
12
- end
13
-
14
- # Exists
15
- describe "#exists?" do
16
- it "should return true if the table exists" do
17
- @browser.table(:id, 'axis_example').should exist
18
- @browser.table(:id, /axis_example/).should exist
19
- @browser.table(:index, 1).should exist
20
- @browser.table(:xpath, "//table[@id='axis_example']").should exist
21
- end
22
-
23
- it "should return true if the element exists (default how = :id)" do
24
- @browser.table("axis_example").should exist
25
- end
26
-
27
- it "should return false if the table does not exist" do
28
- @browser.table(:id, 'no_such_id').should_not exist
29
- @browser.table(:id, /no_such_id/).should_not exist
30
- @browser.table(:index, 1337).should_not exist
31
- @browser.table(:xpath, "//table[@id='no_such_id']").should_not exist
32
- end
33
-
34
- it "should raise ArgumentError when 'what' argument is invalid" do
35
- lambda { @browser.table(:id, 3.14).exists? }.should raise_error(ArgumentError)
36
- end
37
-
38
- it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
39
- lambda { @browser.table(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
40
- end
41
- end
42
-
43
- # Other
44
- describe "#to_a" do
45
- it "should return a two-dimensional array representation of the table" do
46
- @browser.table(:id, 'inner').to_a.should == [["Table 2, Row 1, Cell 1", "Table 2, Row 1, Cell 2"]]
47
- end
48
- end
49
-
50
- describe "#row_count" do
51
- it "should count the number of rows correctly" do
52
- @browser.table(:id, 'inner').row_count.should == 1
53
- @browser.table(:id, 'outer').row_count.should == 3
54
- end
55
-
56
- it "should raise an UnknownObjectException if the table doesn't exist" do
57
- lambda { @browser.table(:id, 'no_such_id').row_count }.should raise_error(UnknownObjectException)
58
- lambda { @browser.table(:index, 1337).row_count }.should raise_error(UnknownObjectException)
59
- end
60
- end
61
-
62
- describe "#row_values" do
63
- it "should get row values" do
64
- @browser.table(:id, 'outer').row_values(1).should == ["Table 1, Row 1, Cell 1", "Table 1, Row 1, Cell 2"]
65
- @browser.table(:id, 'inner').row_values(1).should == ["Table 2, Row 1, Cell 1", "Table 2, Row 1, Cell 2"]
66
- @browser.table(:id, 'outer').row_values(3).should == ["Table 1, Row 3, Cell 1", "Table 1, Row 3, Cell 2"]
67
- end
68
- end
69
-
70
- describe "#column_count" do
71
- it "should count the number of columns correctly" do
72
- @browser.table(:id, 'inner').column_count.should == 2
73
- @browser.table(:id, 'outer').column_count.should == 2
74
- end
75
-
76
- it "should raise an UnknownObjectException if the table doesn't exist" do
77
- lambda { @browser.table(:id, 'no_such_id').column_count }.should raise_error(UnknownObjectException)
78
- lambda { @browser.table(:index, 1337).column_count }.should raise_error(UnknownObjectException)
79
- end
80
- end
81
-
82
- describe "#column_values" do
83
- it "should get column values" do
84
- @browser.table(:id, 'inner').column_values(1).should == ["Table 2, Row 1, Cell 1"]
85
- @browser.table(:id, 'outer').column_values(1).should == ["Table 1, Row 1, Cell 1", "Table 1, Row 2, Cell 1", "Table 1, Row 3, Cell 1"]
86
- end
87
-
88
- it "should raise UnknownCellException when trying to locate non-existing cell" do
89
- lambda { @browser.table(:id, 'inner').column_values(1337) }.should raise_error(UnknownCellException)
90
- end
91
- end
92
-
93
- describe "#[]" do
94
- it "should return the nth child row" do
95
- @browser.table(:id, 'outer')[1].id.should == "outer_first"
96
- @browser.table(:id, 'inner')[1].id.should == "inner_first"
97
- @browser.table(:id, 'outer')[3].id.should == "outer_last"
98
- end
99
- it "should raise UnknownRowException if the index is out of bounds" do
100
- lambda { @browser.table(:id, 'outer')[1337] }.should raise_error(UnknownRowException)
101
- end
102
- end
103
-
104
- describe "#child_row" do
105
- it "should return the nth child row" do
106
- @browser.table(:id, 'outer').child_row(1).id.should == "outer_first"
107
- @browser.table(:id, 'inner').child_row(1).id.should == "inner_first"
108
- @browser.table(:id, 'outer').child_row(3).id.should == "outer_last"
109
- end
110
- it "should raise UnknownRowException if the index is out of bounds" do
111
- lambda { @browser.table(:id, 'outer').child_row(1337) }.should raise_error(UnknownRowException)
112
- end
113
- end
114
-
115
- describe "#child_cell" do
116
- it "should return the nth child row" do
117
- @browser.table(:id, 'outer').child_cell(5).text.should == "Table 1, Row 3, Cell 1"
118
- end
119
- it "should raise UnknownCellException if the index is out of bounds" do
120
- lambda { @browser.table(:id, 'outer').child_cell(1337) }.should raise_error(UnknownCellException)
121
- end
122
- end
123
-
124
- describe "#each" do
125
- it "should iterate through the table's rows" do
126
- index = 1
127
- @browser.table(:id, 'outer').each do |r|
128
- case index
129
- when 1
130
- r.text.should == "Table 1, Row 1, Cell 1 Table 1, Row 1, Cell 2"
131
- when 3
132
- r.text.should == "Table 1, Row 3, Cell 1 Table 1, Row 3, Cell 2"
133
- end
134
- index += 1
135
- end
136
- end
137
- end
138
-
139
- describe "#body" do
140
- it "should return the correct instance of TableBody" do
141
- body = @browser.table(:index, 1).body(:id, 'first')
142
- body.should be_instance_of(TableBody)
143
- body[1][1].text.should == "March 2008"
144
- end
145
- end
146
-
147
- describe "#bodies" do
148
- it "should return the correct instance of TableBodies" do
149
- bodies = @browser.table(:index, 1).bodies
150
- bodies.should be_instance_of(TableBodies)
151
- bodies[1].id.should == "first"
152
- bodies[2].id.should == "second"
153
- end
154
- end
155
-
156
- after :all do
157
- @browser.close
158
- end
159
-
160
- end