watir 1.4.1 → 1.5.2

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 (151) hide show
  1. data/bin/watir-console +1 -0
  2. data/changes.rb +119 -0
  3. data/license.rb +37 -0
  4. data/readme.rb +55 -120
  5. data/unittests/buttons_test.rb +107 -104
  6. data/unittests/buttons_xpath_test.rb +69 -0
  7. data/unittests/checkbox_test.rb +154 -141
  8. data/unittests/checkbox_xpath_test.rb +107 -0
  9. data/unittests/core_tests.rb +6 -2
  10. data/unittests/css_test.rb +50 -50
  11. data/unittests/defer_test.rb +47 -0
  12. data/unittests/dialog_test.rb +78 -0
  13. data/unittests/div2_xpath_test.rb +22 -0
  14. data/unittests/div_test.rb +159 -159
  15. data/unittests/div_xpath_test.rb +96 -0
  16. data/unittests/errorchecker_test.rb +22 -22
  17. data/unittests/filefield_test.rb +30 -23
  18. data/unittests/filefield_xpath_test.rb +35 -0
  19. data/unittests/form_test.rb +250 -229
  20. data/unittests/form_xpath_test.rb +253 -0
  21. data/unittests/frame_test.rb +123 -108
  22. data/unittests/google_form_test.rb +17 -0
  23. data/unittests/html/JavascriptClick.html +39 -0
  24. data/unittests/html/buttons1.html +3 -2
  25. data/unittests/html/checkboxes1.html +32 -14
  26. data/unittests/html/complex_table.html +1 -1
  27. data/unittests/html/depot_store.html +59 -0
  28. data/unittests/html/div.html +3 -21
  29. data/unittests/html/div_xml.html +21 -0
  30. data/unittests/html/fileupload.html +2 -2
  31. data/unittests/html/forms2.html +3 -3
  32. data/unittests/html/forms3.html +2 -2
  33. data/unittests/html/frame_links.html +2 -2
  34. data/unittests/html/google_india.html +119 -0
  35. data/unittests/html/iframeTest.html +2 -2
  36. data/unittests/html/images/map.GIF +0 -0
  37. data/unittests/html/images/map2.gif +0 -0
  38. data/unittests/html/images1.html +17 -2
  39. data/unittests/html/javascriptevents.html +3 -7
  40. data/unittests/html/links1.html +9 -8
  41. data/unittests/html/links_multi.html +14 -0
  42. data/unittests/html/list_matters.html +720 -0
  43. data/unittests/html/lists.html +18 -0
  44. data/unittests/html/map_test.html +31 -0
  45. data/unittests/html/modal_dialog.html +10 -0
  46. data/unittests/html/modal_dialog_launcher.html +12 -0
  47. data/unittests/html/new_browser.html +17 -0
  48. data/unittests/html/pass.html +3 -0
  49. data/unittests/html/popups1.html +1 -1
  50. data/unittests/html/pre.html +28 -0
  51. data/unittests/html/radioButtons1.html +6 -5
  52. data/unittests/html/selectboxes1.html +12 -11
  53. data/unittests/html/simple_table.html +1 -1
  54. data/unittests/html/simple_table_columns.html +1 -1
  55. data/unittests/html/table1.html +1 -1
  56. data/unittests/html/tableCell_using_xpath.html +19 -0
  57. data/unittests/html/textfields1.html +6 -4
  58. data/unittests/html/xpath_nbsp.html +12 -0
  59. data/unittests/ie_exists_test.rb +32 -0
  60. data/unittests/ie_mock.rb +78 -79
  61. data/unittests/ie_test.rb +39 -39
  62. data/unittests/images_test.rb +132 -155
  63. data/unittests/images_xpath_test.rb +91 -0
  64. data/unittests/links_multi_test.rb +36 -0
  65. data/unittests/links_test.rb +158 -152
  66. data/unittests/links_xpath_test.rb +40 -0
  67. data/unittests/lists_test.rb +29 -0
  68. data/unittests/map_test.rb +99 -0
  69. data/unittests/minmax_test.rb +23 -23
  70. data/unittests/navigate_test.rb +43 -51
  71. data/unittests/nbsp_xpath_test.rb +18 -0
  72. data/unittests/other/WindowLogonExample.rb +28 -0
  73. data/unittests/{WindowLogonExtra.rb → other/WindowLogonExtra.rb} +0 -0
  74. data/unittests/{all_tests_concurrent.rb → other/all_tests_concurrent.rb} +23 -23
  75. data/unittests/other/navigate_exception_test.rb +14 -0
  76. data/unittests/other/rexml_unit_test.rb +24 -0
  77. data/unittests/other/testcase_method_order_test.rb +36 -0
  78. data/unittests/other/testcase_verify_test.rb +25 -0
  79. data/unittests/other/wait_until_test.rb +99 -0
  80. data/unittests/pagecontainstext_test.rb +56 -37
  81. data/unittests/parent_child_test.rb +55 -0
  82. data/unittests/popups_test.rb +37 -37
  83. data/unittests/pre_test.rb +52 -0
  84. data/unittests/radios_test.rb +186 -155
  85. data/unittests/radios_xpath_test.rb +101 -0
  86. data/unittests/screen_capture_test.rb +41 -41
  87. data/unittests/selectbox_test.rb +223 -181
  88. data/unittests/selectbox_xpath_test.rb +113 -0
  89. data/unittests/setup.rb +29 -25
  90. data/unittests/speed_settings_test.rb +22 -0
  91. data/unittests/table_cell_using_xpath_test.rb +40 -0
  92. data/unittests/table_test.rb +315 -284
  93. data/unittests/table_xpath_test.rb +114 -0
  94. data/unittests/textarea_test.rb +81 -0
  95. data/unittests/textarea_xpath_test.rb +82 -0
  96. data/unittests/textfields_test.rb +205 -229
  97. data/unittests/textfields_xpath_test.rb +111 -0
  98. data/unittests/window_tests.rb +7 -0
  99. data/unittests/windows/attach_to_existing_window_test.rb +52 -0
  100. data/unittests/windows/attach_to_new_window_test.rb +82 -0
  101. data/unittests/windows/close_window_test.rb +22 -0
  102. data/unittests/windows/frame_links_test.rb +25 -0
  103. data/unittests/windows/ie-each_test.rb +48 -0
  104. data/unittests/windows/iedialog_test.rb +55 -0
  105. data/unittests/windows/js_events_test.rb +57 -0
  106. data/unittests/windows/jscriptExtraAlert.rb +6 -0
  107. data/unittests/windows/jscriptExtraConfirmCancel.rb +7 -0
  108. data/unittests/windows/jscriptExtraConfirmOk.rb +7 -0
  109. data/unittests/{jscriptPushButton.rb → windows/jscriptPushButton.rb} +1 -1
  110. data/unittests/windows/jscript_test.rb +64 -0
  111. data/unittests/windows/modal_dialog_test.rb +127 -0
  112. data/unittests/windows/new.rb +56 -0
  113. data/unittests/windows/open_close_test.rb +22 -0
  114. data/unittests/windows/send_keys_test.rb +34 -0
  115. data/unittests/xpath_tests.rb +10 -0
  116. data/watir.rb +4344 -3565
  117. data/watir/IEDialog/Release/IEDialog.dll +0 -0
  118. data/watir/WindowHelper.rb +13 -11
  119. data/watir/assertions.rb +36 -0
  120. data/watir/camel_case.rb +14 -5
  121. data/watir/close_all.rb +38 -0
  122. data/watir/contrib/enabled_popup.rb +21 -0
  123. data/watir/contrib/ie-new-process.rb +27 -0
  124. data/watir/contrib/page_checker.rb +29 -0
  125. data/watir/contrib/visible.rb +47 -0
  126. data/watir/cookiemanager.rb +4 -4
  127. data/watir/datahandler.rb +107 -0
  128. data/watir/dialog.rb +46 -0
  129. data/watir/elements.rb +65 -0
  130. data/watir/exceptions.rb +18 -36
  131. data/watir/ie-process.rb +40 -0
  132. data/watir/irb-history.rb +31 -0
  133. data/watir/process.rb +20 -0
  134. data/watir/testUnitAddons.rb +3 -42
  135. data/watir/testcase.rb +58 -0
  136. data/watir/utils.rb +20 -0
  137. data/watir/waiter.rb +88 -0
  138. data/watir/watir_simple.rb +4 -4
  139. data/watir/win32ole.rb +8 -0
  140. data/watir/win32ole/win32ole.so +0 -0
  141. data/watir/winClicker.rb +374 -400
  142. metadata +209 -128
  143. data/unittests/WindowLogonExample.rb +0 -30
  144. data/unittests/attachToExistingWindow_test.rb +0 -40
  145. data/unittests/js_events_test.rb +0 -77
  146. data/unittests/jscriptExtraAlert.rb +0 -6
  147. data/unittests/jscriptExtraConfirmCancel.rb +0 -7
  148. data/unittests/jscriptExtraConfirmOk.rb +0 -7
  149. data/unittests/jscript_test.rb +0 -57
  150. data/unittests/send_keys_test.rb +0 -29
  151. data/unittests/textAreafields_test.rb +0 -81
@@ -0,0 +1,101 @@
1
+ # feature tests for Radio Buttons
2
+ # revision: $Revision: 962 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
+ require 'unittests/setup'
6
+
7
+ class TC_Radios_XPath < Test::Unit::TestCase
8
+ include Watir
9
+
10
+ def setup
11
+ $ie.goto($htmlRoot + "radioButtons1.html")
12
+ end
13
+
14
+ def test_Radio_Exists
15
+ assert($ie.radio(:xpath, "//input[@name='box1']/").exists?)
16
+ assert($ie.radio(:xpath, "//input[@id='box5']/").exists?)
17
+
18
+ assert(!$ie.radio(:xpath, "//input[@name='missingname']/").exists?)
19
+ assert(!$ie.radio(:xpath, "//input[@id='missingid']/").exists?)
20
+ end
21
+
22
+ def test_Radio_Enabled
23
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='noName']/").enabled? }
24
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@id='noName']/").enabled? }
25
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='box4' and @value='6']/").enabled? }
26
+
27
+ assert(!$ie.radio(:xpath, "//input[@name='box2']/").enabled?)
28
+ assert($ie.radio(:xpath, "//input[@id='box5']/").enabled?)
29
+ assert($ie.radio(:xpath, "//input[@name='box1']/").enabled?)
30
+ end
31
+
32
+ def test_little
33
+ assert(!$ie.button(:xpath,"//input[@name='foo']/").enabled?)
34
+ end
35
+
36
+ def test_onClick
37
+ assert(!$ie.button(:xpath,"//input[@name='foo']/").enabled?)
38
+ $ie.radio(:xpath, "//input[@name='box5' and @value='1']/").set
39
+ assert($ie.button(:xpath,"//input[@name='foo']/").enabled?)
40
+
41
+ $ie.radio(:xpath, "//input[@name='box5' and @value='2']/").set
42
+ assert(!$ie.button(:xpath,"//input[@name='foo']/").enabled?)
43
+ end
44
+
45
+ def test_Radio_isSet
46
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='noName']/").isSet? }
47
+
48
+ puts "radio 1 is set : #{ $ie.radio(:xpath, "//input[@name='box1']/").isSet? } "
49
+ assert(!$ie.radio(:xpath, "//input[@name='box1']/").isSet?)
50
+
51
+ assert($ie.radio(:xpath, "//input[@name='box3']/").isSet?)
52
+ assert(!$ie.radio(:xpath, "//input[@name='box2']/").isSet?)
53
+
54
+ assert( $ie.radio(:xpath, "//input[@name='box4' and @value='1']/").isSet?)
55
+ assert(!$ie.radio(:xpath, "//input[@name='box4' and @value='2']/").isSet?)
56
+ end
57
+
58
+ def test_radio_clear
59
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='noName']/").clear }
60
+
61
+ $ie.radio(:xpath, "//input[@name='box1']/").clear
62
+ assert(!$ie.radio(:xpath, "//input[@name='box1']/").isSet?)
63
+
64
+ assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='box2']/").clear }
65
+ assert(!$ie.radio(:xpath, "//input[@name='box2']/").isSet?)
66
+
67
+ $ie.radio(:xpath, "//input[@name='box3']/").clear
68
+ assert(!$ie.radio(:xpath, "//input[@name='box3']/").isSet?)
69
+
70
+ $ie.radio(:xpath, "//input[@name='box4' and @value='1']/").clear
71
+ assert(!$ie.radio(:xpath, "//input[@name='box4' and @value='1']/").isSet?)
72
+ end
73
+
74
+ def test_radio_getState
75
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='noName']/").getState }
76
+
77
+ assert_equal( false , $ie.radio(:xpath, "//input[@name='box1']/").getState )
78
+ assert_equal( true , $ie.radio(:xpath, "//input[@name='box3']/").getState)
79
+
80
+ # radioes that have the same name but different values
81
+ assert_equal( false , $ie.radio(:xpath, "//input[@name='box4' and @value='2']/").getState )
82
+ assert_equal( true , $ie.radio(:xpath, "//input[@name='box4' and @value='1']/").getState)
83
+ end
84
+
85
+ def test_radio_set
86
+ assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='noName']/").set }
87
+ $ie.radio(:xpath, "//input[@name='box1']/").set
88
+ assert($ie.radio(:xpath, "//input[@name='box1']/").isSet?)
89
+
90
+ assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='box2']/").set }
91
+
92
+ $ie.radio(:xpath, "//input[@name='box3']/").set
93
+ assert($ie.radio(:xpath, "//input[@name='box3']/").isSet?)
94
+
95
+ # radioes that have the same name but different values
96
+ $ie.radio(:xpath, "//input[@name='box4' and @value='3']/").set
97
+ assert($ie.radio(:xpath, "//input[@name='box4' and @value='3']/").isSet?)
98
+ end
99
+
100
+ end
101
+
@@ -1,53 +1,53 @@
1
1
  # feature tests for screen capture
2
- # revision: $Revision: 1.4 $
2
+ # revision: $Revision: 958 $
3
3
 
4
4
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
5
  require 'unittests/setup'
6
6
  require 'watir/screen_capture'
7
7
 
8
8
  class TC_Capture< Test::Unit::TestCase
9
- include Watir
10
- include Watir::ScreenCapture
11
-
12
- def setup
13
- delete_captured_files( [ 'jpeg1.jpg' , 'jpeg2.jpg' , 'bmp1.bmp', 'bmp2.bmp' ] )
14
- $ie.goto($htmlRoot + 'buttons1.html' )
15
- @file_list = []
16
- end
17
-
18
- def teardown
19
- delete_captured_files
9
+ include Watir
10
+ include Watir::ScreenCapture
11
+
12
+ def setup
13
+ delete_captured_files( [ 'jpeg1.jpg' , 'jpeg2.jpg' , 'bmp1.bmp', 'bmp2.bmp' ] )
14
+ $ie.goto($htmlRoot + 'buttons1.html' )
15
+ @file_list = []
16
+ end
17
+
18
+ def teardown
19
+ delete_captured_files
20
+ end
21
+
22
+ def delete_captured_files(files=nil )
23
+ files = @file_list unless files
24
+ files.each do |f|
25
+ File.delete( f) if FileTest.exists?( f)
20
26
  end
27
+ end
28
+
29
+ def test_jpeg
30
+ file_name= 'jpeg1.jpg'
31
+ @file_list << file_name
32
+ screen_capture( file_name )
33
+ assert(FileTest.exist?( file_name) )
21
34
 
22
- def delete_captured_files(files=nil )
23
- files = @file_list unless files
24
- files.each do |f|
25
- File.delete( f) if FileTest.exists?( f)
26
- end
27
- end
35
+ file_name= 'jpeg2.jpg'
36
+ @file_list << file_name
37
+ screen_capture( file_name , true ) # just the active window
38
+ assert(FileTest.exist?( file_name) )
39
+ end
40
+
41
+ def test_bmp
42
+ file_name= 'bmp1.bmp'
43
+ @file_list << file_name
44
+ screen_capture( file_name , false, true )
45
+ assert(FileTest.exist?( file_name ) )
28
46
 
29
- def test_jpeg
30
- file_name= 'jpeg1.jpg'
31
- @file_list << file_name
32
- screen_capture( file_name )
33
- assert(FileTest.exist?( file_name) )
34
-
35
- file_name= 'jpeg2.jpg'
36
- @file_list << file_name
37
- screen_capture( file_name , true ) # just the active window
38
- assert(FileTest.exist?( file_name) )
39
- end
40
-
41
- def test_bmp
42
- file_name= 'bmp1.bmp'
43
- @file_list << file_name
44
- screen_capture( file_name , false, true )
45
- assert(FileTest.exist?( file_name ) )
46
-
47
- file_name= 'bmp2.bmp'
48
- @file_list << file_name
49
- screen_capture( file_name , true , true ) # just the active window
50
- assert(FileTest.exist?( file_name) )
51
- end
47
+ file_name= 'bmp2.bmp'
48
+ @file_list << file_name
49
+ screen_capture( file_name , true , true ) # just the active window
50
+ assert(FileTest.exist?( file_name) )
51
+ end
52
52
  end
53
53
 
@@ -1,197 +1,239 @@
1
1
  # feature tests for Select Boxes
2
- # revision: $Revision: 1.28 $
2
+ # revision: $Revision: 1111 $
3
3
 
4
4
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
5
  require 'unittests/setup'
6
6
 
7
7
  class TC_SelectList < Test::Unit::TestCase
8
- include Watir
8
+ include Watir
9
+
10
+ def setup
11
+ $ie.goto($htmlRoot + "selectboxes1.html")
12
+ end
13
+
14
+ def test_SelectList_exists
15
+ assert($ie.select_list(:name, "sel1").exists?)
16
+ assert(!$ie.select_list(:name, "missing").exists?)
17
+ assert(!$ie.select_list(:id, "missing").exists?)
18
+ end
19
+
20
+ def test_SelectList_enabled
21
+ assert($ie.select_list(:name, "sel1").enabled?)
22
+ assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").enabled? }
23
+ assert(!$ie.select_list(:id, 'selectbox_4').enabled?)
24
+ end
25
+
26
+ def test_SelectList_class_name
27
+ assert_raises(UnknownObjectException) { $ie.select_list(:name, "missing").class_name }
28
+ assert_equal("list_style" , $ie.select_list(:name, "sel1").class_name)
29
+ assert_equal("" , $ie.selectBox(:name, "sel2").class_name )
30
+ end
31
+
32
+
33
+
34
+ def test_Option_text_select
35
+ assert_raises(UnknownObjectException) { $ie.select_list(:name, "sel1").option(:text, "missing item").select }
36
+ assert_raises(UnknownObjectException) { $ie.select_list(:name, "sel1").option(:text, /missing/).select }
37
+ assert_raises(MissingWayOfFindingObjectException) { $ie.select_list(:name, "sel1").option(:missing, "Option 1").select }
38
+
39
+ # the select method keeps any currently selected items - use the clear selection method first
40
+ $ie.select_list( :name , "sel1").clearSelection
41
+ $ie.select_list( :name , "sel1").option(:text, "Option 1").select
42
+ assert_equal( ["Option 1" ] , $ie.select_list(:name, "sel1").getSelectedItems)
43
+ end
44
+
45
+
46
+ def xtest_option_class_name
47
+
48
+ # the option object doesnt inherit from element, so this doesnt work
49
+ assert_raises(UnknownObjectException) { $ie.select_list(:name, "sel1").option(:text, "missing item").class_name }
50
+ assert_equal("list_style" , $ie.select_list(:name, "sel2").option(:value , 'o2').class_name)
51
+ assert_equal("" , $ie.select_list(:name, "sel2").option(:value , 'o1').class_name)
52
+
53
+ end
54
+
55
+ def test_includes
56
+ assert $ie.select_list(:name, 'sel1').includes?('Option 1')
57
+ assert ! $ie.select_list(:name, 'sel1').includes?('Option 6')
58
+ end
59
+
60
+ def test_selected
61
+ assert ! $ie.select_list(:name, 'sel1').selected?('Option 1')
62
+ assert $ie.select_list(:name, 'sel1').selected?('Option 3')
63
+ end
64
+
65
+ def test_selected_not_found
66
+ selectbox = $ie.select_list(:name, 'sel1')
67
+ assert_raises(Watir::Exception::UnknownObjectException) {selectbox.selected?('Option Not Exists')}
68
+ end
9
69
 
10
- def setup()
11
- $ie.goto($htmlRoot + "selectboxes1.html")
12
- end
13
-
14
- def test_SelectList_exists
15
- assert($ie.select_list(:name, "sel1").exists?)
16
- assert_false($ie.select_list(:name, "missing").exists?)
17
- assert_false($ie.select_list(:id, "missing").exists?)
18
- end
19
-
20
- def test_SelectList_enabled
21
- assert($ie.select_list(:name, "sel1").enabled?)
22
- assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").enabled? }
23
- assert_false($ie.select_list(:id, 'selectbox_4').enabled?)
24
- end
25
-
26
- def test_Option_text_select
27
- assert_raises(UnknownObjectException) { $ie.select_list(:name, "sel1").option(:text, "missing item").select }
28
- assert_raises(UnknownObjectException) { $ie.select_list(:name, "sel1").option(:text, /missing/).select }
29
- assert_raises(MissingWayOfFindingObjectException) { $ie.select_list(:name, "sel1").option(:missing, "Option 1").select }
30
-
31
- # the select method keeps any currently selected items - use the clear selection method first
32
- $ie.select_list( :name , "sel1").clearSelection
33
- $ie.select_list( :name , "sel1").option(:text, "Option 1").select
34
- assert_arrayEquals( ["Option 1" ] , $ie.select_list(:name, "sel1").getSelectedItems)
35
- end
36
70
  end
37
71
 
38
72
  # Tests for the old interface
39
73
  class TC_Selectbox < Test::Unit::TestCase
40
- include Watir
41
-
42
- def setup()
43
- $ie.goto($htmlRoot + "selectboxes1.html")
44
- end
45
-
46
- def test_selectBox_Exists
47
- assert($ie.selectBox(:name, "sel1").exists?)
48
- assert_false($ie.selectBox(:name, "missing").exists?)
49
- assert_false($ie.selectBox(:id, "missing").exists?)
50
- end
51
-
52
- def test_selectBox_enabled
53
- assert($ie.selectBox(:name, "sel1").enabled?)
54
- assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").enabled? }
55
- end
56
-
57
- def test_selectBox_getAllContents
58
- assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").getAllContents }
59
- assert_arrayEquals( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
60
- $ie.selectBox(:name, "sel1").getAllContents)
61
- end
62
-
63
- def test_selectBox_getSelectedItems
64
- assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").getSelectedItems }
65
- assert_arrayEquals( ["Option 3" ] ,
66
- $ie.selectBox(:name, "sel1").getSelectedItems)
67
- assert_arrayEquals( ["Option 3" , "Option 6" ] ,
68
- $ie.selectBox(:name, "sel2").getSelectedItems)
69
- end
70
-
71
- def test_clearSelection
72
- assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").clearSelection }
73
- $ie.selectBox( :name , "sel1").clearSelection
74
-
75
- # the box sel1 has no ability to have a de-selected item
76
- assert_arrayEquals( ["Option 3" ] , $ie.selectBox(:name, "sel1").getSelectedItems)
77
-
78
- $ie.selectBox( :name , "sel2").clearSelection
79
- assert_arrayEquals( [ ] , $ie.selectBox(:name, "sel2").getSelectedItems)
80
- end
81
-
82
- def test_selectBox_select
83
- assert_raises(NoValueFoundException) { $ie.selectBox(:name, "sel1").select("missing item") }
84
- assert_raises(NoValueFoundException) { $ie.selectBox(:name, "sel1").select(/missing/) }
85
-
86
- # the select method keeps any currently selected items - use the clear selectcion method first
87
- $ie.selectBox( :name , "sel1").clearSelection
88
- $ie.selectBox( :name , "sel1").select("Option 1")
89
- assert_arrayEquals( ["Option 1" ] , $ie.selectBox(:name, "sel1").getSelectedItems)
90
-
91
- $ie.selectBox( :name , "sel1").clearSelection
92
- $ie.selectBox( :name , "sel1").select(/2/)
93
- assert_arrayEquals( ["Option 2" ] , $ie.selectBox(:name, "sel1").getSelectedItems)
94
-
95
- $ie.selectBox( :name , "sel2").clearSelection
96
- $ie.selectBox( :name , "sel2").select(/2/)
97
- $ie.selectBox( :name , "sel2").select(/4/)
98
- assert_arrayEquals( ["Option 2" , "Option 4" ] ,
99
- $ie.selectBox(:name, "sel2").getSelectedItems)
100
-
101
- # these are to test the onchange event
102
- # the event shouldnt get fired, as this is the selected item
103
- $ie.selectBox( :name , "sel3").select( /3/ )
104
- assert_false($ie.contains_text("Pass") )
105
- end
106
-
107
- def test_selectBox_select2
108
- # the event should get fired
109
- $ie.selectBox( :name , "sel3").select( /2/ )
110
- assert($ie.contains_text("PASS") )
111
- end
112
-
113
- def test_selectBox_select_using_value
114
- assert_raises(UnknownObjectException) { $ie.select_list(:name, "NoName").getSelectedItems }
115
- assert_raises(NoValueFoundException) { $ie.select_list(:name, "sel1").select_value("missing item") }
116
- assert_raises(NoValueFoundException) { $ie.select_list(:name, "sel1").select_value(/missing/) }
117
-
118
- # the select method keeps any currently selected items - use the clear selectcion method first
119
- $ie.select_list( :name , "sel1").clearSelection
120
- $ie.select_list( :name , "sel1").select_value("o1")
121
- assert_arrayEquals( ["Option 1" ] , $ie.select_list(:name, "sel1").getSelectedItems)
122
-
123
- $ie.select_list( :name , "sel1").clearSelection
124
- $ie.select_list( :name , "sel1").select_value(/2/)
125
- assert_arrayEquals( ["Option 2" ] , $ie.select_list(:name, "sel1").getSelectedItems)
126
-
127
- $ie.select_list( :name , "sel2").clearSelection
128
- $ie.select_list( :name , "sel2").select_value(/4/)
129
- $ie.select_list( :name , "sel2").select_value(/2/)
130
- assert_arrayEquals( ["Option 2" , "Option 4" ] ,
131
- $ie.select_list(:name, "sel2").getSelectedItems)
132
-
133
- # these are to test the onchange event
134
- # the event shouldnt get fired, as this is the selected item
135
- $ie.select_list( :name , "sel3").select_value( /3/ )
136
- assert_false($ie.contains_text("Pass") )
137
- end
138
-
139
- def test_select_list_select_using_value2
140
- # the event should get fired
141
- $ie.select_list( :name , "sel3").select_value( /2/ )
142
- assert($ie.contains_text("PASS") )
143
- end
144
-
145
- def test_select_list_properties
146
- assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).value }
147
- assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).name }
148
- assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).id }
149
- assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).disabled }
150
- assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).type }
151
-
152
- assert_equal("o3" , $ie.select_list(:index, 1).value)
153
- assert_equal("sel1" , $ie.select_list(:index, 1).name )
154
- assert_equal("" , $ie.select_list(:index, 1).id )
155
- assert_equal("select-one", $ie.select_list(:index, 1).type )
156
- assert_equal("select-multiple", $ie.select_list(:index, 2).type )
157
-
158
- $ie.select_list(:index,1).select(/1/)
159
- assert_equal("o1" , $ie.select_list(:index, 1).value)
160
-
161
- assert_false( $ie.select_list(:index, 1).disabled )
162
- assert( $ie.select_list(:index, 4).disabled )
163
- assert( $ie.select_list(:id, 'selectbox_4').disabled )
164
- end
165
-
166
- def test_select_list_iterator
167
- assert_equal(4, $ie.select_lists.length)
168
- assert_equal("o3" , $ie.select_lists[1].value)
169
- assert_equal("sel1" , $ie.select_lists[1].name )
170
- assert_equal("select-one", $ie.select_lists[1].type )
171
- assert_equal("select-multiple" , $ie.select_lists[2].type )
172
-
173
- index=1
174
- $ie.select_lists.each do |l|
175
- assert_equal( $ie.select_list(:index, index).name , l.name )
176
- assert_equal( $ie.select_list(:index, index).id , l.id )
177
- assert_equal( $ie.select_list(:index, index).type , l.type )
178
- assert_equal( $ie.select_list(:index, index).value , l.value )
179
- index+=1
180
- end
181
- assert_equal( index-1, $ie.select_lists.length)
182
- end
74
+ include Watir
75
+
76
+ def setup
77
+ $ie.goto($htmlRoot + "selectboxes1.html")
78
+ end
79
+
80
+ def test_selectBox_Exists
81
+ assert($ie.selectBox(:name, "sel1").exists?)
82
+ assert(!$ie.selectBox(:name, "missing").exists?)
83
+ assert(!$ie.selectBox(:id, "missing").exists?)
84
+ end
85
+
86
+ def test_selectBox_enabled
87
+ assert($ie.selectBox(:name, "sel1").enabled?)
88
+ assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").enabled? }
89
+ end
90
+
91
+
92
+ def test_SelectList_class_name
93
+ assert_raises(UnknownObjectException) { $ie.select_list(:name, "missing").class_name }
94
+ assert_equal("list_style" , $ie.select_list(:name, "sel1").class_name)
95
+ assert_equal("" , $ie.selectBox(:name, "sel2").class_name )
96
+ end
97
+
98
+
99
+ def test_selectBox_getAllContents
100
+ assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").getAllContents }
101
+ assert_equal( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
102
+ $ie.selectBox(:name, "sel1").getAllContents)
103
+ end
104
+
105
+ def test_selectBox_getSelectedItems
106
+ assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").getSelectedItems }
107
+ assert_equal( ["Option 3" ] ,
108
+ $ie.selectBox(:name, "sel1").getSelectedItems)
109
+ assert_equal( ["Option 3" , "Option 6" ] ,
110
+ $ie.selectBox(:name, "sel2").getSelectedItems)
111
+ end
112
+
113
+ def test_clearSelection
114
+ assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").clearSelection }
115
+ $ie.selectBox( :name , "sel1").clearSelection
116
+
117
+ # the box sel1 has no ability to have a de-selected item
118
+ assert_equal( ["Option 3" ] , $ie.selectBox(:name, "sel1").getSelectedItems)
119
+
120
+ $ie.selectBox( :name , "sel2").clearSelection
121
+ assert_equal( [ ] , $ie.selectBox(:name, "sel2").getSelectedItems)
122
+ end
123
+
124
+ def test_selectBox_select
125
+ assert_raises(NoValueFoundException) { $ie.selectBox(:name, "sel1").select("missing item") }
126
+ assert_raises(NoValueFoundException) { $ie.selectBox(:name, "sel1").select(/missing/) }
127
+
128
+ # the select method keeps any currently selected items - use the clear selectcion method first
129
+ $ie.selectBox( :name , "sel1").clearSelection
130
+ $ie.selectBox( :name , "sel1").select("Option 1")
131
+ assert_equal( ["Option 1" ] , $ie.selectBox(:name, "sel1").getSelectedItems)
132
+
133
+ $ie.selectBox( :name , "sel1").clearSelection
134
+ $ie.selectBox( :name , "sel1").select(/2/)
135
+ assert_equal( ["Option 2" ] , $ie.selectBox(:name, "sel1").getSelectedItems)
136
+
137
+ $ie.selectBox( :name , "sel2").clearSelection
138
+ $ie.selectBox( :name , "sel2").select(/2/)
139
+ $ie.selectBox( :name , "sel2").select(/4/)
140
+ assert_equal( ["Option 2" , "Option 4" ] ,
141
+ $ie.selectBox(:name, "sel2").getSelectedItems)
142
+
143
+ # these are to test the onchange event
144
+ # the event shouldnt get fired, as this is the selected item
145
+ $ie.selectBox( :name , "sel3").select( /3/ )
146
+ assert(!$ie.text.include?("Pass") )
147
+ end
148
+
149
+ def test_selectBox_select2
150
+ # the event should get fired
151
+ $ie.selectBox( :name , "sel3").select( /2/ )
152
+ assert($ie.text.include?("PASS") )
153
+ end
154
+
155
+ def test_selectBox_select_using_value
156
+ assert_raises(UnknownObjectException) { $ie.select_list(:name, "NoName").getSelectedItems }
157
+ assert_raises(NoValueFoundException) { $ie.select_list(:name, "sel1").select_value("missing item") }
158
+ assert_raises(NoValueFoundException) { $ie.select_list(:name, "sel1").select_value(/missing/) }
159
+
160
+ # the select method keeps any currently selected items - use the clear selectcion method first
161
+ $ie.select_list( :name , "sel1").clearSelection
162
+ $ie.select_list( :name , "sel1").select_value("o1")
163
+ assert_equal( ["Option 1" ] , $ie.select_list(:name, "sel1").getSelectedItems)
164
+
165
+ $ie.select_list( :name , "sel1").clearSelection
166
+ $ie.select_list( :name , "sel1").select_value(/2/)
167
+ assert_equal( ["Option 2" ] , $ie.select_list(:name, "sel1").getSelectedItems)
168
+
169
+ $ie.select_list( :name , "sel2").clearSelection
170
+ $ie.select_list( :name , "sel2").select_value(/4/)
171
+ $ie.select_list( :name , "sel2").select_value(/2/)
172
+ assert_equal( ["Option 2" , "Option 4" ] ,
173
+ $ie.select_list(:name, "sel2").getSelectedItems)
174
+
175
+ # these are to test the onchange event
176
+ # the event shouldnt get fired, as this is the selected item
177
+ $ie.select_list( :name , "sel3").select_value( /3/ )
178
+ assert(!$ie.text.include?("Pass") )
179
+ end
180
+
181
+ def test_select_list_select_using_value2
182
+ # the event should get fired
183
+ $ie.select_list( :name , "sel3").select_value( /2/ )
184
+ assert($ie.text.include?("PASS") )
185
+ end
186
+
187
+ def test_select_list_properties
188
+ assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).value }
189
+ assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).name }
190
+ assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).id }
191
+ assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).disabled }
192
+ assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).type }
193
+
194
+ assert_equal("o3" , $ie.select_list(:index, 1).value)
195
+ assert_equal("sel1" , $ie.select_list(:index, 1).name )
196
+ assert_equal("" , $ie.select_list(:index, 1).id )
197
+ assert_equal("select-one", $ie.select_list(:index, 1).type )
198
+ assert_equal("select-multiple", $ie.select_list(:index, 2).type )
199
+
200
+ $ie.select_list(:index,1).select(/1/)
201
+ assert_equal("o1" , $ie.select_list(:index, 1).value)
202
+
203
+ assert(! $ie.select_list(:index, 1).disabled )
204
+ assert( $ie.select_list(:index, 4).disabled )
205
+ assert( $ie.select_list(:id, 'selectbox_4').disabled )
206
+ end
207
+
208
+ def test_select_list_iterator
209
+ assert_equal(4, $ie.select_lists.length)
210
+ assert_equal("o3" , $ie.select_lists[1].value)
211
+ assert_equal("sel1" , $ie.select_lists[1].name )
212
+ assert_equal("select-one", $ie.select_lists[1].type )
213
+ assert_equal("select-multiple" , $ie.select_lists[2].type )
214
+
215
+ index=1
216
+ $ie.select_lists.each do |l|
217
+ assert_equal( $ie.select_list(:index, index).name , l.name )
218
+ assert_equal( $ie.select_list(:index, index).id , l.id )
219
+ assert_equal( $ie.select_list(:index, index).type , l.type )
220
+ assert_equal( $ie.select_list(:index, index).value , l.value )
221
+ index+=1
222
+ end
223
+ assert_equal( index-1, $ie.select_lists.length)
224
+ end
183
225
  end
184
226
 
185
227
  class TC_Select_Options < Test::Unit::TestCase
186
- include Watir
187
-
188
- def setup()
189
- $ie.goto($htmlRoot + "select_tealeaf.html")
190
- end
191
-
192
- def test_options_text
193
- $ie.select_list(:name, 'op_numhits').option(:text, '>=').select
194
- assert($ie.select_list(:name, 'op_numhits').option(:text, '>=').selected)
195
- end
228
+ include Watir
229
+
230
+ def setup
231
+ $ie.goto($htmlRoot + "select_tealeaf.html")
232
+ end
233
+
234
+ def test_options_text
235
+ $ie.select_list(:name, 'op_numhits').option(:text, '>=').select
236
+ assert($ie.select_list(:name, 'op_numhits').option(:text, '>=').selected)
237
+ end
196
238
  end
197
239