watir-classic 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. data/.gitignore +7 -0
  2. data/.gitmodules +3 -0
  3. data/.rspec +1 -0
  4. data/.yardopts +5 -0
  5. data/CHANGES +20 -10
  6. data/CONTRIBUTORS.txt +55 -0
  7. data/Gemfile +3 -0
  8. data/Gemfile.lock +78 -0
  9. data/README.rdoc +8 -14
  10. data/Rakefile +32 -0
  11. data/VERSION +1 -1
  12. data/lib/watir-classic.rb +0 -1
  13. data/lib/watir-classic/IEDialog/IEDialog.cpp +225 -0
  14. data/lib/watir-classic/IEDialog/IEDialog.h +15 -0
  15. data/lib/watir-classic/IEDialog/IEDialog.vcproj +159 -0
  16. data/lib/watir-classic/IEDialog/ReadMe.txt +40 -0
  17. data/lib/watir-classic/IEDialog/stdafx.cpp +8 -0
  18. data/lib/watir-classic/IEDialog/stdafx.h +21 -0
  19. data/lib/watir-classic/browser.rb +1 -1
  20. data/lib/watir-classic/container.rb +4 -33
  21. data/lib/watir-classic/core.rb +1 -3
  22. data/lib/watir-classic/dialogs/alert.rb +46 -0
  23. data/lib/watir-classic/dialogs/file_field.rb +1 -0
  24. data/lib/watir-classic/drag_and_drop_helper.rb +18 -6
  25. data/lib/watir-classic/element.rb +0 -2
  26. data/lib/watir-classic/ext/json2.js +487 -0
  27. data/lib/watir-classic/ie-class.rb +10 -164
  28. data/lib/watir-classic/ie.rb +2 -0
  29. data/lib/watir-classic/input_elements.rb +1 -1
  30. data/lib/watir-classic/modal_dialog.rb +1 -7
  31. data/lib/watir-classic/module.rb +1 -10
  32. data/lib/watir-classic/non_control_elements.rb +11 -0
  33. data/lib/watir-classic/page-container.rb +22 -24
  34. data/lib/watir-classic/screenshot.rb +33 -0
  35. data/lib/watir-classic/win32ole/1.8.7/win32ole.patch +56 -0
  36. data/lib/watir-classic/win32ole/1.9.3/win32ole.patch +63 -0
  37. data/lib/watir-classic/win32ole/build_notes.txt +18 -0
  38. data/lib/watir-classic/win32ole/history.txt +88 -0
  39. data/spec/browser_spec.rb +34 -0
  40. data/spec/implementation.rb +18 -0
  41. data/watir-classic.gemspec +40 -0
  42. data/watir.gif +0 -0
  43. metadata +159 -192
  44. data/bin/watir-console +0 -5
  45. data/lib/watir-classic/assertions.rb +0 -44
  46. data/lib/watir-classic/dialogs/javascript.rb +0 -43
  47. data/lib/watir-classic/irb-history.rb +0 -31
  48. data/lib/watir-classic/logger.rb +0 -19
  49. data/lib/watir-classic/screen_capture.rb +0 -115
  50. data/lib/watir-classic/testcase.rb +0 -97
  51. data/lib/watir-classic/waiter.rb +0 -98
  52. data/rakefile.rb +0 -54
  53. data/unittests/all_tests.rb +0 -10
  54. data/unittests/buttons_xpath_test.rb +0 -68
  55. data/unittests/checkbox_test.rb +0 -163
  56. data/unittests/checkbox_xpath_test.rb +0 -106
  57. data/unittests/click_no_wait_test.rb +0 -23
  58. data/unittests/close_all_test.rb +0 -17
  59. data/unittests/core_tests.rb +0 -17
  60. data/unittests/css_selector_test.rb +0 -44
  61. data/unittests/css_test.rb +0 -38
  62. data/unittests/dialog_test.rb +0 -64
  63. data/unittests/div2_xpath_test.rb +0 -21
  64. data/unittests/div_test.rb +0 -170
  65. data/unittests/div_xpath_test.rb +0 -95
  66. data/unittests/document_standards.rb +0 -63
  67. data/unittests/element_collection_indexes_test.rb +0 -57
  68. data/unittests/element_collections_test.rb +0 -100
  69. data/unittests/element_test.rb +0 -47
  70. data/unittests/errorchecker_test.rb +0 -31
  71. data/unittests/filefield_test.rb +0 -43
  72. data/unittests/filefield_xpath_test.rb +0 -35
  73. data/unittests/form_test.rb +0 -282
  74. data/unittests/form_xpath_test.rb +0 -254
  75. data/unittests/frame_test.rb +0 -165
  76. data/unittests/google_form_test.rb +0 -15
  77. data/unittests/html/JavascriptClick.html +0 -39
  78. data/unittests/html/blankpage.html +0 -11
  79. data/unittests/html/buttons1.html +0 -40
  80. data/unittests/html/checkboxes1.html +0 -89
  81. data/unittests/html/click_no_wait.html +0 -14
  82. data/unittests/html/complex_table.html +0 -35
  83. data/unittests/html/cssTest.html +0 -42
  84. data/unittests/html/depot_store.html +0 -59
  85. data/unittests/html/div.html +0 -92
  86. data/unittests/html/div_xml.html +0 -21
  87. data/unittests/html/fileupload.html +0 -44
  88. data/unittests/html/formTest1.html +0 -38
  89. data/unittests/html/forms2.html +0 -44
  90. data/unittests/html/forms3.html +0 -131
  91. data/unittests/html/forms4.html +0 -26
  92. data/unittests/html/frame_buttons.html +0 -4
  93. data/unittests/html/frame_links.html +0 -4
  94. data/unittests/html/frame_multi.html +0 -5
  95. data/unittests/html/google_india.html +0 -119
  96. data/unittests/html/ie7_document_standards.html +0 -9
  97. data/unittests/html/ie8_document_standards.html +0 -9
  98. data/unittests/html/ie9_document_standards.html +0 -9
  99. data/unittests/html/iframe.html +0 -3
  100. data/unittests/html/iframeTest.html +0 -17
  101. data/unittests/html/iframeTest1.html +0 -7
  102. data/unittests/html/iframeTest2.html +0 -5
  103. data/unittests/html/images/1.gif +0 -0
  104. data/unittests/html/images/2.GIF +0 -0
  105. data/unittests/html/images/3.GIF +0 -0
  106. data/unittests/html/images/button.jpg +0 -0
  107. data/unittests/html/images/circle.jpg +0 -0
  108. data/unittests/html/images/map.GIF +0 -0
  109. data/unittests/html/images/map2.gif +0 -0
  110. data/unittests/html/images/minus.GIF +0 -0
  111. data/unittests/html/images/originaltriangle.jpg +0 -0
  112. data/unittests/html/images/plus.gif +0 -0
  113. data/unittests/html/images/square.jpg +0 -0
  114. data/unittests/html/images/triangle.jpg +0 -0
  115. data/unittests/html/images1.html +0 -65
  116. data/unittests/html/javascriptevents.html +0 -33
  117. data/unittests/html/link_pass.html +0 -11
  118. data/unittests/html/links1.html +0 -37
  119. data/unittests/html/links2.html +0 -11
  120. data/unittests/html/links_multi.html +0 -12
  121. data/unittests/html/list_matters.html +0 -720
  122. data/unittests/html/lists.html +0 -18
  123. data/unittests/html/map_test.html +0 -30
  124. data/unittests/html/modal_dialog.html +0 -10
  125. data/unittests/html/modal_dialog_launcher.html +0 -12
  126. data/unittests/html/multiple_specifiers.html +0 -64
  127. data/unittests/html/nestedFrames.html +0 -6
  128. data/unittests/html/new_browser.html +0 -17
  129. data/unittests/html/pass.html +0 -13
  130. data/unittests/html/popups1.html +0 -59
  131. data/unittests/html/pre.html +0 -29
  132. data/unittests/html/quirks_document_standards.html +0 -8
  133. data/unittests/html/radioButtons1.html +0 -71
  134. data/unittests/html/select_tealeaf.html +0 -54
  135. data/unittests/html/selectboxes1.html +0 -52
  136. data/unittests/html/simple_table.html +0 -25
  137. data/unittests/html/simple_table_buttons.html +0 -104
  138. data/unittests/html/simple_table_columns.html +0 -75
  139. data/unittests/html/table1.html +0 -179
  140. data/unittests/html/tableCell_using_xpath.html +0 -19
  141. data/unittests/html/table_and_tablerow_to_a.html +0 -174
  142. data/unittests/html/textarea.html +0 -30
  143. data/unittests/html/textfields1.html +0 -100
  144. data/unittests/html/textsearch.html +0 -44
  145. data/unittests/html/wallofcheckboxes.html +0 -1003
  146. data/unittests/html/xpath_nbsp.html +0 -11
  147. data/unittests/html/zeroindex.html +0 -11
  148. data/unittests/ie_exists_test.rb +0 -16
  149. data/unittests/ie_mock.rb +0 -94
  150. data/unittests/ie_test.rb +0 -54
  151. data/unittests/images_test.rb +0 -156
  152. data/unittests/images_xpath_test.rb +0 -90
  153. data/unittests/index_specifier_test.rb +0 -31
  154. data/unittests/js_events_test.rb +0 -31
  155. data/unittests/links_multi_test.rb +0 -34
  156. data/unittests/links_test.rb +0 -131
  157. data/unittests/links_xpath_test.rb +0 -38
  158. data/unittests/lists_test.rb +0 -23
  159. data/unittests/map_test.rb +0 -98
  160. data/unittests/minmax_test.rb +0 -37
  161. data/unittests/navigate_test.rb +0 -38
  162. data/unittests/nbsp_xpath_test.rb +0 -16
  163. data/unittests/no_wait_test.rb +0 -28
  164. data/unittests/non_core_tests.rb +0 -12
  165. data/unittests/other/all_tests_concurrent.rb +0 -57
  166. data/unittests/other/navigate_exception_test.rb +0 -24
  167. data/unittests/other/rexml_unit_test.rb +0 -27
  168. data/unittests/other/screen_capture_test.rb +0 -53
  169. data/unittests/other/testcase_method_order_test.rb +0 -36
  170. data/unittests/other/testcase_verify_test.rb +0 -25
  171. data/unittests/other/wait_until_test.rb +0 -102
  172. data/unittests/pagecontainstext_test.rb +0 -69
  173. data/unittests/parent_child_test.rb +0 -27
  174. data/unittests/perf_test.rb +0 -20
  175. data/unittests/pre_test.rb +0 -49
  176. data/unittests/radios_test.rb +0 -181
  177. data/unittests/radios_xpath_test.rb +0 -100
  178. data/unittests/security_setting_test.rb +0 -24
  179. data/unittests/selectbox_test.rb +0 -144
  180. data/unittests/selectbox_xpath_test.rb +0 -102
  181. data/unittests/setup.rb +0 -69
  182. data/unittests/speed_settings_test.rb +0 -67
  183. data/unittests/table_cell_using_xpath_test.rb +0 -34
  184. data/unittests/table_test.rb +0 -296
  185. data/unittests/table_xpath_test.rb +0 -109
  186. data/unittests/test_tests.rb +0 -9
  187. data/unittests/textarea_test.rb +0 -92
  188. data/unittests/textarea_xpath_test.rb +0 -77
  189. data/unittests/textfield_for_ch_char_test.rb +0 -32
  190. data/unittests/textfields_test.rb +0 -184
  191. data/unittests/textfields_xpath_test.rb +0 -110
  192. data/unittests/version_test.rb +0 -15
  193. data/unittests/win32ole_so_test.rb +0 -35
  194. data/unittests/window_tests.rb +0 -10
  195. data/unittests/windows/attach_to_existing_window_test.rb +0 -52
  196. data/unittests/windows/attach_to_new_window_test.rb +0 -74
  197. data/unittests/windows/close_window_test.rb +0 -20
  198. data/unittests/windows/frame_links_test.rb +0 -23
  199. data/unittests/windows/ie-each_test.rb +0 -46
  200. data/unittests/windows/modal_dialog_test.rb +0 -95
  201. data/unittests/windows/new_process_test.rb +0 -24
  202. data/unittests/windows/new_test.rb +0 -58
  203. data/unittests/windows/open_close_test.rb +0 -19
  204. data/unittests/windows/send_keys_test.rb +0 -26
  205. data/unittests/xpath_tests.rb +0 -11
  206. data/watir-rdoc.rb +0 -7
@@ -1,102 +0,0 @@
1
- # feature tests for Select Boxes
2
-
3
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
4
- require 'unittests/setup'
5
-
6
- class TC_Selectbox_XPath < Test::Unit::TestCase
7
- include Watir::Exception
8
-
9
- def setup
10
- goto_page "selectboxes1.html"
11
- end
12
-
13
- def test_textBox_Exists
14
- assert(browser.select_list(:xpath, "//select[@name='sel1']/").exists?)
15
- assert_false(browser.select_list(:xpath, "//select[@name='missing']/").exists?)
16
- assert_false(browser.select_list(:xpath, "//select[@id='missing']/").exists?)
17
- end
18
-
19
- def test_select_list_enabled
20
- assert(browser.select_list(:xpath, "//select[@name='sel1']/").enabled?)
21
- assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").enabled? }
22
- end
23
-
24
- def test_select_list_getAllContents
25
- assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").getAllContents }
26
- assert_equal( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
27
- browser.select_list(:xpath, "//select[@name='sel1']/").options.map(&:text))
28
- end
29
-
30
- def test_select_list_getSelectedItems
31
- assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").getSelectedItems }
32
- assert_equal( ["Option 3" ] ,
33
- browser.select_list(:xpath, "//select[@name='sel1']/").selected_options.map(&:text))
34
- assert_equal( ["Option 3" , "Option 6" ] ,
35
- browser.select_list(:xpath, "//select[@name='sel2']/").selected_options.map(&:text))
36
- end
37
-
38
- def test_clearSelection
39
- browser.select_list(:xpath, "//select[@name='sel2']/").clearSelection
40
- assert_equal( [ ] , browser.select_list(:xpath, "//select[@name='sel2']/").selected_options.map(&:text))
41
- end
42
-
43
- def test_select_list_select
44
- assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").selected_options.map(&:text) }
45
- assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']/").select("missing item") }
46
- assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']/").select(/missing/) }
47
-
48
- # the select method keeps any currently selected items - use the clear selectcion method first
49
- browser.select_list(:xpath, "//select[@name='sel1']/").select("Option 1")
50
- assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']/").selected_options.map(&:text))
51
-
52
- browser.select_list(:xpath, "//select[@name='sel1']/").select(/2/)
53
- assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']/").selected_options.map(&:text))
54
-
55
- browser.select_list(:xpath, "//select[@name='sel2']/").clearSelection
56
- browser.select_list(:xpath, "//select[@name='sel2']/").select( /2/ )
57
- browser.select_list(:xpath, "//select[@name='sel2']/").select( /4/ )
58
- assert_equal( ["Option 2" , "Option 4" ] ,
59
- browser.select_list(:xpath, "//select[@name='sel2']/").selected_options.map(&:text))
60
-
61
- # these are to test the onchange event
62
- # the event shouldnt get fired, as this is the selected item
63
- browser.select_list(:xpath, "//select[@name='sel3']/").select( /3/ )
64
- assert_false(browser.text.include?("Pass") )
65
- end
66
-
67
- def test_select_list_select2
68
- # the event should get fired
69
- browser.select_list(:xpath, "//select[@name='sel3']/").select( /2/ )
70
- assert(browser.text.include?("PASS") )
71
- end
72
-
73
- def test_select_list_select_using_value
74
- assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").getSelectedItems }
75
- assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']/").select_value("missing item") }
76
- assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']/").select_value(/missing/) }
77
-
78
- # the select method keeps any currently selected items - use the clear selectcion method first
79
- browser.select_list(:xpath, "//select[@name='sel1']/").select_value("o1")
80
- assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']/").selected_options.map(&:text))
81
-
82
- browser.select_list(:xpath, "//select[@name='sel1']/").select_value(/2/)
83
- assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']/").selected_options.map(&:text))
84
-
85
- browser.select_list(:xpath, "//select[@name='sel2']/").clearSelection
86
- browser.select_list(:xpath, "//select[@name='sel2']/").select( /2/ )
87
- browser.select_list(:xpath, "//select[@name='sel2']/").select( /4/ )
88
- assert_equal( ["Option 2" , "Option 4" ] , browser.select_list(:xpath, "//select[@name='sel2']/").selected_options.map(&:text))
89
-
90
- # these are to test the onchange event
91
- # the event shouldnt get fired, as this is the selected item
92
- browser.select_list(:xpath, "//select[@name='sel3']/").select_value( /3/ )
93
- assert_false(browser.text.include?("Pass") )
94
- end
95
-
96
- def test_select_list_select_using_value2
97
- # the event should get fired
98
- browser.select_list(:xpath, "//select[@name='sel3']/").select_value( /2/ )
99
- assert(browser.text.include?("PASS") )
100
- end
101
-
102
- end
@@ -1,69 +0,0 @@
1
- # watir/unittests/setup.rb
2
- $SETUP_LOADED = true
3
- $myDir = File.expand_path(File.dirname(__FILE__))
4
-
5
- def append_to_load_path path
6
- $LOAD_PATH.unshift File.expand_path(path)
7
- end
8
-
9
- # use local development versions of watir
10
- topdir = File.join(File.dirname(__FILE__), '..')
11
- $watir_dev_lib = File.join(topdir, 'lib')
12
- commonwatir_dir = "commonwatir#{File.exist?('VERSION') ? "-#{File.read('VERSION').strip}" : ""}"
13
- commonwatir_absolute_dir = File.join(topdir, '..', commonwatir_dir)
14
- libs = []
15
- libs << File.join(commonwatir_absolute_dir, 'lib')
16
- libs << commonwatir_absolute_dir # for the unit tests
17
- libs.each { |lib| append_to_load_path(lib) }
18
-
19
- require 'watir-classic/browser'
20
- Watir::Browser.default = 'ie'
21
- require 'unittests/setup/lib'
22
- require 'watir-classic/testcase'
23
-
24
- # Standard Tags
25
- # :must_be_visible
26
- # :creates_windows
27
- # :unreliable (test fails intermittently)
28
-
29
- =begin
30
- Test Suites
31
- * all_tests -- all the tests in the unittests directory (omits "other")
32
- * window_tests -- window intensive tests
33
- =end
34
-
35
- $all_tests = []
36
- $all_tests += Dir["unittests/*_test.rb"]
37
- Dir.chdir commonwatir_absolute_dir do
38
- $all_tests += Dir["unittests/*_test.rb"]
39
- end
40
-
41
- # These tests won't load unless Watir is in the path
42
- $watir_only_tests = [
43
- "images_xpath_test.rb",
44
- "images_test.rb",
45
- "dialog_test.rb",
46
- "ie_test.rb"
47
- ].map {|file| "unittests/#{file}"}
48
-
49
- if Watir::UnitTest.options[:browser] != 'ie'
50
- $all_tests -= $watir_only_tests
51
- end
52
-
53
-
54
- =begin
55
- 'attach_to_existing_window', # could actually run robustly as part of the core suite!
56
- 'attach_to_new_window', # creates new window
57
- 'close_window', # creates new window
58
- 'frame_links', # visible
59
- 'iedialog', # visible
60
- #ie-each
61
- 'js_events', # is always visible
62
- 'jscript',
63
- 'modal_dialog', # modal is visible
64
- #new
65
- 'open_close',
66
- 'send_keys', # visible
67
- =end
68
-
69
- $window_tests = Dir["unittests/windows/*_test.rb"] - ["unittests/windows/ie-each_test.rb"]
@@ -1,67 +0,0 @@
1
- # tests for ability to set defaults for Watir
2
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
3
- require 'unittests/setup'
4
-
5
- class TC_instance_options < Test::Unit::TestCase
6
- tags :fails_on_firefox
7
-
8
- def setup
9
- @ie4 = Watir::IE.new
10
- end
11
-
12
- def test_using_default
13
- @ie4.speed = :fast
14
- assert_equal(:fast, @ie4.speed)
15
- @ie4.speed = :slow
16
- assert_equal(:slow, @ie4.speed)
17
- @ie4.speed = :zippy
18
- assert_equal(:zippy, @ie4.speed)
19
-
20
- assert_raise(ArgumentError){@ie4.speed = :fubar}
21
- end
22
-
23
- def teardown
24
- @ie4.close if @ie4.exists?
25
- end
26
- end
27
-
28
- class TC_class_options < Test::Unit::TestCase
29
- tags :fails_on_firefox
30
- include Watir
31
- @@hide_ie = $HIDE_IE
32
- def setup
33
- @previous = IE.options
34
- end
35
- def test_class_defaults
36
- assert_equal({:speed => IE.speed, :visible => IE.visible, :attach_timeout => IE.attach_timeout, :zero_based_indexing => IE.zero_based_indexing}, IE.options)
37
- end
38
- def test_change_defaults
39
- IE.set_options(:speed => :fast)
40
- assert_equal(:fast, IE.speed)
41
- IE.set_options(:visible => false)
42
- assert_equal(false, IE.visible)
43
- IE.set_options(:speed => :slow)
44
- assert_equal(:slow, IE.speed)
45
- IE.set_options(:visible => true)
46
- assert_equal(true, IE.visible)
47
- IE.set_options(:attach_timeout => 22.0)
48
- assert_equal(22.0, IE.attach_timeout)
49
- end
50
- def test_defaults_affect_on_instance
51
- IE.set_options(:speed => :fast)
52
- @ie1 = IE.new
53
- assert_equal(:fast, @ie1.speed)
54
- IE.set_options(:speed => :slow)
55
- @ie2 = IE.new
56
- assert_equal(:slow, @ie2.speed)
57
- IE.set_options(:speed => :zippy)
58
- @ie3 = IE.new
59
- assert_equal(:zippy, @ie3.speed)
60
- end
61
- def teardown
62
- IE.set_options @previous
63
- @ie1.close if @ie1
64
- @ie2.close if @ie2
65
- @ie3.close if @ie3
66
- end
67
- end
@@ -1,34 +0,0 @@
1
- # feature tests for xpath table cells
2
-
3
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
4
- require 'unittests/setup'
5
-
6
- class TC_TableCell_XPath < Test::Unit::TestCase
7
-
8
- def setup
9
- goto_page "tableCell_using_xpath.html"
10
- end
11
-
12
- def testCellExists
13
- # There is no <image> with @src='rectangle.jpg'. So image will not be there.
14
- assert_false( browser.cell(:xpath , "//img[@src='images\/rectangle.jpg']/../").exists? )
15
- # Select the parent element of image with src='square.jpg' which is a tablecell.
16
- assert( browser.cell(:xpath , "//img[@src='images\/square.jpg']/../").exists? )
17
- assert( browser.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").exists? )
18
- puts "Selected table cell with text 'Table Cell with image of triangle.'"
19
- puts browser.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").to_s
20
- end
21
-
22
- def testCell_properties
23
- assert_equal(1 , browser.cell(:xpath , "//img[@src='images\/square.jpg']/../").colspan)
24
- assert_equal(2 , browser.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").colspan)
25
- assert_equal(3 , browser.cell(:xpath , "//img[@src='images\/circle.jpg']/../").colspan)
26
- assert_equal(4 , browser.cell(:xpath , "//img[@src='images\/button.jpg']/../").colspan)
27
-
28
- # to string tests -- output should be verified!
29
- puts browser.cell(:xpath , "//img[@src='images\/square.jpg']/../").to_s
30
- puts browser.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").to_s
31
- end
32
-
33
- end
34
-
@@ -1,296 +0,0 @@
1
- # feature tests for Tables
2
- # Why do so many of these tests call "strip"? A distinct smell...
3
-
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
- require 'unittests/setup'
6
-
7
- class TC_Tables < Test::Unit::TestCase
8
- include Watir::Exception
9
-
10
- def setup
11
- uses_page "table1.html"
12
- end
13
- def teardown
14
- browser.refresh if @reload_page
15
- end
16
-
17
- def test_exists
18
- assert browser.table(:id, 't1').exists?
19
- assert browser.table(:id, /t/).exists?
20
-
21
- assert !browser.table(:id, 'missingTable').exists?
22
- assert !browser.table(:id, /missing_table/).exists?
23
-
24
- assert browser.table(:index, 0).exists?
25
- assert !browser.table(:index, 33).exists?
26
- end
27
-
28
- tag_method :test_row_count_exceptions, :fails_on_firefox
29
- def test_row_count_exceptions
30
- assert_raises UnknownObjectException do
31
- browser.table(:id, 'missingTable').row_count
32
- end
33
- assert_raises UnknownObjectException do
34
- browser.table(:index, 66).row_count
35
- end
36
- assert_raises MissingWayOfFindingObjectException do
37
- browser.table(:bad_attribute, 99).row_count
38
- end
39
- end
40
- def test_rows
41
- assert_equal(2, browser.table(:index, 0).row_count)
42
- assert_equal(2, browser.table(:index, 0).rows.length)
43
-
44
- assert_equal(5, browser.table(:id, 't1').row_count) # 4 rows and a header
45
- assert_equal(5, browser.table(:index, 1).row_count) # same table as above, just accessed by index
46
- assert_equal(5, browser.table(:id, 't1').rows.length)
47
-
48
- # test the each iterator on rows - ie, go through each cell
49
- row = browser.table(:index, 1)[1]
50
- result = []
51
- row.each do |cell|
52
- result << cell.to_s.strip
53
- end
54
- assert_equal(['Row 1 Col1', 'Row 1 Col2'], result)
55
- assert_equal(2, row.column_count)
56
- end
57
-
58
- tag_method :test_row_counts, :fails_on_firefox
59
- def test_row_counts
60
- table = browser.table(:id => 't2')
61
- assert_equal(2, table.row_count)
62
- end
63
-
64
- tag_method :test_dynamic_tables, :fails_on_firefox
65
- def test_dynamic_tables
66
- @reload_page = true
67
- t = browser.table(:id, 't1')
68
- assert_equal(5, t.row_count)
69
- browser.button(:value, 'add row').click
70
- assert_equal(6, t.row_count)
71
- end
72
-
73
- def test_columns
74
- assert_raises UnknownObjectException do
75
- browser.table(:id, 'missingTable').column_count
76
- end
77
- assert_raises UnknownObjectException do
78
- browser.table(:index, 77).column_count
79
- end
80
- assert_equal(2, browser.table(:index, 0).column_count)
81
- assert_equal(1, browser.table(:id, 't1').column_count) # row one has 1 cell with a colspan of 2
82
- end
83
-
84
- def test_links_and_images_in_table
85
- table = browser.table(:id, 'pic_table')
86
- image = table[0][1].image(:index,0)
87
- assert_equal(106, image.width)
88
-
89
- link = table[0][3].link(:index,0)
90
- assert_equal("Google", link.text)
91
- end
92
-
93
- def test_cell_directly
94
- assert browser.td(:id, 'cell1').exists?
95
- assert ! browser.td(:id, 'no_exist').exists?
96
- assert_equal("Row 1 Col1", browser.td(:id, 'cell1').to_s.strip)
97
- end
98
-
99
- def test_cell_another_way
100
- assert_equal( "Row 1 Col1", browser.table(:index,0)[0][0].to_s.strip)
101
- end
102
-
103
- def test_row_directly
104
- assert browser.tr(:id, 'row1').exists?
105
- assert ! browser.tr(:id, 'no_exist').exists?
106
- end
107
- def test_row_another_way
108
- assert_equal('Row 2 Col1', browser.tr(:id, 'row1')[0].to_s.strip)
109
- end
110
-
111
- tag_method :test_row_in_table, :fails_on_firefox
112
- def test_row_in_table
113
- assert_equal 'Row 2 Col1 Row 2 Col2',
114
- browser.table(:id, 't1').row(:id, 'row1').text.gsub(/(\r|\n)/,'')
115
- end
116
-
117
- def test_row_collection
118
- t = browser.table(:index,0)
119
- t.rows.each_with_index do |row, i|
120
- assert("Row #{i + 1} Col1", row[0].text)
121
- assert("Row #{i + 1} Col2", row[1].text)
122
- end
123
- end
124
-
125
- tag_method :test_cell_collection, :fails_on_firefox
126
- def test_cell_collection
127
- t = browser.table(:index,0)
128
- contents = t.cells.collect {|c| c.text}
129
- assert_equal(["Row 1 Col1","Row 1 Col2","Row 2 Col1","Row 2 Col2"], contents)
130
- end
131
-
132
- tag_method :test_table_body, :fails_on_firefox
133
- def test_table_body
134
- assert_equal(1, browser.table(:index, 0).tbodys.length)
135
- assert_equal(3, browser.table(:id, 'body_test').tbodys.length)
136
-
137
- count = 1
138
- browser.table(:id, 'body_test').tbodys.each do |n|
139
- # do something better here!
140
- case count
141
- when 1
142
- compare_text = "This text is in the FRST TBODY."
143
- when 2
144
- compare_text = "This text is in the SECOND TBODY."
145
- when 3
146
- compare_text = "This text is in the THIRD TBODY."
147
- end
148
- assert_equal(compare_text, n[0][0].to_s.strip ) # this is the 1st cell of the first row of this particular body
149
- count += 1
150
- end
151
- assert_equal( count - 1, browser.table(:id, 'body_test').tbodys.length )
152
- assert_equal( "This text is in the THIRD TBODY." ,browser.table(:id, 'body_test' ).tbody(:index,2)[0][0].to_s.strip )
153
- end
154
-
155
- def test_table_container
156
- assert_nothing_raised { browser.table(:id, 't1').html }
157
- end
158
-
159
- def test_multiple_selector
160
- assert_equal('Second table with css class',
161
- browser.table(:class => 'sample', :index => 1)[0][0].text)
162
- end
163
- end
164
-
165
- class TC_Tables_Simple < Test::Unit::TestCase
166
- include Watir
167
-
168
- def setup
169
- goto_page "simple_table.html"
170
- end
171
-
172
- def test_simple_table_access
173
- table = browser.table(:index,0)
174
- assert_equal("Row 3 Col1", table[2][0].text.strip)
175
- assert_equal("Row 1 Col1", table[0][0].text.strip)
176
- assert_equal("Row 3 Col2", table[2][1].text.strip)
177
- assert_equal(2, table.column_count)
178
- end
179
- end
180
- class TC_Tables_Buttons < Test::Unit::TestCase
181
- include Watir
182
-
183
- def setup
184
- uses_page "simple_table_buttons.html"
185
- end
186
-
187
- def test_simple_table_buttons
188
- table = browser.table(:index, 0)
189
-
190
- table[0][0].button(:index, 0).click
191
- assert(browser.text_field(:name,"confirmtext").verify_contains(/CLICK1/i))
192
- table[1][0].button(:index, 0).click
193
- assert(browser.text_field(:name,"confirmtext").verify_contains(/CLICK2/i))
194
-
195
- table[0][0].button(:id, 'b1').click
196
- assert(browser.text_field(:name,"confirmtext").verify_contains(/CLICK1/i))
197
-
198
- assert_raises(UnknownObjectException ) { table[0][0].button(:id,'b_missing').click }
199
-
200
- table[2][0].button(:index, 1).click
201
- assert(browser.text_field(:name,"confirmtext").verify_contains(/TOO/i))
202
-
203
- table[2][0].button(:value, "Click too").click
204
- assert(browser.text_field(:name,"confirmtext").verify_contains(/TOO/i))
205
-
206
- browser.table(:index, 0)[3][0].text_field(:index,0).set("123")
207
- assert(browser.text_field(:index,1).verify_contains("123"))
208
-
209
- # check when a cell contains 2 objects
210
-
211
- # if there were 2 different html objects in the same cell, some weird things happened ( button caption could change for example)
212
- assert_equal( 'Click ->' , browser.table(:index,0)[4][0].text_field(:index,0).value )
213
- browser.table(:index,0)[4][0].text_field(:index,0).click
214
- assert_equal( 'Click ->' , browser.table(:index,0)[4][0].text_field(:index,0).value )
215
-
216
- browser.table(:index,0)[4][0].button(:index,0).click
217
- assert_equal( '' , browser.table(:index,0)[4][0].text_field(:index,0).value )
218
- end
219
-
220
- def test_simple_table_gif
221
- table = browser.table(:index,1)
222
- assert_match(/1\.gif/, table[0][0].image(:index, 0).src)
223
- assert_match(/2\.gif/, table[0][1].image(:index, 0).src)
224
- assert_match(/3\.gif/, table[0][2].image(:index, 0).src)
225
-
226
- assert_match(/1\.gif/, table[2][0].image(:index, 0).src)
227
- assert_match(/2\.gif/, table[2][1].image(:index, 0).src)
228
- assert_match(/3\.gif/, table[2][2].image(:index, 0).src)
229
-
230
- table = browser.table(:index,2)
231
- assert_match(/1\.gif/, table[0][0].image(:index, 0).src)
232
- assert_match(/2\.gif/, table[0][0].image(:index, 1).src)
233
- assert_match(/3\.gif/, table[0][0].image(:index, 2).src)
234
-
235
- assert_match(/1\.gif/, table[2][0].image(:index, 0).src)
236
- assert_match(/2\.gif/, table[2][0].image(:index, 1).src)
237
- assert_match(/3\.gif/, table[2][0].image(:index, 2).src)
238
- end
239
-
240
- end
241
-
242
- class TC_Table_Columns < Test::Unit::TestCase
243
- include Watir::Exception
244
- def setup
245
- uses_page "simple_table_columns.html"
246
- end
247
-
248
- def test_get_columnvalues_single_column
249
- assert_equal(["R1C1", "R2C1", "R3C1"], browser.table(:index, 0).column_values(0))
250
- end
251
-
252
- def test_colspan
253
- assert_equal(2, browser.table(:index, 2)[1][0].colspan)
254
- assert_equal(1, browser.table(:index, 2)[0][0].colspan)
255
- assert_equal(3, browser.table(:index, 2)[3][0].colspan)
256
- end
257
-
258
- def test_get_columnvalues_multiple_column
259
- assert_equal(["R1C1", "R2C1", "R3C1"], browser.table(:index, 1).column_values(0))
260
- assert_equal(["R1C3", "R2C3", "R3C3"], browser.table(:index, 1).column_values(2))
261
- end
262
-
263
- tag_method :test_get_columnvalues_with_colspan, :fails_on_firefox
264
- def test_get_columnvalues_with_colspan
265
- assert_equal(["R1C1", "R2C1", "R3C1", "R4C1", "R5C1", "R6C2"], browser.table(:index, 2).column_values(0))
266
- (1..3).each{|x|assert_raises(UnknownCellException){browser.table(:index, 2).column_values(x)}}
267
- end
268
-
269
- def test_get_rowvalues_full_row
270
- assert_equal(["R1C1", "R1C2", "R1C3"], browser.table(:index, 2).row_values(0))
271
- end
272
-
273
- def test_get_rowvalues_with_colspan
274
- assert_equal(["R2C1", "R2C2"], browser.table(:index, 2).row_values(1))
275
- end
276
-
277
- def test_getrowvalues_with_rowspan
278
- assert_equal(["R5C1", "R5C2", "R5C3"], browser.table(:index, 2).row_values(4))
279
- assert_equal(["R6C2", "R6C3"], browser.table(:index, 2).row_values(5))
280
- end
281
- end
282
-
283
- class TC_Tables_Complex < Test::Unit::TestCase
284
- def setup
285
- uses_page "complex_table.html"
286
- end
287
-
288
- def test_complex_table_access
289
- table = browser.table(:index,0)
290
- assert_equal("subtable1 Row 1 Col1",table[0][0].table(:index,0)[0][0].text.strip)
291
- assert_equal("subtable1 Row 1 Col2",table[0][0].table(:index,0)[0][1].text.strip)
292
- assert_equal("subtable2 Row 1 Col2",table[1][0].table(:index,0)[0][1].text.strip)
293
- assert_equal("subtable2 Row 1 Col1",table[1][0].table(:index,0)[0][0].text.strip)
294
- end
295
-
296
- end