operawatir 0.3-jruby

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 (171) hide show
  1. data/.gitmodules +3 -0
  2. data/.yardopts +5 -0
  3. data/AUTHORS +7 -0
  4. data/Gemfile +9 -0
  5. data/LICENSE +30 -0
  6. data/README.md +158 -0
  7. data/Rakefile +59 -0
  8. data/VERSION +1 -0
  9. data/bin/desktopwatir +106 -0
  10. data/bin/operawatir +95 -0
  11. data/lib/operadriver/APACHE_2.0_LICENSE.txt +204 -0
  12. data/lib/operadriver/NEW_BSD_LICENSE.txt +36 -0
  13. data/lib/operadriver/commons-jxpath-1.3.jar +0 -0
  14. data/lib/operadriver/protobuf-java-2.3.0.jar +0 -0
  15. data/lib/operadriver/selenium-common.jar +0 -0
  16. data/lib/operadriver/webdriver-opera.jar +0 -0
  17. data/lib/operawatir.rb +46 -0
  18. data/lib/operawatir/browser.rb +181 -0
  19. data/lib/operawatir/collection.rb +133 -0
  20. data/lib/operawatir/compat.rb +25 -0
  21. data/lib/operawatir/compat/browser.rb +20 -0
  22. data/lib/operawatir/compat/collection.rb +99 -0
  23. data/lib/operawatir/compat/deprecation.rb +46 -0
  24. data/lib/operawatir/compat/element.rb +165 -0
  25. data/lib/operawatir/compat/element_finders.rb +159 -0
  26. data/lib/operawatir/compat/window.rb +27 -0
  27. data/lib/operawatir/element.rb +228 -0
  28. data/lib/operawatir/exceptions.rb +38 -0
  29. data/lib/operawatir/helper.rb +53 -0
  30. data/lib/operawatir/selector.rb +111 -0
  31. data/lib/operawatir/version.rb +15 -0
  32. data/lib/operawatir/window.rb +174 -0
  33. data/spec/fire_event/fire_event.rb +268 -0
  34. data/spec/fire_event/interactive/onBlur.html +45 -0
  35. data/spec/fire_event/interactive/onChange.html +47 -0
  36. data/spec/fire_event/interactive/onClick.html +45 -0
  37. data/spec/fire_event/interactive/onDblClick.html +45 -0
  38. data/spec/fire_event/interactive/onFocus.html +45 -0
  39. data/spec/fire_event/interactive/onMouseDown.html +45 -0
  40. data/spec/fire_event/interactive/onMouseMove.html +45 -0
  41. data/spec/fire_event/interactive/onMouseOut.html +45 -0
  42. data/spec/fire_event/interactive/onMouseOver.html +45 -0
  43. data/spec/fire_event/interactive/onMouseUp.html +45 -0
  44. data/spec/fire_event/interactive/onScroll.html +14 -0
  45. data/spec/legacy_watirspec/area_spec.rb +106 -0
  46. data/spec/legacy_watirspec/areas_spec.rb +38 -0
  47. data/spec/legacy_watirspec/browser_spec.rb +297 -0
  48. data/spec/legacy_watirspec/button_spec.rb +260 -0
  49. data/spec/legacy_watirspec/buttons_spec.rb +54 -0
  50. data/spec/legacy_watirspec/checkbox_spec.rb +280 -0
  51. data/spec/legacy_watirspec/checkboxes_spec.rb +38 -0
  52. data/spec/legacy_watirspec/collections_spec.rb +18 -0
  53. data/spec/legacy_watirspec/dd_spec.rb +140 -0
  54. data/spec/legacy_watirspec/dds_spec.rb +38 -0
  55. data/spec/legacy_watirspec/del_spec.rb +181 -0
  56. data/spec/legacy_watirspec/dels_spec.rb +62 -0
  57. data/spec/legacy_watirspec/div_spec.rb +244 -0
  58. data/spec/legacy_watirspec/divs_spec.rb +38 -0
  59. data/spec/legacy_watirspec/dl_spec.rb +140 -0
  60. data/spec/legacy_watirspec/dls_spec.rb +38 -0
  61. data/spec/legacy_watirspec/dt_spec.rb +140 -0
  62. data/spec/legacy_watirspec/dts_spec.rb +38 -0
  63. data/spec/legacy_watirspec/element_spec.rb +86 -0
  64. data/spec/legacy_watirspec/em_spec.rb +114 -0
  65. data/spec/legacy_watirspec/ems_spec.rb +38 -0
  66. data/spec/legacy_watirspec/filefield_spec.rb +127 -0
  67. data/spec/legacy_watirspec/filefields_spec.rb +38 -0
  68. data/spec/legacy_watirspec/fixtures/2000_spans.html +2009 -0
  69. data/spec/legacy_watirspec/fixtures/bug_duplicate_attributes.html +14 -0
  70. data/spec/legacy_watirspec/fixtures/bug_javascript_001.html +11 -0
  71. data/spec/legacy_watirspec/fixtures/buttons_with_duplicate_ids.html +18 -0
  72. data/spec/legacy_watirspec/fixtures/collections.html +15 -0
  73. data/spec/legacy_watirspec/fixtures/definition_lists.html +48 -0
  74. data/spec/legacy_watirspec/fixtures/euc-jp_text.html +17 -0
  75. data/spec/legacy_watirspec/fixtures/forms_with_input_elements.html +126 -0
  76. data/spec/legacy_watirspec/fixtures/frame_1.html +18 -0
  77. data/spec/legacy_watirspec/fixtures/frame_2.html +16 -0
  78. data/spec/legacy_watirspec/fixtures/frames.html +11 -0
  79. data/spec/legacy_watirspec/fixtures/iframes.html +12 -0
  80. data/spec/legacy_watirspec/fixtures/images.html +27 -0
  81. data/spec/legacy_watirspec/fixtures/images/1.gif +0 -0
  82. data/spec/legacy_watirspec/fixtures/images/2.gif +0 -0
  83. data/spec/legacy_watirspec/fixtures/images/3.gif +0 -0
  84. data/spec/legacy_watirspec/fixtures/images/button.jpg +0 -0
  85. data/spec/legacy_watirspec/fixtures/images/circle.jpg +0 -0
  86. data/spec/legacy_watirspec/fixtures/images/map.gif +0 -0
  87. data/spec/legacy_watirspec/fixtures/images/map2.gif +0 -0
  88. data/spec/legacy_watirspec/fixtures/images/minus.gif +0 -0
  89. data/spec/legacy_watirspec/fixtures/images/originaltriangle.jpg +0 -0
  90. data/spec/legacy_watirspec/fixtures/images/plus.gif +0 -0
  91. data/spec/legacy_watirspec/fixtures/images/square.jpg +0 -0
  92. data/spec/legacy_watirspec/fixtures/images/triangle.jpg +0 -0
  93. data/spec/legacy_watirspec/fixtures/iso-2022-jp_text.html +17 -0
  94. data/spec/legacy_watirspec/fixtures/javascript/helpers.js +16 -0
  95. data/spec/legacy_watirspec/fixtures/jquery.html +28 -0
  96. data/spec/legacy_watirspec/fixtures/latin1_text.html +17 -0
  97. data/spec/legacy_watirspec/fixtures/multiple_ids.html +14 -0
  98. data/spec/legacy_watirspec/fixtures/non_control_elements.html +135 -0
  99. data/spec/legacy_watirspec/fixtures/parser_bug_001.html +12 -0
  100. data/spec/legacy_watirspec/fixtures/prevent_form_submit.html +20 -0
  101. data/spec/legacy_watirspec/fixtures/right_click.html +11 -0
  102. data/spec/legacy_watirspec/fixtures/shift_jis_text.html +17 -0
  103. data/spec/legacy_watirspec/fixtures/tables.html +121 -0
  104. data/spec/legacy_watirspec/fixtures/timeout.html +16 -0
  105. data/spec/legacy_watirspec/fixtures/timeout_window_location.html +19 -0
  106. data/spec/legacy_watirspec/fixtures/tiny_mce.html +27 -0
  107. data/spec/legacy_watirspec/fixtures/utf8_text.html +15 -0
  108. data/spec/legacy_watirspec/fixtures/watirspec.css +0 -0
  109. data/spec/legacy_watirspec/form_spec.rb +73 -0
  110. data/spec/legacy_watirspec/forms_spec.rb +39 -0
  111. data/spec/legacy_watirspec/frame_spec.rb +161 -0
  112. data/spec/legacy_watirspec/frames_spec.rb +75 -0
  113. data/spec/legacy_watirspec/guards.rb +38 -0
  114. data/spec/legacy_watirspec/hidden_spec.rb +120 -0
  115. data/spec/legacy_watirspec/hiddens_spec.rb +38 -0
  116. data/spec/legacy_watirspec/hn_spec.rb +101 -0
  117. data/spec/legacy_watirspec/hns_spec.rb +39 -0
  118. data/spec/legacy_watirspec/image_spec.rb +237 -0
  119. data/spec/legacy_watirspec/images_spec.rb +38 -0
  120. data/spec/legacy_watirspec/ins_spec.rb +181 -0
  121. data/spec/legacy_watirspec/inses_spec.rb +62 -0
  122. data/spec/legacy_watirspec/label_spec.rb +85 -0
  123. data/spec/legacy_watirspec/labels_spec.rb +38 -0
  124. data/spec/legacy_watirspec/li_spec.rb +135 -0
  125. data/spec/legacy_watirspec/link_spec.rb +194 -0
  126. data/spec/legacy_watirspec/links_spec.rb +39 -0
  127. data/spec/legacy_watirspec/lis_spec.rb +38 -0
  128. data/spec/legacy_watirspec/map_spec.rb +100 -0
  129. data/spec/legacy_watirspec/maps_spec.rb +38 -0
  130. data/spec/legacy_watirspec/meta_spec.rb +26 -0
  131. data/spec/legacy_watirspec/metas_spec.rb +36 -0
  132. data/spec/legacy_watirspec/ol_spec.rb +86 -0
  133. data/spec/legacy_watirspec/ols_spec.rb +38 -0
  134. data/spec/legacy_watirspec/option_spec.rb +187 -0
  135. data/spec/legacy_watirspec/p_spec.rb +167 -0
  136. data/spec/legacy_watirspec/pre_spec.rb +133 -0
  137. data/spec/legacy_watirspec/pres_spec.rb +38 -0
  138. data/spec/legacy_watirspec/ps_spec.rb +38 -0
  139. data/spec/legacy_watirspec/radio_spec.rb +286 -0
  140. data/spec/legacy_watirspec/radios_spec.rb +35 -0
  141. data/spec/legacy_watirspec/select_list_spec.rb +326 -0
  142. data/spec/legacy_watirspec/select_lists_spec.rb +39 -0
  143. data/spec/legacy_watirspec/server.rb +91 -0
  144. data/spec/legacy_watirspec/span_spec.rb +181 -0
  145. data/spec/legacy_watirspec/spans_spec.rb +64 -0
  146. data/spec/legacy_watirspec/spec_helper.rb +12 -0
  147. data/spec/legacy_watirspec/strong_spec.rb +97 -0
  148. data/spec/legacy_watirspec/strongs_spec.rb +39 -0
  149. data/spec/legacy_watirspec/table_bodies_spec.rb +61 -0
  150. data/spec/legacy_watirspec/table_body_spec.rb +119 -0
  151. data/spec/legacy_watirspec/table_cell_spec.rb +76 -0
  152. data/spec/legacy_watirspec/table_cells_spec.rb +71 -0
  153. data/spec/legacy_watirspec/table_footer_spec.rb +94 -0
  154. data/spec/legacy_watirspec/table_footers_spec.rb +61 -0
  155. data/spec/legacy_watirspec/table_header_spec.rb +98 -0
  156. data/spec/legacy_watirspec/table_headers_spec.rb +59 -0
  157. data/spec/legacy_watirspec/table_row_spec.rb +104 -0
  158. data/spec/legacy_watirspec/table_rows_spec.rb +64 -0
  159. data/spec/legacy_watirspec/table_spec.rb +170 -0
  160. data/spec/legacy_watirspec/tables_spec.rb +40 -0
  161. data/spec/legacy_watirspec/text_field_spec.rb +315 -0
  162. data/spec/legacy_watirspec/text_fields_spec.rb +38 -0
  163. data/spec/legacy_watirspec/ul_spec.rb +84 -0
  164. data/spec/legacy_watirspec/uls_spec.rb +40 -0
  165. data/spec/legacy_watirspec/watir_compatibility_spec.rb +176 -0
  166. data/spec/legacy_watirspec/watirspec_helper.rb +57 -0
  167. data/utils/Rakefile +79 -0
  168. data/utils/launchers/launcher-linux-i686 +0 -0
  169. data/utils/launchers/launcher-linux-x86_64 +0 -0
  170. data/utils/launchers/launcher-win32-i86pc.exe +0 -0
  171. metadata +404 -0
@@ -0,0 +1,119 @@
1
+ # encoding: utf-8
2
+ require File.expand_path("../spec_helper", __FILE__)
3
+
4
+ describe "TableBody" do
5
+
6
+ before :each do
7
+ browser.goto(WatirSpec.files + "/tables.html")
8
+ end
9
+
10
+ describe "#exists?" do
11
+ bug "WTR-357", :watir do
12
+ it "returns true if the table body exists (page context)" do
13
+ browser.body(:id, 'first').should exist
14
+ browser.body(:id, /first/).should exist
15
+ browser.body(:name, 'second').should exist
16
+ browser.body(:name, /second/).should exist
17
+ browser.body(:index, 1).should exist
18
+ browser.body(:xpath, "//tbody[@id='first']").should exist
19
+ end
20
+ end
21
+
22
+ it "returns true if the table body exists (table context)" do
23
+ browser.table(:index, 1).body(:id, 'first').should exist
24
+ browser.table(:index, 1).body(:id, /first/).should exist
25
+ browser.table(:index, 1).body(:name, 'second').should exist
26
+ browser.table(:index, 1).body(:name, /second/).should exist
27
+ browser.table(:index, 1).body(:index, 1).should exist
28
+ browser.table(:index, 1).body(:xpath, "//tbody[@id='first']").should exist
29
+ end
30
+
31
+ it "returns the first table body if given no args" do
32
+ browser.table.body.should exist
33
+ end
34
+
35
+ it "returns true if the element exists (default how = :id)" do
36
+ bug "WTR-357", :watir do
37
+ browser.body("first").should exist
38
+ end
39
+ browser.table(:index, 1).body("first").should exist
40
+ end
41
+
42
+ bug "WTR-357", :watir do
43
+ it "returns false if the table body doesn't exist (page context)" do
44
+ browser.body(:id, 'no_such_id').should_not exist
45
+ browser.body(:id, /no_such_id/).should_not exist
46
+ browser.body(:name, 'no_such_name').should_not exist
47
+ browser.body(:name, /no_such_name/).should_not exist
48
+ browser.body(:index, 1337).should_not exist
49
+ browser.body(:xpath, "//tbody[@id='no_such_id']").should_not exist
50
+ end
51
+ end
52
+
53
+ it "returns false if the table body doesn't exist (table context)" do
54
+ browser.table(:index, 1).body(:id, 'no_such_id').should_not exist
55
+ browser.table(:index, 1).body(:id, /no_such_id/).should_not exist
56
+ browser.table(:index, 1).body(:name, 'no_such_name').should_not exist
57
+ browser.table(:index, 1).body(:name, /no_such_name/).should_not exist
58
+ browser.table(:index, 1).body(:index, 1337).should_not exist
59
+ browser.table(:index, 1).body(:xpath, "//tbody[@id='no_such_id']").should_not exist
60
+ end
61
+
62
+ it "raises TypeError when 'what' argument is invalid" do
63
+ bug "WTR-357", :watir do
64
+ lambda { browser.body(:id, 3.14).exists? }.should raise_error(TypeError)
65
+ end
66
+ lambda { browser.table(:index, 1).body(:id, 3.14).exists? }.should raise_error(TypeError)
67
+ end
68
+
69
+ it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
70
+ bug "WTR-357", :watir do
71
+ lambda { browser.body(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
72
+ end
73
+ lambda { browser.table(:index, 1).body(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
74
+ end
75
+ end
76
+
77
+ describe "#length" do
78
+ bug "WTR-357", :watir do
79
+ it "returns the correct number of table bodies (page context)" do
80
+ browser.body(:id, 'first').length.should == 3
81
+ browser.body(:name, 'second').length.should == 3
82
+ end
83
+ end
84
+
85
+ it "returns the correct number of table bodies (table context)" do
86
+ browser.table(:index, 1).body(:id, 'first').length.should == 3
87
+ browser.table(:index, 1).body(:name, 'second').length.should == 3
88
+ end
89
+ end
90
+
91
+ describe "#[]" do
92
+ bug "WTR-357", :watir do
93
+ it "returns the row at the given index (page context)" do
94
+ browser.body(:id, 'first')[1].text.should == 'March 2008'
95
+ browser.body(:id, 'first')[2][1].text.should == 'Gregory House'
96
+ browser.body(:id, 'first')[3][1].text.should == 'Hugh Laurie'
97
+ end
98
+ end
99
+
100
+ it "returns the row at the given index (table context)" do
101
+ browser.table(:index, 1).body(:id, 'first')[1].text.should == 'March 2008'
102
+ browser.table(:index, 1).body(:id, 'first')[2][1].text.should == 'Gregory House'
103
+ browser.table(:index, 1).body(:id, 'first')[3][1].text.should == 'Hugh Laurie'
104
+ end
105
+ end
106
+
107
+ describe "#each" do
108
+ it "iterates through rows correctly" do
109
+ body = browser.table(:index, 1).body(:id, 'first')
110
+ expected_texts = ["march", "gregory", "hugh"]
111
+
112
+ body.each_with_index do |row, idx|
113
+ row.id.should == expected_texts[idx]
114
+ end
115
+
116
+ end
117
+ end
118
+
119
+ end
@@ -0,0 +1,76 @@
1
+ # encoding: utf-8
2
+ require File.expand_path("../spec_helper", __FILE__)
3
+
4
+ describe "TableCell" do
5
+
6
+ before :each do
7
+ browser.goto(WatirSpec.files + "/tables.html")
8
+ end
9
+
10
+ # Exists
11
+ describe "#exists?" do
12
+ it "returns true when the table cell exists" do
13
+ browser.cell(:id, 't1_r2_c1').should exist
14
+ browser.cell(:id, /t1_r2_c1/).should exist
15
+ browser.cell(:text, 'Table 1, Row 3, Cell 1').should exist
16
+ browser.cell(:text, /Table 1/).should exist
17
+ browser.cell(:index, 1).should exist
18
+ browser.cell(:xpath, "//td[@id='t1_r2_c1']").should exist
19
+ end
20
+
21
+ it "returns true if the element exists (default how = :id)" do
22
+ browser.cell("t1_r2_c1").should exist
23
+ end
24
+
25
+ it "returns the first cell if given no args" do
26
+ browser.cell.should exist
27
+ end
28
+
29
+ it "returns false when the table cell does not exist" do
30
+ browser.cell(:id, 'no_such_id').should_not exist
31
+ browser.cell(:id, /no_such_id/).should_not exist
32
+ browser.cell(:text, 'no_such_text').should_not exist
33
+ browser.cell(:text, /no_such_text/).should_not exist
34
+ browser.cell(:index, 1337).should_not exist
35
+ browser.cell(:xpath, "//td[@id='no_such_id']").should_not exist
36
+ end
37
+
38
+ it "raises TypeError when 'what' argument is invalid" do
39
+ lambda { browser.cell(:id, 3.14).exists? }.should raise_error(TypeError)
40
+ end
41
+
42
+ it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
43
+ lambda { browser.cell(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
44
+ end
45
+ end
46
+
47
+ describe "#click" do
48
+ it "fires the table's onclick event" do
49
+ browser.cell(:id, 't2_r1_c1').click
50
+ messages.should include('td')
51
+ end
52
+ end
53
+
54
+ # Attribute methods
55
+ describe "#text" do
56
+ it "returns the text inside the table cell" do
57
+ browser.cell(:id, 't1_r2_c1').text.should == 'Table 1, Row 2, Cell 1'
58
+ browser.cell(:id, 't2_r1_c1').text.should == 'Table 2, Row 1, Cell 1'
59
+ end
60
+ end
61
+
62
+ describe "#colspan" do
63
+ it "gets the colspan attribute" do
64
+ browser.cell(:id, 'colspan_2').colspan.should == 2
65
+ browser.cell(:id, 'no_colspan').colspan.should == 1
66
+ end
67
+ end
68
+
69
+ describe "#respond_to?" do
70
+ it "returns true for all attribute methods" do
71
+ browser.cell(:index, 1).should respond_to(:text)
72
+ browser.cell(:index, 1).should respond_to(:colspan)
73
+ end
74
+ end
75
+
76
+ end
@@ -0,0 +1,71 @@
1
+ # encoding: utf-8
2
+ require File.expand_path("../spec_helper", __FILE__)
3
+
4
+ describe "TableCells" do
5
+
6
+ before :each do
7
+ browser.goto(WatirSpec.files + "/tables.html")
8
+ end
9
+
10
+ # describe "#length" do
11
+ # it "returns the number of cells" do
12
+ # browser.table(:id, 'outer').cells.length.should == 6
13
+ # browser.table(:id, 'inner').cells.length.should == 2
14
+ # end
15
+ # end
16
+ #
17
+ # describe "#[]" do
18
+ # it "returns the row at the given index" do
19
+ # browser.table(:id, 'outer').cells[1].text.should == "Table 1, Row 1, Cell 1"
20
+ # browser.table(:id, 'inner').cells[1].text.should == "Table 2, Row 1, Cell 1"
21
+ # browser.table(:id, 'outer').cells[6].text.should == "Table 1, Row 3, Cell 2"
22
+ # end
23
+ # end
24
+
25
+ describe "#each" do
26
+ it "iterates through cells correctly" do
27
+ # All cells on the page
28
+ count = 0
29
+
30
+ browser.cells.each_with_index do |c, index|
31
+ c.name.should == browser.cell(:index, index+1).name
32
+ c.id.should == browser.cell(:index, index+1).id
33
+ c.value.should == browser.cell(:index, index+1).value
34
+
35
+ count += 1
36
+ end
37
+
38
+ count.should > 0
39
+
40
+ # Cells inside a table
41
+ count = 0
42
+
43
+ inner_table = browser.table(:id, 'inner')
44
+
45
+ inner_table.cells.each_with_index do |c, index|
46
+ c.name.should == inner_table.cell(:index, index+1).name
47
+ c.id.should == inner_table.cell(:index, index+1).id
48
+ c.value.should == inner_table.cell(:index, index+1).value
49
+
50
+ count += 1
51
+ end
52
+
53
+ count.should > 0
54
+
55
+ # Cells inside a table (should not include cells inside a table inside a table)
56
+ outer_table = browser.table(:id, 'outer')
57
+ count = 0
58
+
59
+ outer_table.cells.each_with_index do |c, index|
60
+ c.name.should == outer_table.cell(:index, index+1).name
61
+ c.id.should == outer_table.cell(:index, index+1).id
62
+ c.value.should == outer_table.cell(:index, index+1).value
63
+
64
+ count += 1
65
+ end
66
+
67
+ count.should > 0
68
+ end
69
+ end
70
+
71
+ end
@@ -0,0 +1,94 @@
1
+ # encoding: utf-8
2
+ require File.expand_path("../spec_helper", __FILE__)
3
+
4
+ bug "WTR-358", :watir do
5
+
6
+ describe "TableFooter" do
7
+ before :each do
8
+ browser.goto(WatirSpec.files + "/tables.html")
9
+ end
10
+
11
+ describe "#exists?" do
12
+ it "returns true if the table tfoot exists (page context)" do
13
+ browser.tfoot(:id, 'tax_totals').should exist
14
+ browser.tfoot(:id, /tax_totals/).should exist
15
+ browser.tfoot(:index, 1).should exist
16
+ browser.tfoot(:xpath, "//tfoot[@id='tax_totals']").should exist
17
+ end
18
+
19
+ it "returns the first tfoot if given no args" do
20
+ browser.tfoot.should exist
21
+ end
22
+
23
+ it "returns true if the table tfoot exists (table context)" do
24
+ browser.table(:index, 1).tfoot(:id, 'tax_totals').should exist
25
+ browser.table(:index, 1).tfoot(:id, /tax_totals/).should exist
26
+ browser.table(:index, 1).tfoot(:index, 1).should exist
27
+ browser.table(:index, 1).tfoot(:xpath, "//tfoot[@id='tax_totals']").should exist
28
+ end
29
+
30
+ it "returns true if the element exists (default how = :id)" do
31
+ browser.tfoot("tax_totals").should exist
32
+ browser.table(:index, 1).tfoot("tax_totals").should exist
33
+ end
34
+
35
+ it "returns false if the table tfoot doesn't exist (page context)" do
36
+ browser.tfoot(:id, 'no_such_id').should_not exist
37
+ browser.tfoot(:id, /no_such_id/).should_not exist
38
+ browser.tfoot(:index, 1337).should_not exist
39
+ browser.tfoot(:xpath, "//tfoot[@id='no_such_id']").should_not exist
40
+ end
41
+
42
+ it "returns false if the table tfoot doesn't exist (table context)" do
43
+ browser.table(:index, 1).tfoot(:id, 'no_such_id').should_not exist
44
+ browser.table(:index, 1).tfoot(:id, /no_such_id/).should_not exist
45
+ browser.table(:index, 1).tfoot(:index, 1337).should_not exist
46
+ browser.table(:index, 1).tfoot(:xpath, "//tfoot[@id='no_such_id']").should_not exist
47
+ end
48
+
49
+ it "raises TypeError when 'what' argument is invalid" do
50
+ lambda { browser.tfoot(:id, 3.14).exists? }.should raise_error(TypeError)
51
+ lambda { browser.table(:index, 1).tfoot(:id, 3.14).exists? }.should raise_error(TypeError)
52
+ end
53
+
54
+ it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
55
+ lambda { browser.tfoot(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
56
+ lambda { browser.table(:index, 1).tfoot(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
57
+ end
58
+ end
59
+
60
+ describe "#length" do
61
+ it "returns the correct number of table footers (page context)" do
62
+ browser.tfoot(:id, 'tax_totals').length.should == 1
63
+ end
64
+
65
+ it "returns the correct number of table footers (table context)" do
66
+ browser.table(:index, 1).tfoot(:id, 'tax_totals').length.should == 1
67
+ end
68
+ end
69
+
70
+ describe "#[]" do
71
+ it "returns the row at the given index (page context)" do
72
+ browser.tfoot(:id, 'tax_totals')[1].id.should == 'tfoot_row_1'
73
+ browser.tfoot(:id, 'tax_totals')[1][2].text.should == '24 349'
74
+ browser.tfoot(:id, 'tax_totals')[1][3].text.should == '5 577'
75
+ end
76
+
77
+ it "returns the row at the given index (table context)" do
78
+ browser.table(:index, 1).tfoot(:id, 'tax_totals')[1].id.should == "tfoot_row_1"
79
+ browser.table(:index, 1).tfoot(:id, 'tax_totals')[1][2].text.should == '24 349'
80
+ browser.table(:index, 1).tfoot(:id, 'tax_totals')[1][3].text.should == '5 577'
81
+ end
82
+ end
83
+
84
+ describe "#each" do
85
+ it "iterates through rows correctly" do
86
+ tfoot = browser.table(:index, 1).tfoot(:id, 'tax_totals')
87
+ tfoot.each_with_index do |r, idx|
88
+ r.id.should == "tfoot_row_#{idx + 1}"
89
+ end
90
+ end
91
+ end
92
+ end
93
+
94
+ end
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+ require File.expand_path("../spec_helper", __FILE__)
3
+
4
+ bug "WTR-358", :watir do
5
+
6
+ describe "TableFooters" do
7
+ before :each do
8
+ browser.goto(WatirSpec.files + "/tables.html")
9
+ end
10
+
11
+ describe "#length" do
12
+ it "returns the correct number of table tfoots (page context)" do
13
+ browser.tfoots.length.should == 1
14
+ end
15
+
16
+ it "returns the correct number of table tfoots (table context)" do
17
+ browser.table(:index, 1).tfoots.length.should == 1
18
+ end
19
+ end
20
+
21
+ describe "#[]" do
22
+ it "returns the row at the given index (page context)" do
23
+ browser.tfoots[1].id.should == "tax_totals"
24
+ end
25
+
26
+ it "returns the row at the given index (table context)" do
27
+ browser.table(:index, 1).tfoots[1].id.should == "tax_totals"
28
+ end
29
+ end
30
+
31
+ describe "#each" do
32
+ it "iterates through table tfoots correctly (page context)" do
33
+ count = 0
34
+
35
+ browser.tfoots.each_with_index do |tfoot, index|
36
+ tfoot.name.should == browser.tfoot(:index, index+1).name
37
+ tfoot.id.should == browser.tfoot(:index, index+1).id
38
+
39
+ count += 1
40
+ end
41
+
42
+ count.should > 0
43
+ end
44
+
45
+ it "iterates through table tfoots correctly (table context)" do
46
+ table = browser.table(:index, 1)
47
+ count = 0
48
+
49
+ table.tfoots.each_with_index do |tfoot, index|
50
+ tfoot.name.should == table.tfoot(:index, index+1).name
51
+ tfoot.id.should == table.tfoot(:index, index+1).id
52
+
53
+ count += 1
54
+ end
55
+
56
+ count.should > 0
57
+ end
58
+ end
59
+ end
60
+
61
+ end
@@ -0,0 +1,98 @@
1
+ # encoding: utf-8
2
+ require File.expand_path("../spec_helper", __FILE__)
3
+
4
+ bug "WTR-357", :watir do
5
+ describe "TableHeader" do
6
+
7
+ before :each do
8
+ browser.goto(WatirSpec.files + "/tables.html")
9
+ end
10
+
11
+ describe "#exists?" do
12
+ it "returns true if the table theader exists (page context)" do
13
+ browser.thead(:id, 'tax_headers').should exist
14
+ browser.thead(:id, /tax_headers/).should exist
15
+ browser.thead(:index, 1).should exist
16
+ browser.thead(:xpath, "//thead[@id='tax_headers']").should exist
17
+ end
18
+
19
+ it "returns the first thead if given no args" do
20
+ browser.thead.should exist
21
+ end
22
+
23
+ it "returns true if the table theader exists (table context)" do
24
+ browser.table(:index, 1).thead(:id, 'tax_headers').should exist
25
+ browser.table(:index, 1).thead(:id, /tax_headers/).should exist
26
+ browser.table(:index, 1).thead(:index, 1).should exist
27
+ browser.table(:index, 1).thead(:xpath, "//thead[@id='tax_headers']").should exist
28
+ end
29
+
30
+ it "returns true if the element exists (default how = :id)" do
31
+ browser.thead("tax_headers").should exist
32
+ browser.table(:index, 1).thead("tax_headers").should exist
33
+ end
34
+
35
+ it "returns false if the table theader doesn't exist (page context)" do
36
+ browser.thead(:id, 'no_such_id').should_not exist
37
+ browser.thead(:id, /no_such_id/).should_not exist
38
+ browser.thead(:index, 1337).should_not exist
39
+ browser.thead(:xpath, "//thead[@id='no_such_id']").should_not exist
40
+ end
41
+
42
+ it "returns false if the table theader doesn't exist (table context)" do
43
+ browser.table(:index, 1).thead(:id, 'no_such_id').should_not exist
44
+ browser.table(:index, 1).thead(:id, /no_such_id/).should_not exist
45
+ browser.table(:index, 1).thead(:index, 1337).should_not exist
46
+ browser.table(:index, 1).thead(:xpath, "//thead[@id='no_such_id']").should_not exist
47
+ end
48
+
49
+ it "raises TypeError when 'what' argument is invalid" do
50
+ lambda { browser.thead(:id, 3.14).exists? }.should raise_error(TypeError)
51
+ lambda { browser.table(:index, 1).thead(:id, 3.14).exists? }.should raise_error(TypeError)
52
+ end
53
+
54
+ it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
55
+ lambda { browser.thead(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
56
+ lambda { browser.table(:index, 1).thead(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
57
+ end
58
+ end
59
+
60
+ describe "#length" do
61
+ it "returns the correct number of table bodies (page context)" do
62
+ browser.thead(:id, 'tax_headers').length.should == 1
63
+ end
64
+
65
+ it "returns the correct number of table bodies (table context)" do
66
+ browser.table(:index, 1).thead(:id, 'tax_headers').length.should == 1
67
+ end
68
+ end
69
+
70
+ describe "#[]" do
71
+ it "returns the row at the given index (page context)" do
72
+ browser.thead(:id, 'tax_headers')[1].id.should == 'thead_row_1'
73
+ browser.thead(:id, 'tax_headers')[1][2].text.should == 'Before income tax'
74
+ browser.thead(:id, 'tax_headers')[1][3].text.should == 'Income tax'
75
+ end
76
+
77
+ it "returns the row at the given index (table context)" do
78
+ browser.table(:index, 1).thead(:id, 'tax_headers')[1].id.should == 'thead_row_1'
79
+ browser.table(:index, 1).thead(:id, 'tax_headers')[1][2].text.should == 'Before income tax'
80
+ browser.table(:index, 1).thead(:id, 'tax_headers')[1][3].text.should == 'Income tax'
81
+ end
82
+ end
83
+
84
+ describe "#each" do
85
+ it "iterates through rows correctly" do
86
+ theader = browser.table(:index, 1).thead(:id, 'tax_headers')
87
+ index = 1
88
+ theader.each do |r|
89
+ r.name.should == browser.row(:index, index).name
90
+ r.id.should == browser.row(:index, index).id
91
+ r.value.should == browser.row(:index, index).value
92
+ index += 1
93
+ end
94
+ index.should_not == 1
95
+ end
96
+ end
97
+ end
98
+ end