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 Radio Buttons
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_Radios_XPath < Test::Unit::TestCase
@@ -12,89 +12,89 @@ class TC_Radios_XPath < Test::Unit::TestCase
12
12
  end
13
13
 
14
14
  def test_Radio_Exists
15
- assert($ie.radio(:xpath, "//input[@name='box1']/").exists?)
16
- assert($ie.radio(:xpath, "//input[@id='box5']/").exists?)
15
+ assert(browser.radio(:xpath, "//input[@name='box1']/").exists?)
16
+ assert(browser.radio(:xpath, "//input[@id='box5']/").exists?)
17
17
 
18
- assert(!$ie.radio(:xpath, "//input[@name='missingname']/").exists?)
19
- assert(!$ie.radio(:xpath, "//input[@id='missingid']/").exists?)
18
+ assert_false(browser.radio(:xpath, "//input[@name='missingname']/").exists?)
19
+ assert_false(browser.radio(:xpath, "//input[@id='missingid']/").exists?)
20
20
  end
21
21
 
22
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? }
23
+ assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']/").enabled? }
24
+ assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@id='noName']/").enabled? }
25
+ assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='box4' and @value='6']/").enabled? }
26
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?)
27
+ assert_false(browser.radio(:xpath, "//input[@name='box2']/").enabled?)
28
+ assert(browser.radio(:xpath, "//input[@id='box5']/").enabled?)
29
+ assert(browser.radio(:xpath, "//input[@name='box1']/").enabled?)
30
30
  end
31
31
 
32
32
  def test_little
33
- assert(!$ie.button(:xpath,"//input[@name='foo']/").enabled?)
33
+ assert_false(browser.button(:xpath,"//input[@name='foo']/").enabled?)
34
34
  end
35
35
 
36
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?)
37
+ assert_false(browser.button(:xpath,"//input[@name='foo']/").enabled?)
38
+ browser.radio(:xpath, "//input[@name='box5' and @value='1']/").set
39
+ assert(browser.button(:xpath,"//input[@name='foo']/").enabled?)
40
40
 
41
- $ie.radio(:xpath, "//input[@name='box5' and @value='2']/").set
42
- assert(!$ie.button(:xpath,"//input[@name='foo']/").enabled?)
41
+ browser.radio(:xpath, "//input[@name='box5' and @value='2']/").set
42
+ assert_false(browser.button(:xpath,"//input[@name='foo']/").enabled?)
43
43
  end
44
44
 
45
45
  def test_Radio_isSet
46
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='noName']/").isSet? }
46
+ assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']/").isSet? }
47
47
 
48
- puts "radio 1 is set : #{ $ie.radio(:xpath, "//input[@name='box1']/").isSet? } "
49
- assert(!$ie.radio(:xpath, "//input[@name='box1']/").isSet?)
48
+ puts "radio 1 is set : #{ browser.radio(:xpath, "//input[@name='box1']/").isSet? } "
49
+ assert_false(browser.radio(:xpath, "//input[@name='box1']/").isSet?)
50
50
 
51
- assert($ie.radio(:xpath, "//input[@name='box3']/").isSet?)
52
- assert(!$ie.radio(:xpath, "//input[@name='box2']/").isSet?)
51
+ assert(browser.radio(:xpath, "//input[@name='box3']/").isSet?)
52
+ assert_false(browser.radio(:xpath, "//input[@name='box2']/").isSet?)
53
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?)
54
+ assert( browser.radio(:xpath, "//input[@name='box4' and @value='1']/").isSet?)
55
+ assert_false(browser.radio(:xpath, "//input[@name='box4' and @value='2']/").isSet?)
56
56
  end
57
57
 
58
58
  def test_radio_clear
59
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='noName']/").clear }
59
+ assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']/").clear }
60
60
 
61
- $ie.radio(:xpath, "//input[@name='box1']/").clear
62
- assert(!$ie.radio(:xpath, "//input[@name='box1']/").isSet?)
61
+ browser.radio(:xpath, "//input[@name='box1']/").clear
62
+ assert_false(browser.radio(:xpath, "//input[@name='box1']/").isSet?)
63
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?)
64
+ assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:xpath, "//input[@name='box2']/").clear }
65
+ assert_false(browser.radio(:xpath, "//input[@name='box2']/").isSet?)
66
66
 
67
- $ie.radio(:xpath, "//input[@name='box3']/").clear
68
- assert(!$ie.radio(:xpath, "//input[@name='box3']/").isSet?)
67
+ browser.radio(:xpath, "//input[@name='box3']/").clear
68
+ assert_false(browser.radio(:xpath, "//input[@name='box3']/").isSet?)
69
69
 
70
- $ie.radio(:xpath, "//input[@name='box4' and @value='1']/").clear
71
- assert(!$ie.radio(:xpath, "//input[@name='box4' and @value='1']/").isSet?)
70
+ browser.radio(:xpath, "//input[@name='box4' and @value='1']/").clear
71
+ assert_false(browser.radio(:xpath, "//input[@name='box4' and @value='1']/").isSet?)
72
72
  end
73
73
 
74
74
  def test_radio_getState
75
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='noName']/").getState }
75
+ assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']/").getState }
76
76
 
77
- assert_equal( false , $ie.radio(:xpath, "//input[@name='box1']/").getState )
78
- assert_equal( true , $ie.radio(:xpath, "//input[@name='box3']/").getState)
77
+ assert_equal( false , browser.radio(:xpath, "//input[@name='box1']/").getState )
78
+ assert_equal( true , browser.radio(:xpath, "//input[@name='box3']/").getState)
79
79
 
80
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)
81
+ assert_equal( false , browser.radio(:xpath, "//input[@name='box4' and @value='2']/").getState )
82
+ assert_equal( true , browser.radio(:xpath, "//input[@name='box4' and @value='1']/").getState)
83
83
  end
84
84
 
85
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?)
86
+ assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']/").set }
87
+ browser.radio(:xpath, "//input[@name='box1']/").set
88
+ assert(browser.radio(:xpath, "//input[@name='box1']/").isSet?)
89
89
 
90
- assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ie.radio(:xpath, "//input[@name='box2']/").set }
90
+ assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:xpath, "//input[@name='box2']/").set }
91
91
 
92
- $ie.radio(:xpath, "//input[@name='box3']/").set
93
- assert($ie.radio(:xpath, "//input[@name='box3']/").isSet?)
92
+ browser.radio(:xpath, "//input[@name='box3']/").set
93
+ assert(browser.radio(:xpath, "//input[@name='box3']/").isSet?)
94
94
 
95
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?)
96
+ browser.radio(:xpath, "//input[@name='box4' and @value='3']/").set
97
+ assert(browser.radio(:xpath, "//input[@name='box4' and @value='3']/").isSet?)
98
98
  end
99
99
 
100
100
  end
@@ -0,0 +1,24 @@
1
+ # The purpose of this test is to verify that IE has been manually
2
+ # configured to allow active content from local files.
3
+ # This setting is not really required for normal use of Watir, but
4
+ # it is essential for many of our unit tests.
5
+
6
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
7
+ require 'unittests/setup'
8
+
9
+ class TC_AAA_Security_Settings < Test::Unit::TestCase
10
+ def setup
11
+ uses_page "div.html"
12
+ end
13
+
14
+ @@security_instructions = "\
15
+ You must change your IE security settings to run these tests.
16
+ Tools -> Internet Options -> Advanced -> Security ->
17
+ 'Allow active content to run in files on My Computer'"
18
+
19
+ def test_active_content
20
+ browser.span(:id, "span3").click
21
+ value = browser.text_field(:name, "text2").value
22
+ fail(@@security_instructions) if value == '0'
23
+ end
24
+ end
@@ -1,7 +1,7 @@
1
1
  # feature tests for Select Boxes
2
- # revision: $Revision: 1348 $
2
+ # revision: $Revision: 1531 $
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_SelectList < Test::Unit::TestCase
@@ -12,208 +12,116 @@ class TC_SelectList < Test::Unit::TestCase
12
12
  end
13
13
 
14
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?)
15
+ assert(browser.select_list(:name, "sel1").exists?)
16
+ assert_false(browser.select_list(:name, "missing").exists?)
17
+ assert_false(browser.select_list(:id, "missing").exists?)
18
18
  end
19
19
 
20
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?)
21
+ assert(browser.select_list(:name, "sel1").enabled?)
22
+ assert_raises(UnknownObjectException) { browser.select_list(:name, "NoName").enabled? }
23
+ assert_false(browser.select_list(:id, 'selectbox_4').enabled?)
24
24
  end
25
25
 
26
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 )
27
+ assert_raises(UnknownObjectException) { browser.select_list(:name, "missing").class_name }
28
+ assert_equal("list_style" , browser.select_list(:name, "sel1").class_name)
29
+ assert_equal("" , browser.select_list(:name, "sel2").class_name )
30
30
  end
31
31
 
32
32
  def test_Option_text_select
33
- assert_raises(UnknownObjectException) { $ie.select_list(:name, "sel1").option(:text, "missing item").select }
34
- assert_raises(UnknownObjectException) { $ie.select_list(:name, "sel1").option(:text, /missing/).select }
35
- assert_raises(MissingWayOfFindingObjectException) { $ie.select_list(:name, "sel1").option(:missing, "Option 1").select }
33
+ assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, "missing item").select }
34
+ assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, /missing/).select }
35
+ assert_raises(MissingWayOfFindingObjectException) { browser.select_list(:name, "sel1").option(:missing, "Option 1").select }
36
36
 
37
37
  # the select method keeps any currently selected items - use the clear selection method first
38
- $ie.select_list( :name , "sel1").clearSelection
39
- $ie.select_list( :name , "sel1").option(:text, "Option 1").select
40
- assert_equal( ["Option 1" ] , $ie.select_list(:name, "sel1").getSelectedItems)
38
+ browser.select_list( :name , "sel1").clearSelection
39
+ browser.select_list( :name , "sel1").option(:text, "Option 1").select
40
+ assert_equal( ["Option 1" ] , browser.select_list(:name, "sel1").getSelectedItems)
41
41
  end
42
42
 
43
43
  def xtest_option_class_name
44
44
  # the option object doesnt inherit from element, so this doesnt work
45
- assert_raises(UnknownObjectException) { $ie.select_list(:name, "sel1").option(:text, "missing item").class_name }
46
- assert_equal("list_style" , $ie.select_list(:name, "sel2").option(:value , 'o2').class_name)
47
- assert_equal("" , $ie.select_list(:name, "sel2").option(:value , 'o1').class_name)
45
+ assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, "missing item").class_name }
46
+ assert_equal("list_style" , browser.select_list(:name, "sel2").option(:value , 'o2').class_name)
47
+ assert_equal("" , browser.select_list(:name, "sel2").option(:value , 'o1').class_name)
48
48
  end
49
-
49
+
50
+ tag_method :test_includes, :fails_on_firefox
50
51
  def test_includes
51
- assert $ie.select_list(:name, 'sel1').includes?('Option 1')
52
- assert ! $ie.select_list(:name, 'sel1').includes?('Option 6')
52
+ assert browser.select_list(:name, 'sel1').includes?('Option 1')
53
+ assert browser.select_list(:name, 'sel1').includes?(/option/i)
54
+ assert ! browser.select_list(:name, 'sel1').includes?('Option 6')
55
+ assert ! browser.select_list(:name, 'sel1').includes?(/foobar/)
53
56
  end
54
57
 
58
+ tag_method :test_selected, :fails_on_firefox
55
59
  def test_selected
56
- assert ! $ie.select_list(:name, 'sel1').selected?('Option 1')
57
- assert $ie.select_list(:name, 'sel1').selected?('Option 3')
60
+ assert browser.select_list(:name, 'sel1').selected?('Option 3')
61
+ assert browser.select_list(:name, 'sel1').selected?(/option/i)
62
+ assert ! browser.select_list(:name, 'sel1').selected?('Option 1')
63
+ assert ! browser.select_list(:name, 'sel1').selected?(/option 1/i)
58
64
  end
59
65
 
66
+ tag_method :test_selected_not_found, :fails_on_firefox
60
67
  def test_selected_not_found
61
- selectbox = $ie.select_list(:name, 'sel1')
62
- assert_raises(Watir::Exception::UnknownObjectException) {selectbox.selected?('Option Not Exists')}
68
+ selectbox = browser.select_list(:name, 'sel1')
69
+ assert_raises(Watir::Exception::UnknownObjectException) {selectbox.selected?("option doesn't exist")}
70
+ assert_raises(Watir::Exception::UnknownObjectException) {selectbox.selected?(/option doesn't exist/)}
63
71
  end
64
72
 
65
73
  end
66
74
 
67
- # Tests for the old interface
68
75
  class TC_Selectbox < Test::Unit::TestCase
69
76
  include Watir::Exception
70
77
 
71
78
  def setup
72
79
  goto_page "selectboxes1.html"
73
80
  end
74
-
75
- def test_selectBox_Exists
76
- assert($ie.selectBox(:name, "sel1").exists?)
77
- assert(!$ie.selectBox(:name, "missing").exists?)
78
- assert(!$ie.selectBox(:id, "missing").exists?)
79
- end
80
-
81
- def test_selectBox_enabled
82
- assert($ie.selectBox(:name, "sel1").enabled?)
83
- assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").enabled? }
84
- end
85
-
86
- def test_SelectList_class_name
87
- assert_raises(UnknownObjectException) { $ie.select_list(:name, "missing").class_name }
88
- assert_equal("list_style" , $ie.select_list(:name, "sel1").class_name)
89
- assert_equal("" , $ie.selectBox(:name, "sel2").class_name )
90
- end
91
-
92
- def test_selectBox_getAllContents
93
- assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").getAllContents }
94
- assert_equal( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
95
- $ie.selectBox(:name, "sel1").getAllContents)
96
- end
97
-
98
- def test_selectBox_getSelectedItems
99
- assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").getSelectedItems }
100
- assert_equal( ["Option 3" ] ,
101
- $ie.selectBox(:name, "sel1").getSelectedItems)
102
- assert_equal( ["Option 3" , "Option 6" ] ,
103
- $ie.selectBox(:name, "sel2").getSelectedItems)
104
- end
105
-
106
- def test_clearSelection
107
- assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").clearSelection }
108
- $ie.selectBox( :name , "sel1").clearSelection
109
-
110
- # the box sel1 has no ability to have a de-selected item
111
- assert_equal( ["Option 3" ] , $ie.selectBox(:name, "sel1").getSelectedItems)
112
-
113
- $ie.selectBox( :name , "sel2").clearSelection
114
- assert_equal( [ ] , $ie.selectBox(:name, "sel2").getSelectedItems)
115
- end
116
-
117
- def test_selectBox_select
118
- assert_raises(NoValueFoundException) { $ie.selectBox(:name, "sel1").select("missing item") }
119
- assert_raises(NoValueFoundException) { $ie.selectBox(:name, "sel1").select(/missing/) }
120
-
121
- # the select method keeps any currently selected items - use the clear selectcion method first
122
- $ie.selectBox( :name , "sel1").clearSelection
123
- $ie.selectBox( :name , "sel1").select("Option 1")
124
- assert_equal( ["Option 1" ] , $ie.selectBox(:name, "sel1").getSelectedItems)
125
-
126
- $ie.selectBox( :name , "sel1").clearSelection
127
- $ie.selectBox( :name , "sel1").select(/2/)
128
- assert_equal( ["Option 2" ] , $ie.selectBox(:name, "sel1").getSelectedItems)
129
-
130
- $ie.selectBox( :name , "sel2").clearSelection
131
- $ie.selectBox( :name , "sel2").select(/2/)
132
- $ie.selectBox( :name , "sel2").select(/4/)
133
- assert_equal( ["Option 2" , "Option 4" ] ,
134
- $ie.selectBox(:name, "sel2").getSelectedItems)
135
-
136
- # these are to test the onchange event
137
- # the event shouldnt get fired, as this is the selected item
138
- $ie.selectBox( :name , "sel3").select( /3/ )
139
- assert(!$ie.text.include?("Pass") )
140
- end
141
-
142
- def test_selectBox_select2
143
- # the event should get fired
144
- $ie.selectBox( :name , "sel3").select( /2/ )
145
- assert($ie.text.include?("PASS") )
146
- end
147
-
148
- def test_selectBox_select_using_value
149
- assert_raises(UnknownObjectException) { $ie.select_list(:name, "NoName").getSelectedItems }
150
- assert_raises(NoValueFoundException) { $ie.select_list(:name, "sel1").select_value("missing item") }
151
- assert_raises(NoValueFoundException) { $ie.select_list(:name, "sel1").select_value(/missing/) }
152
-
153
- # the select method keeps any currently selected items - use the clear selectcion method first
154
- $ie.select_list( :name , "sel1").clearSelection
155
- $ie.select_list( :name , "sel1").select_value("o1")
156
- assert_equal( ["Option 1" ] , $ie.select_list(:name, "sel1").getSelectedItems)
157
81
 
158
- $ie.select_list( :name , "sel1").clearSelection
159
- $ie.select_list( :name , "sel1").select_value(/2/)
160
- assert_equal( ["Option 2" ] , $ie.select_list(:name, "sel1").getSelectedItems)
161
-
162
- $ie.select_list( :name , "sel2").clearSelection
163
- $ie.select_list( :name , "sel2").select_value(/4/)
164
- $ie.select_list( :name , "sel2").select_value(/2/)
165
- assert_equal( ["Option 2" , "Option 4" ] ,
166
- $ie.select_list(:name, "sel2").getSelectedItems)
167
-
168
- # these are to test the onchange event
169
- # the event shouldnt get fired, as this is the selected item
170
- $ie.select_list( :name , "sel3").select_value( /3/ )
171
- assert(!$ie.text.include?("Pass") )
172
- end
173
-
174
82
  def test_select_list_select_using_value2
175
83
  # the event should get fired
176
- $ie.select_list( :name , "sel3").select_value( /2/ )
177
- assert($ie.text.include?("PASS") )
84
+ browser.select_list( :name , "sel3").select_value( /2/ )
85
+ assert(browser.text.include?("PASS") )
178
86
  end
179
87
 
180
88
  def test_select_list_properties
181
- assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).value }
182
- assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).name }
183
- assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).id }
184
- assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).disabled }
185
- assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).type }
89
+ assert_raises(UnknownObjectException) { browser.select_list(:index, 199).value }
90
+ assert_raises(UnknownObjectException) { browser.select_list(:index, 199).name }
91
+ assert_raises(UnknownObjectException) { browser.select_list(:index, 199).id }
92
+ assert_raises(UnknownObjectException) { browser.select_list(:index, 199).disabled }
93
+ assert_raises(UnknownObjectException) { browser.select_list(:index, 199).type }
186
94
 
187
- assert_equal("o3" , $ie.select_list(:index, 1).value)
188
- assert_equal("sel1" , $ie.select_list(:index, 1).name )
189
- assert_equal("" , $ie.select_list(:index, 1).id )
190
- assert_equal("select-one", $ie.select_list(:index, 1).type )
191
- assert_equal("select-multiple", $ie.select_list(:index, 2).type )
95
+ assert_equal("o3" , browser.select_list(:index, 1).value)
96
+ assert_equal("sel1" , browser.select_list(:index, 1).name )
97
+ assert_equal("" , browser.select_list(:index, 1).id )
98
+ assert_equal("select-one", browser.select_list(:index, 1).type )
99
+ assert_equal("select-multiple", browser.select_list(:index, 2).type )
192
100
 
193
- $ie.select_list(:index,1).select(/1/)
194
- assert_equal("o1" , $ie.select_list(:index, 1).value)
101
+ browser.select_list(:index,1).select(/1/)
102
+ assert_equal("o1" , browser.select_list(:index, 1).value)
195
103
 
196
- assert(! $ie.select_list(:index, 1).disabled )
197
- assert( $ie.select_list(:index, 4).disabled )
198
- assert( $ie.select_list(:id, 'selectbox_4').disabled )
104
+ assert_false( browser.select_list(:index, 1).disabled )
105
+ assert( browser.select_list(:index, 4).disabled )
106
+ assert( browser.select_list(:id, 'selectbox_4').disabled )
199
107
  end
200
108
 
201
109
  def test_select_list_iterator
202
- assert_equal(4, $ie.select_lists.length)
203
- assert_equal("o3" , $ie.select_lists[1].value)
204
- assert_equal("sel1" , $ie.select_lists[1].name )
205
- assert_equal("select-one", $ie.select_lists[1].type )
206
- assert_equal("select-multiple" , $ie.select_lists[2].type )
110
+ assert_equal(4, browser.select_lists.length)
111
+ assert_equal("o3" , browser.select_lists[1].value)
112
+ assert_equal("sel1" , browser.select_lists[1].name )
113
+ assert_equal("select-one", browser.select_lists[1].type )
114
+ assert_equal("select-multiple" , browser.select_lists[2].type )
207
115
 
208
116
  index=1
209
- $ie.select_lists.each do |l|
210
- assert_equal( $ie.select_list(:index, index).name , l.name )
211
- assert_equal( $ie.select_list(:index, index).id , l.id )
212
- assert_equal( $ie.select_list(:index, index).type , l.type )
213
- assert_equal( $ie.select_list(:index, index).value , l.value )
117
+ browser.select_lists.each do |l|
118
+ assert_equal( browser.select_list(:index, index).name , l.name )
119
+ assert_equal( browser.select_list(:index, index).id , l.id )
120
+ assert_equal( browser.select_list(:index, index).type , l.type )
121
+ assert_equal( browser.select_list(:index, index).value , l.value )
214
122
  index+=1
215
123
  end
216
- assert_equal( index-1, $ie.select_lists.length)
124
+ assert_equal( index-1, browser.select_lists.length)
217
125
  end
218
126
  end
219
127
 
@@ -224,8 +132,8 @@ class TC_Select_Options < Test::Unit::TestCase
224
132
  end
225
133
 
226
134
  def test_options_text
227
- $ie.select_list(:name, 'op_numhits').option(:text, '>=').select
228
- assert($ie.select_list(:name, 'op_numhits').option(:text, '>=').selected)
135
+ browser.select_list(:name, 'op_numhits').option(:text, '>=').select
136
+ assert(browser.select_list(:name, 'op_numhits').option(:text, '>=').selected)
229
137
  end
230
138
  end
231
139