watir 1.5.6 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. data/{changes.rb → CHANGES} +12 -3
  2. data/bin/watir-console +7 -1
  3. data/lib/changes.rb +3 -0
  4. data/{license.rb → lib/license.rb} +2 -1
  5. data/{readme.rb → lib/readme.rb} +4 -6
  6. data/{watir → lib/watir}/AutoItX3.dll +0 -0
  7. data/{watir → lib/watir}/IEDialog/Release/IEDialog.dll +0 -0
  8. data/{watir → lib/watir}/WindowHelper.rb +1 -1
  9. data/{watir → lib/watir}/camel_case.rb +0 -0
  10. data/{watir → lib/watir}/clickJSDialog.rb +0 -0
  11. data/{watir → lib/watir}/close_all.rb +1 -1
  12. data/{watir → lib/watir}/collections.rb +1 -1
  13. data/{watir → lib/watir}/container.rb +17 -8
  14. data/{watir → lib/watir}/contrib/enabled_popup.rb +0 -0
  15. data/{watir → lib/watir}/contrib/ie-new-process.rb +0 -0
  16. data/{watir → lib/watir}/contrib/page_checker.rb +0 -0
  17. data/{watir → lib/watir}/contrib/visible.rb +2 -2
  18. data/{watir → lib/watir}/cookiemanager.rb +0 -0
  19. data/{watir → lib/watir}/datahandler.rb +0 -0
  20. data/{watir → lib/watir}/dialog.rb +1 -1
  21. data/{watir → lib/watir}/element.rb +3 -7
  22. data/{watir → lib/watir}/element_collections.rb +0 -0
  23. data/{watir → lib/watir}/form.rb +31 -11
  24. data/{watir → lib/watir}/frame.rb +0 -0
  25. data/{watir/ie.rb → lib/watir/ie-class.rb} +22 -22
  26. data/{watir → lib/watir}/ie-process.rb +0 -0
  27. data/{watir.rb → lib/watir/ie.rb} +11 -27
  28. data/{watir → lib/watir}/image.rb +0 -0
  29. data/{watir → lib/watir}/input_elements.rb +33 -44
  30. data/{watir → lib/watir}/irb-history.rb +0 -0
  31. data/{watir → lib/watir}/link.rb +0 -0
  32. data/{watir → lib/watir}/locator.rb +56 -43
  33. data/{watir → lib/watir}/logger.rb +0 -0
  34. data/{watir → lib/watir}/modal_dialog.rb +0 -0
  35. data/{watir → lib/watir}/non_control_elements.rb +0 -0
  36. data/{watir → lib/watir}/page-container.rb +2 -2
  37. data/{watir → lib/watir}/popup.rb +0 -0
  38. data/{watir → lib/watir}/process.rb +0 -0
  39. data/{watir → lib/watir}/screen_capture.rb +0 -0
  40. data/{watir → lib/watir}/setFileDialog.rb +0 -0
  41. data/{watir → lib/watir}/table.rb +7 -2
  42. data/{watir → lib/watir}/utils.rb +0 -0
  43. data/lib/watir/version.rb +5 -0
  44. data/{watir → lib/watir}/watir_simple.rb +3 -3
  45. data/{watir → lib/watir}/win32.rb +0 -0
  46. data/lib/watir/win32ole.rb +6 -0
  47. data/lib/watir/win32ole/win32ole.so +0 -0
  48. data/{watir → lib/watir}/winClicker.rb +0 -0
  49. data/unittests/buttons_xpath_test.rb +32 -32
  50. data/unittests/checkbox_test.rb +113 -99
  51. data/unittests/checkbox_xpath_test.rb +57 -57
  52. data/unittests/core_tests.rb +10 -7
  53. data/unittests/css_test.rb +12 -32
  54. data/unittests/defer_test.rb +22 -22
  55. data/unittests/dialog_test.rb +13 -13
  56. data/unittests/div2_xpath_test.rb +3 -3
  57. data/unittests/div_test.rb +23 -19
  58. data/unittests/div_xpath_test.rb +50 -50
  59. data/unittests/errorchecker_test.rb +7 -9
  60. data/unittests/filefield_test.rb +12 -11
  61. data/unittests/filefield_xpath_test.rb +10 -10
  62. data/unittests/form_test.rb +144 -151
  63. data/unittests/form_xpath_test.rb +99 -99
  64. data/unittests/frame_test.rb +46 -44
  65. data/unittests/google_form_test.rb +2 -2
  66. data/unittests/html/checkboxes1.html +19 -16
  67. data/unittests/html/forms3.html +2 -2
  68. data/unittests/html/wallofcheckboxes.html +1003 -0
  69. data/unittests/ie_exists_test.rb +5 -3
  70. data/unittests/ie_test.rb +2 -2
  71. data/unittests/images_test.rb +83 -82
  72. data/unittests/images_xpath_test.rb +40 -40
  73. data/unittests/iostring_test.rb +1 -1
  74. data/unittests/links_multi_test.rb +7 -8
  75. data/unittests/links_test.rb +73 -71
  76. data/unittests/links_xpath_test.rb +15 -15
  77. data/unittests/lists_test.rb +10 -10
  78. data/unittests/map_test.rb +65 -65
  79. data/unittests/minmax_test.rb +10 -9
  80. data/unittests/navigate_test.rb +19 -23
  81. data/unittests/nbsp_xpath_test.rb +2 -2
  82. data/unittests/non_core_tests.rb +5 -2
  83. data/unittests/other/WindowLogonExample.rb +2 -2
  84. data/unittests/other/WindowLogonExtra.rb +1 -1
  85. data/unittests/other/navigate_exception_test.rb +14 -3
  86. data/unittests/other/screen_capture_test.rb +3 -2
  87. data/unittests/other/testcase_method_order_test.rb +1 -1
  88. data/unittests/pagecontainstext_test.rb +17 -14
  89. data/unittests/parent_child_test.rb +11 -7
  90. data/unittests/perf_test.rb +20 -0
  91. data/unittests/popups_test.rb +13 -14
  92. data/unittests/pre_test.rb +30 -28
  93. data/unittests/radios_test.rb +128 -107
  94. data/unittests/radios_xpath_test.rb +47 -47
  95. data/unittests/security_setting_test.rb +24 -0
  96. data/unittests/selectbox_test.rb +65 -157
  97. data/unittests/selectbox_xpath_test.rb +51 -51
  98. data/unittests/setup.rb +52 -48
  99. data/unittests/speed_settings_test.rb +31 -20
  100. data/unittests/table_cell_using_xpath_test.rb +12 -12
  101. data/unittests/table_test.rb +30 -16
  102. data/unittests/table_xpath_test.rb +25 -25
  103. data/unittests/test_tests.rb +9 -0
  104. data/unittests/textarea_test.rb +33 -33
  105. data/unittests/textarea_xpath_test.rb +37 -37
  106. data/unittests/textfield_for_ch_char_test.rb +9 -9
  107. data/unittests/textfields_test.rb +103 -98
  108. data/unittests/textfields_xpath_test.rb +50 -50
  109. data/unittests/windows/attach_to_existing_window_test.rb +2 -2
  110. data/unittests/windows/attach_to_new_window_test.rb +10 -10
  111. data/unittests/windows/close_window_test.rb +2 -2
  112. data/unittests/windows/frame_links_test.rb +6 -6
  113. data/unittests/windows/ie-each_test.rb +1 -1
  114. data/unittests/windows/iedialog_test.rb +4 -5
  115. data/unittests/windows/js_events_test.rb +14 -14
  116. data/unittests/windows/jscriptExtraAlert.rb +2 -1
  117. data/unittests/windows/jscriptExtraConfirmCancel.rb +1 -1
  118. data/unittests/windows/jscriptExtraConfirmOk.rb +1 -1
  119. data/unittests/windows/jscriptPushButton.rb +2 -1
  120. data/unittests/windows/jscript_test.rb +7 -7
  121. data/unittests/windows/modal_dialog_test.rb +28 -29
  122. data/unittests/windows/{new.rb → new_test.rb} +1 -1
  123. data/unittests/windows/open_close_test.rb +4 -7
  124. data/unittests/windows/send_keys_test.rb +11 -11
  125. data/unittests/xpath_tests.rb +4 -3
  126. metadata +82 -58
  127. data/unittests/buttons_test.rb +0 -107
  128. data/watir/assertions.rb +0 -44
  129. data/watir/exceptions.rb +0 -42
  130. data/watir/testcase.rb +0 -58
  131. data/watir/waiter.rb +0 -88
  132. data/watir/win32ole.rb +0 -8
  133. data/watir/win32ole/win32ole.so +0 -0
@@ -1,7 +1,7 @@
1
1
  # feature tests for Select Boxes
2
- # revision: $Revision: 1348 $
2
+ # revision: $Revision: 1544 $
3
3
 
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
5
  require 'unittests/setup'
6
6
 
7
7
  class TC_Selectbox_XPath < Test::Unit::TestCase
@@ -12,102 +12,102 @@ class TC_Selectbox_XPath < Test::Unit::TestCase
12
12
  end
13
13
 
14
14
  def test_textBox_Exists
15
- assert($ie.select_list(:xpath, "//select[@name='sel1']/").exists?)
16
- assert(!$ie.select_list(:xpath, "//select[@name='missing']/").exists?)
17
- assert(!$ie.select_list(:xpath, "//select[@id='missing']/").exists?)
15
+ assert(browser.select_list(:xpath, "//select[@name='sel1']/").exists?)
16
+ assert_false(browser.select_list(:xpath, "//select[@name='missing']/").exists?)
17
+ assert_false(browser.select_list(:xpath, "//select[@id='missing']/").exists?)
18
18
  end
19
19
 
20
20
  def test_select_list_enabled
21
- assert($ie.select_list(:xpath, "//select[@name='sel1']/").enabled?)
22
- assert_raises(UnknownObjectException) { $ie.select_list(:xpath, "//select[@name='NoName']/").enabled? }
21
+ assert(browser.select_list(:xpath, "//select[@name='sel1']/").enabled?)
22
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").enabled? }
23
23
  end
24
24
 
25
25
  def test_select_list_getAllContents
26
- assert_raises(UnknownObjectException) { $ie.select_list(:xpath, "//select[@name='NoName']/").getAllContents }
26
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").getAllContents }
27
27
  assert_equal( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
28
- $ie.select_list(:xpath, "//select[@name='sel1']/").getAllContents)
28
+ browser.select_list(:xpath, "//select[@name='sel1']/").getAllContents)
29
29
  end
30
30
 
31
31
  def test_select_list_getSelectedItems
32
- assert_raises(UnknownObjectException) { $ie.select_list(:xpath, "//select[@name='NoName']/").getSelectedItems }
32
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").getSelectedItems }
33
33
  assert_equal( ["Option 3" ] ,
34
- $ie.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
34
+ browser.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
35
35
  assert_equal( ["Option 3" , "Option 6" ] ,
36
- $ie.select_list(:xpath, "//select[@name='sel2']/").getSelectedItems)
36
+ browser.select_list(:xpath, "//select[@name='sel2']/").getSelectedItems)
37
37
  end
38
38
 
39
39
  def test_clearSelection
40
- assert_raises(UnknownObjectException) { $ie.select_list(:xpath, "//select[@name='NoName']/").clearSelection }
41
- $ie.select_list(:xpath, "//select[@name='sel1']/").clearSelection
40
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").clearSelection }
41
+ browser.select_list(:xpath, "//select[@name='sel1']/").clearSelection
42
42
 
43
43
  # the box sel1 has no ability to have a de-selected item
44
- assert_equal( ["Option 3" ] , $ie.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
44
+ assert_equal( ["Option 3" ] , browser.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
45
45
 
46
- $ie.select_list(:xpath, "//select[@name='sel2']/").clearSelection
47
- assert_equal( [ ] , $ie.select_list(:xpath, "//select[@name='sel2']/").getSelectedItems)
46
+ browser.select_list(:xpath, "//select[@name='sel2']/").clearSelection
47
+ assert_equal( [ ] , browser.select_list(:xpath, "//select[@name='sel2']/").getSelectedItems)
48
48
  end
49
49
 
50
50
  def test_select_list_select
51
- assert_raises(UnknownObjectException) { $ie.select_list(:xpath, "//select[@name='NoName']/").getSelectedItems }
52
- assert_raises(NoValueFoundException) { $ie.select_list(:xpath, "//select[@name='sel1']/").select("missing item") }
53
- assert_raises(NoValueFoundException) { $ie.select_list(:xpath, "//select[@name='sel1']/").select(/missing/) }
51
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").getSelectedItems }
52
+ assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']/").select("missing item") }
53
+ assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']/").select(/missing/) }
54
54
 
55
55
  # the select method keeps any currently selected items - use the clear selectcion method first
56
- $ie.select_list(:xpath, "//select[@name='sel1']/").clearSelection
57
- $ie.select_list(:xpath, "//select[@name='sel1']/").select("Option 1")
58
- assert_equal( ["Option 1" ] , $ie.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
56
+ browser.select_list(:xpath, "//select[@name='sel1']/").clearSelection
57
+ browser.select_list(:xpath, "//select[@name='sel1']/").select("Option 1")
58
+ assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
59
59
 
60
- $ie.select_list(:xpath, "//select[@name='sel1']/").clearSelection
61
- $ie.select_list(:xpath, "//select[@name='sel1']/").select(/2/)
62
- assert_equal( ["Option 2" ] , $ie.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
60
+ browser.select_list(:xpath, "//select[@name='sel1']/").clearSelection
61
+ browser.select_list(:xpath, "//select[@name='sel1']/").select(/2/)
62
+ assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
63
63
 
64
- $ie.select_list(:xpath, "//select[@name='sel2']/").clearSelection
65
- $ie.select_list(:xpath, "//select[@name='sel2']/").select( /2/ )
66
- $ie.select_list(:xpath, "//select[@name='sel2']/").select( /4/ )
64
+ browser.select_list(:xpath, "//select[@name='sel2']/").clearSelection
65
+ browser.select_list(:xpath, "//select[@name='sel2']/").select( /2/ )
66
+ browser.select_list(:xpath, "//select[@name='sel2']/").select( /4/ )
67
67
  assert_equal( ["Option 2" , "Option 4" ] ,
68
- $ie.select_list(:xpath, "//select[@name='sel2']/").getSelectedItems)
68
+ browser.select_list(:xpath, "//select[@name='sel2']/").getSelectedItems)
69
69
 
70
70
  # these are to test the onchange event
71
71
  # the event shouldnt get fired, as this is the selected item
72
- $ie.select_list(:xpath, "//select[@name='sel3']/").select( /3/ )
73
- assert(!$ie.text.include?("Pass") )
72
+ browser.select_list(:xpath, "//select[@name='sel3']/").select( /3/ )
73
+ assert_false(browser.text.include?("Pass") )
74
74
  end
75
75
 
76
76
  def test_select_list_select2
77
77
  # the event should get fired
78
- $ie.select_list(:xpath, "//select[@name='sel3']/").select( /2/ )
79
- assert($ie.text.include?("PASS") )
78
+ browser.select_list(:xpath, "//select[@name='sel3']/").select( /2/ )
79
+ assert(browser.text.include?("PASS") )
80
80
  end
81
81
 
82
82
  def test_select_list_select_using_value
83
- assert_raises(UnknownObjectException) { $ie.select_list(:xpath, "//select[@name='NoName']/").getSelectedItems }
84
- assert_raises(NoValueFoundException) { $ie.select_list(:xpath, "//select[@name='sel1']/").select_value("missing item") }
85
- assert_raises(NoValueFoundException) { $ie.select_list(:xpath, "//select[@name='sel1']/").select_value(/missing/) }
83
+ assert_raises(UnknownObjectException) { browser.select_list(:xpath, "//select[@name='NoName']/").getSelectedItems }
84
+ assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']/").select_value("missing item") }
85
+ assert_raises(NoValueFoundException) { browser.select_list(:xpath, "//select[@name='sel1']/").select_value(/missing/) }
86
86
 
87
87
  # the select method keeps any currently selected items - use the clear selectcion method first
88
- $ie.select_list(:xpath, "//select[@name='sel1']/").clearSelection
89
- $ie.select_list(:xpath, "//select[@name='sel1']/").select_value("o1")
90
- assert_equal( ["Option 1" ] , $ie.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
88
+ browser.select_list(:xpath, "//select[@name='sel1']/").clearSelection
89
+ browser.select_list(:xpath, "//select[@name='sel1']/").select_value("o1")
90
+ assert_equal( ["Option 1" ] , browser.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
91
91
 
92
- $ie.select_list(:xpath, "//select[@name='sel1']/").clearSelection
93
- $ie.select_list(:xpath, "//select[@name='sel1']/").select_value(/2/)
94
- assert_equal( ["Option 2" ] , $ie.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
92
+ browser.select_list(:xpath, "//select[@name='sel1']/").clearSelection
93
+ browser.select_list(:xpath, "//select[@name='sel1']/").select_value(/2/)
94
+ assert_equal( ["Option 2" ] , browser.select_list(:xpath, "//select[@name='sel1']/").getSelectedItems)
95
95
 
96
- $ie.select_list(:xpath, "//select[@name='sel2']/").clearSelection
97
- $ie.select_list(:xpath, "//select[@name='sel2']/").select( /2/ )
98
- $ie.select_list(:xpath, "//select[@name='sel2']/").select( /4/ )
99
- assert_equal( ["Option 2" , "Option 4" ] , $ie.select_list(:xpath, "//select[@name='sel2']/").getSelectedItems)
96
+ browser.select_list(:xpath, "//select[@name='sel2']/").clearSelection
97
+ browser.select_list(:xpath, "//select[@name='sel2']/").select( /2/ )
98
+ browser.select_list(:xpath, "//select[@name='sel2']/").select( /4/ )
99
+ assert_equal( ["Option 2" , "Option 4" ] , browser.select_list(:xpath, "//select[@name='sel2']/").getSelectedItems)
100
100
 
101
101
  # these are to test the onchange event
102
102
  # the event shouldnt get fired, as this is the selected item
103
- $ie.select_list(:xpath, "//select[@name='sel3']/").select_value( /3/ )
104
- assert(!$ie.text.include?("Pass") )
103
+ browser.select_list(:xpath, "//select[@name='sel3']/").select_value( /3/ )
104
+ assert_false(browser.text.include?("Pass") )
105
105
  end
106
106
 
107
107
  def test_select_list_select_using_value2
108
108
  # the event should get fired
109
- $ie.select_list(:xpath, "//select[@name='sel3']/").select_value( /2/ )
110
- assert($ie.text.include?("PASS") )
109
+ browser.select_list(:xpath, "//select[@name='sel3']/").select_value( /2/ )
110
+ assert(browser.text.include?("PASS") )
111
111
  end
112
112
 
113
113
  end
@@ -1,35 +1,62 @@
1
- # libraries used by feature tests
2
- require 'watir'
3
- END {$ie.close if $ie && $ie.exists?; Watir::IE.quit} # close ie at completion of the tests
1
+ # watir/unittests/setup.rb
2
+ $SETUP_LOADED = true
4
3
 
5
- require 'test/unit'
4
+ $myDir = File.expand_path(File.dirname(__FILE__))
5
+
6
+ def append_to_load_path path
7
+ $LOAD_PATH.unshift File.expand_path(path)
8
+ end
9
+
10
+ # use local development versions of watir, firewatir, watir-common if available
11
+ topdir = File.join(File.dirname(__FILE__), '..')
12
+ $firewatir_dev_lib = File.join(topdir, '..', 'firewatir', 'lib')
13
+ $watir_dev_lib = File.join(topdir, 'lib')
14
+ libs = []
15
+ libs << File.join(topdir, '..', 'watir-common', 'lib')
16
+ libs << File.join(topdir, '..', 'watir-common') # for the unit tests
17
+ libs.each { |lib| append_to_load_path(lib) }
18
+
19
+ require 'watir/browser'
20
+ Watir::Browser.default = 'ie'
21
+ require 'unittests/setup/lib'
6
22
  require 'watir/testcase'
7
23
 
8
- # rename goto_page to be goto_page
24
+ # Standard Tags
25
+ # :must_be_visible
26
+ # :creates_windows
27
+ # :unreliable (test fails intermittently)
9
28
 
10
- # Better would be to add this to a module that was included in all the tests.
11
- class Test::Unit::TestCase
12
- # navigate the browser to the specified page in unittests/html
13
- def goto_page page
14
- new_url = $htmlRoot + page
15
- browser.goto new_url
16
- end
17
- # navigate the browser to the specified page in unittests/html IF the browser is not already on that page.
18
- def uses_page page
19
- new_url = $htmlRoot + page
20
- browser.goto new_url unless browser.url == new_url
21
- end
22
- def browser
23
- $ie
24
- end
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
+ tiptopdir = File.join topdir, '..'
36
+ commondir = File.join topdir, '..', 'watir-common'
37
+ append_to_load_path tiptopdir
38
+ $all_tests = []
39
+ Dir.chdir tiptopdir do
40
+ $all_tests += Dir["watir/unittests/*_test.rb"]
41
+ end
42
+ Dir.chdir tiptopdir do
43
+ $all_tests += Dir["watir-common/unittests/*_test.rb"]
25
44
  end
26
45
 
27
- topdir = File.join(File.dirname(__FILE__), '..')
28
- Dir.chdir topdir do
29
- $all_tests = Dir["unittests/*_test.rb"]
30
- $xpath_tests = Dir["unittests/*_xpath_test.rb"]
46
+ # These tests won't load unless Watir is in the path
47
+ $watir_only_tests = [
48
+ "images_xpath_test.rb",
49
+ "images_test.rb",
50
+ "dialog_test.rb",
51
+ "ie_test.rb"
52
+ ].map {|file| "watir/unittests/#{file}"}
53
+
54
+ if Watir::UnitTest.options[:browser] != 'ie'
55
+ $all_tests -= $watir_only_tests
31
56
  end
32
57
 
58
+
59
+ # not in all tests!
33
60
  $window_tests =
34
61
  [
35
62
  'attach_to_existing_window', # could actually run robustly as part of the core suite!
@@ -41,31 +68,8 @@ $window_tests =
41
68
  'js_events', # is always visible
42
69
  'jscript',
43
70
  'modal_dialog', # modal is visible
44
- #new (named oddly)
71
+ #new
45
72
  'open_close',
46
73
  'send_keys', # visible
47
74
  ].collect {|x| "unittests/windows/#{x}_test.rb"}
48
75
 
49
- $non_core_tests =
50
- ['popups', # has problems when run in a suite (is ok when run alone);
51
- # must be visible
52
- # will be revised to use autoit
53
- # takes 15 seconds to run
54
- 'images', # save file must must be visible
55
- # 'screen_capture', # is always visible; takes 25 seconds
56
- 'filefield', # is always visible; takes 40 seconds
57
- 'minmax', # becomes visible
58
- 'dialog' # visible
59
- ].collect {|x| "unittests/#{x}_test.rb"}
60
-
61
- $core_tests = $all_tests - $non_core_tests - $window_tests - $xpath_tests
62
-
63
- $ie = Watir::IE.new
64
- $ie.speed = :fast
65
-
66
- $myDir = File.expand_path(File.dirname(__FILE__))
67
- $myDir.sub!( %r{/cygdrive/(\w)/}, '\1:/' ) # convert from cygwin to dos
68
- # if you run the unit tests from a local file system use this line
69
- $htmlRoot = "file:///#{$myDir}/html/"
70
- # if you run the unit tests from a web server use this line
71
- # $htmlRoot = "http://localhost:8080/watir/html/"
@@ -1,55 +1,66 @@
1
1
  # tests for ability to set defaults for Watir
2
- # revision: $Revision: 1319 $
3
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
4
- require 'test/unit'
5
- require 'watir'
2
+ # revision: $Revision: 1552 $
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
4
+ require 'unittests/setup'
6
5
 
7
6
  class TC_instance_options < Test::Unit::TestCase
7
+ tags :fails_on_firefox
8
+
9
+ def setup
10
+ @ie4 = Watir::IE.new
11
+ end
8
12
 
9
13
  def test_using_default
10
- @ie1 = Watir::IE.new
11
- @ie1.speed = :fast
12
- assert_equal(:fast, @ie1.speed)
13
- @ie1.speed = :slow
14
- assert_equal(:slow, @ie1.speed)
15
- assert_raise(ArgumentError){@ie1.speed = :fubar}
14
+ @ie4.speed = :fast
15
+ assert_equal(:fast, @ie4.speed)
16
+ @ie4.speed = :slow
17
+ assert_equal(:slow, @ie4.speed)
18
+ @ie4.speed = :zippy
19
+ assert_equal(:zippy, @ie4.speed)
20
+
21
+ assert_raise(ArgumentError){@ie4.speed = :fubar}
16
22
  end
17
23
 
18
24
  def teardown
19
- @ie1.close if @ie1
25
+ @ie4.close if @ie4.exists?
20
26
  end
21
27
  end
22
28
 
23
29
  class TC_class_options < Test::Unit::TestCase
30
+ tags :fails_on_firefox
24
31
  include Watir
25
32
  @@hide_ie = $HIDE_IE
26
33
  def setup
27
- @previous = IE.defaults
34
+ @previous = IE.options
28
35
  end
29
36
  def test_class_defaults
30
- assert_equal({:speed => :slow, :visible => ! @@hide_ie}, IE.defaults)
37
+ assert_equal({:speed => IE.speed, :visible => IE.visible}, IE.options)
31
38
  end
32
39
  def test_change_defaults
33
- IE.defaults = {:speed => :fast}
40
+ IE.set_options(:speed => :fast)
34
41
  assert_equal(:fast, IE.speed)
35
- IE.defaults = {:visible => false}
42
+ IE.set_options(:visible => false)
36
43
  assert_equal(false, IE.visible)
37
- IE.defaults = {:speed => :slow}
44
+ IE.set_options(:speed => :slow)
38
45
  assert_equal(:slow, IE.speed)
39
- IE.defaults = {:visible => true}
46
+ IE.set_options(:visible => true)
40
47
  assert_equal(true, IE.visible)
41
48
  end
42
49
  def test_defaults_affect_on_instance
43
- IE.defaults = {:speed => :fast}
50
+ IE.set_options(:speed => :fast)
44
51
  @ie1 = IE.new
45
52
  assert_equal(:fast, @ie1.speed)
46
- IE.defaults = {:speed => :slow}
53
+ IE.set_options(:speed => :slow)
47
54
  @ie2 = IE.new
48
55
  assert_equal(:slow, @ie2.speed)
56
+ IE.set_options(:speed => :zippy)
57
+ @ie3 = IE.new
58
+ assert_equal(:zippy, @ie3.speed)
49
59
  end
50
60
  def teardown
51
- IE.defaults = @previous
61
+ IE.set_options @previous
52
62
  @ie1.close if @ie1
53
63
  @ie2.close if @ie2
64
+ @ie3.close if @ie3
54
65
  end
55
66
  end
@@ -1,7 +1,7 @@
1
1
  # feature tests for xpath table cells
2
- # revision: $Revision: 1348 $
2
+ # revision: $Revision: 1544 $
3
3
 
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
5
5
  require 'unittests/setup'
6
6
 
7
7
  class TC_TableCell_XPath < Test::Unit::TestCase
@@ -12,23 +12,23 @@ class TC_TableCell_XPath < Test::Unit::TestCase
12
12
 
13
13
  def testCellExists
14
14
  # There is no <image> with @src='rectangle.jpg'. So image will not be there.
15
- assert(! $ie.cell(:xpath , "//img[@src='images\/rectangle.jpg']/../").exists? )
15
+ assert_false( browser.cell(:xpath , "//img[@src='images\/rectangle.jpg']/../").exists? )
16
16
  # Select the parent element of image with src='square.jpg' which is a tablecell.
17
- assert( $ie.cell(:xpath , "//img[@src='images\/square.jpg']/../").exists? )
18
- assert( $ie.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").exists? )
17
+ assert( browser.cell(:xpath , "//img[@src='images\/square.jpg']/../").exists? )
18
+ assert( browser.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").exists? )
19
19
  puts "Selected table cell with text 'Table Cell with image of triangle.'"
20
- puts $ie.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").to_s
20
+ puts browser.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").to_s
21
21
  end
22
22
 
23
23
  def testCell_properties
24
- assert_equal(1 , $ie.cell(:xpath , "//img[@src='images\/square.jpg']/../").colspan)
25
- assert_equal(2 , $ie.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").colspan)
26
- assert_equal(3 , $ie.cell(:xpath , "//img[@src='images\/circle.jpg']/../").colspan)
27
- assert_equal(4 , $ie.cell(:xpath , "//img[@src='images\/button.jpg']/../").colspan)
24
+ assert_equal(1 , browser.cell(:xpath , "//img[@src='images\/square.jpg']/../").colspan)
25
+ assert_equal(2 , browser.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").colspan)
26
+ assert_equal(3 , browser.cell(:xpath , "//img[@src='images\/circle.jpg']/../").colspan)
27
+ assert_equal(4 , browser.cell(:xpath , "//img[@src='images\/button.jpg']/../").colspan)
28
28
 
29
29
  # to string tests -- output should be verified!
30
- puts $ie.cell(:xpath , "//img[@src='images\/square.jpg']/../").to_s
31
- puts $ie.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").to_s
30
+ puts browser.cell(:xpath , "//img[@src='images\/square.jpg']/../").to_s
31
+ puts browser.cell(:xpath , "//img[@src='images\/triangle.jpg']/../").to_s
32
32
  end
33
33
 
34
34
  end
@@ -1,9 +1,9 @@
1
1
  # feature tests for Tables
2
- # revision: $Revision: 1348 $
2
+ # revision: $Revision: 1542 $
3
3
 
4
4
  # Why do so many of these tests call "strip"? A distinct smell...
5
5
 
6
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
6
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
7
7
  require 'unittests/setup'
8
8
 
9
9
  class TC_Tables < Test::Unit::TestCase
@@ -27,6 +27,7 @@ class TC_Tables < Test::Unit::TestCase
27
27
  assert !browser.table(:index, 33).exists?
28
28
  end
29
29
 
30
+ tag_method :test_row_count_exceptions, :fails_on_firefox
30
31
  def test_row_count_exceptions
31
32
  assert_raises UnknownObjectException do
32
33
  browser.table(:id, 'missingTable').row_count
@@ -56,6 +57,14 @@ class TC_Tables < Test::Unit::TestCase
56
57
  assert_equal(2, row.column_count)
57
58
  end
58
59
 
60
+ tag_method :test_row_counts, :fails_on_firefox
61
+ def test_row_counts
62
+ table = browser.table(:id => 't2')
63
+ assert_equal(3, table.row_count)
64
+ assert_equal(2, table.row_count_excluding_nested_tables)
65
+ end
66
+
67
+ tag_method :test_dynamic_tables, :fails_on_firefox
59
68
  def test_dynamic_tables
60
69
  @reload_page = true
61
70
  t = browser.table(:id, 't1')
@@ -108,6 +117,7 @@ class TC_Tables < Test::Unit::TestCase
108
117
  assert_equal('Row 2 Col1', browser.row(:id, 'row1')[1].to_s.strip)
109
118
  end
110
119
 
120
+ tag_method :test_row_in_table, :fails_on_firefox
111
121
  def test_row_in_table
112
122
  assert_equal 'Row 2 Col1 Row 2 Col2',
113
123
  browser.table(:id, 't1').row(:id, 'row1').text
@@ -143,12 +153,14 @@ class TC_Tables < Test::Unit::TestCase
143
153
  end
144
154
  end
145
155
 
156
+ tag_method :test_cell_collection, :fails_on_firefox
146
157
  def test_cell_collection
147
158
  t = browser.table(:index,1)
148
159
  contents = t.cells.collect {|c| c.text}
149
160
  assert_equal(["Row 1 Col1","Row 1 Col2","Row 2 Col1","Row 2 Col2"], contents)
150
161
  end
151
-
162
+
163
+ tag_method :test_table_body, :fails_on_firefox
152
164
  def test_table_body
153
165
  assert_equal(1, browser.table(:index, 1).bodies.length)
154
166
  assert_equal(3, browser.table(:id, 'body_test').bodies.length)
@@ -216,25 +228,25 @@ class TC_Tables_Buttons < Test::Unit::TestCase
216
228
  end
217
229
 
218
230
  def test_simple_table_buttons
219
- table = browser.table(:index,1)
231
+ table = browser.table(:index, 1)
220
232
 
221
- table[1][1].button(:index,1).click
222
- assert(browser.textField(:name,"confirmtext").verify_contains(/CLICK1/i))
223
- table[2][1].button(:index,1).click
224
- assert(browser.textField(:name,"confirmtext").verify_contains(/CLICK2/i))
233
+ table[1][1].button(:index, 1).click
234
+ assert(browser.text_field(:name,"confirmtext").verify_contains(/CLICK1/i))
235
+ table[2][1].button(:index, 1).click
236
+ assert(browser.text_field(:name,"confirmtext").verify_contains(/CLICK2/i))
225
237
 
226
- table[1][1].button(:id,'b1').click
227
- assert(browser.textField(:name,"confirmtext").verify_contains(/CLICK1/i))
238
+ table[1][1].button(:id, 'b1').click
239
+ assert(browser.text_field(:name,"confirmtext").verify_contains(/CLICK1/i))
228
240
 
229
241
  assert_raises(UnknownObjectException ) { table[1][1].button(:id,'b_missing').click }
230
242
 
231
- table[3][1].button(:index,2).click
232
- assert(browser.textField(:name,"confirmtext").verify_contains(/TOO/i))
243
+ table[3][1].button(:index, 2).click
244
+ assert(browser.text_field(:name,"confirmtext").verify_contains(/TOO/i))
233
245
 
234
- table[3][1].button(:value ,"Click too").click
235
- assert(browser.textField(:name,"confirmtext").verify_contains(/TOO/i))
246
+ table[3][1].button(:value, "Click too").click
247
+ assert(browser.text_field(:name,"confirmtext").verify_contains(/TOO/i))
236
248
 
237
- browser.table(:index,1)[4][1].text_field(:index,1).set("123")
249
+ browser.table(:index, 1)[4][1].text_field(:index,1).set("123")
238
250
  assert(browser.text_field(:index,2).verify_contains("123"))
239
251
 
240
252
  # check when a cell contains 2 objects
@@ -284,12 +296,13 @@ class TC_Tables_Buttons < Test::Unit::TestCase
284
296
  end
285
297
  end
286
298
 
299
+ tag_method :test_table_from_element, :fails_on_firefox
287
300
  def test_table_from_element
288
301
  button = browser.button(:id, "b1")
289
302
  table = Watir::Table.create_from_element(browser, button)
290
303
 
291
304
  table[2][1].button(:index, 1).click
292
- assert(browser.textField(:name, "confirmtext").verify_contains(/CLICK2/i))
305
+ assert(browser.text_field(:name, "confirmtext").verify_contains(/CLICK2/i))
293
306
  end
294
307
  end
295
308
 
@@ -314,6 +327,7 @@ class TC_Table_Columns < Test::Unit::TestCase
314
327
  assert_equal(["R1C3", "R2C3", "R3C3"], browser.table(:index, 2).column_values(3))
315
328
  end
316
329
 
330
+ tag_method :test_get_columnvalues_with_colspan, :fails_on_firefox
317
331
  def test_get_columnvalues_with_colspan
318
332
  assert_equal(["R1C1", "R2C1", "R3C1", "R4C1", "R5C1", "R6C2"], browser.table(:index, 3).column_values(1))
319
333
  (2..4).each{|x|assert_raises(UnknownCellException){browser.table(:index, 3).column_values(x)}}