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 Check Boxes
2
- # revision: $Revision: 1348 $
2
+ # revision: $Revision: 1542 $
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_CheckBox < Test::Unit::TestCase
@@ -10,153 +10,167 @@ class TC_CheckBox < Test::Unit::TestCase
10
10
  def setup
11
11
  goto_page "checkboxes1.html"
12
12
  end
13
+
14
+ def test_checkbox_exceptions
15
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").id }
16
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").name }
17
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").disabled }
18
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").type }
19
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").value }
20
+ end
13
21
 
22
+ def test_checkbox_properties_with_index
23
+ assert_equal("box1", browser.checkbox(:index, 1).name )
24
+ assert_equal("", browser.checkbox(:index, 1).id )
25
+ assert_equal("checkbox", browser.checkbox(:index, 1).type )
26
+ assert_equal("on", browser.checkbox(:index, 1).value )
27
+ assert_equal(false, browser.checkbox(:index, 1).disabled )
28
+ end
14
29
  def test_checkbox_properties
15
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.checkbox(:name, "noName").id }
16
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.checkbox(:name, "noName").name }
17
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.checkbox(:name, "noName").disabled }
18
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.checkbox(:name, "noName").type }
19
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.checkbox(:name, "noName").value }
20
-
21
- assert_equal("box1" , $ie.checkbox(:index, 1).name )
22
- assert_equal("" , $ie.checkbox(:index, 1).id )
23
- assert_equal("checkbox" , $ie.checkbox(:index, 1).type )
24
- assert_equal("on" , $ie.checkbox(:index, 1).value )
25
- assert_equal(false , $ie.checkbox(:index, 1).disabled )
26
-
27
- assert_equal("check_box_style" , $ie.checkbox(:name, "box1").class_name)
28
- assert_equal("" , $ie.checkbox(:name, "box2").class_name)
29
-
30
- assert_equal("1" , $ie.checkbox(:name,"box4").value )
31
- assert_equal("3" , $ie.checkbox(:name,"box4" , 3).value )
32
- assert($ie.checkbox(:name, "box6").exists?)
33
- assert_equal("checkbox" , $ie.checkbox(:name,"box4" , 3).type )
34
- assert_equal("checkbox" , $ie.checkbox(:name,"box6" , 'Milk').type )
35
- assert_equal(false , $ie.checkbox(:name,"box4" , 3).disabled )
36
- assert_equal("" , $ie.checkbox(:name,"box4" , 3).id )
37
-
38
- assert_equal("box4-value5" , $ie.checkbox(:name,"box4" , 5).title)
39
- assert_equal("" , $ie.checkbox(:name,"box4" , 4).title)
30
+ assert_equal("check_box_style", browser.checkbox(:name, "box1").class_name)
31
+ assert_equal("", browser.checkbox(:name, "box2").class_name)
32
+
33
+ assert_equal("1", browser.checkbox(:name, "box4").value )
34
+ assert_equal("3", browser.checkbox(:name, "box4", 3).value )
35
+ assert(browser.checkbox(:name, "box6").exists?)
36
+ assert_equal("checkbox", browser.checkbox(:name, "box4", 3).type )
37
+ assert_equal("checkbox", browser.checkbox(:name, "box6", 'Milk').type )
38
+ assert_equal(false, browser.checkbox(:name, "box4", 3).disabled )
39
+ assert_equal("", browser.checkbox(:name, "box4", 3).id )
40
+
41
+ assert_equal("box4-value5", browser.checkbox(:name, "box4", 5).title)
42
+ assert_equal("", browser.checkbox(:name,"box4", 4).title)
40
43
  end
41
44
 
42
45
  def test_onClick
43
- assert(!$ie.button(:value , "foo").enabled?)
44
- $ie.checkBox(:name, "box5").set
45
- assert($ie.button(:value , "foo").enabled?)
46
+ assert_false(browser.button(:value, "foo").enabled?)
47
+ browser.checkbox(:name, "box5").set
48
+ assert(browser.button(:value, "foo").enabled?)
46
49
 
47
- $ie.checkBox(:name, "box5").clear
48
- assert(!$ie.button(:value , "foo").enabled?)
50
+ browser.checkbox(:name, "box5").clear
51
+ assert_false(browser.button(:value, "foo").enabled?)
49
52
 
50
- $ie.checkBox(:name, "box5").clear
51
- assert(!$ie.button(:value , "foo").enabled?)
53
+ browser.checkbox(:name, "box5").clear
54
+ assert_false(browser.button(:value, "foo").enabled?)
52
55
  end
53
56
 
54
57
  def test_CheckBox_Exists
55
- assert($ie.checkBox(:name, "box1").exists?)
56
- assert(!$ie.checkBox(:name, "missing").exists?)
58
+ assert(browser.checkbox(:name, "box1").exists?)
59
+ assert_false(browser.checkbox(:name, "missing").exists?)
57
60
 
58
- assert($ie.checkbox(:name, "box4" , 1).exists?)
59
- assert(!$ie.checkbox(:name, "box4" , 22).exists?)
61
+ assert(browser.checkbox(:name, "box4", 1).exists?)
62
+ assert_false(browser.checkbox(:name, "box4", 22).exists?)
60
63
  end
61
64
 
62
65
  def test_checkbox_Enabled
63
- assert_raises(UnknownObjectException) { $ie.checkbox(:name, "noName").enabled? }
64
- assert_raises(UnknownObjectException) { $ie.checkbox(:id, "noName").enabled? }
65
- assert_raises(UnknownObjectException) { $ie.checkbox(:name, "box4" , 6).enabled? }
66
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").enabled? }
67
+ assert_raises(UnknownObjectException) { browser.checkbox(:id, "noName").enabled? }
68
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "box4" , 6).enabled? }
66
69
 
67
- assert($ie.checkbox(:name, "box1").enabled?)
68
- assert(!$ie.checkbox(:name, "box2").enabled?)
70
+ assert(browser.checkbox(:name, "box1").enabled?)
71
+ assert_false(browser.checkbox(:name, "box2").enabled?)
69
72
 
70
- assert($ie.checkbox(:name, "box4", 4).enabled?)
71
- assert(!$ie.checkbox(:name, "box4" , 5 ).enabled?)
73
+ assert(browser.checkbox(:name, "box4", 4).enabled?)
74
+ assert_false(browser.checkbox(:name, "box4", 5 ).enabled?)
72
75
  end
73
76
 
74
77
  def test_checkbox_isSet
75
- assert_raises(UnknownObjectException ) { $ie.checkbox(:name, "noName").isSet? }
78
+ assert_raises(UnknownObjectException ) { browser.checkbox(:name, "noName").isSet? }
76
79
 
77
- assert(!$ie.checkbox(:name, "box1").isSet?)
78
- assert(!$ie.checkbox(:name, "box2").isSet?)
79
- assert($ie.checkbox(:name, "box3").isSet?)
80
+ assert_false(browser.checkbox(:name, "box1").isSet?)
81
+ assert_false(browser.checkbox(:name, "box2").isSet?)
82
+ assert(browser.checkbox(:name, "box3").isSet?)
80
83
 
81
- assert(!$ie.checkbox(:name, "box4" , 2 ).isSet?)
82
- assert($ie.checkbox(:name, "box4" , 1 ).isSet?)
83
- assert(!$ie.checkbox(:name, 'box6', 'Milk').isSet?)
84
+ assert_false(browser.checkbox(:name, "box4", 2 ).isSet?)
85
+ assert(browser.checkbox(:name, "box4", 1 ).isSet?)
86
+
87
+ assert_false(browser.checkbox(:name, 'box6', 'Milk').isSet?)
84
88
  end
85
89
 
86
90
  def test_checkbox_clear
87
- assert_raises(UnknownObjectException) { $ie.checkbox(:name, "noName").clear }
88
- $ie.checkbox(:name, "box1").clear
89
- assert(!$ie.checkbox(:name, "box1").isSet?)
91
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").clear }
92
+ browser.checkbox(:name, "box1").clear
93
+ assert_false(browser.checkbox(:name, "box1").isSet?)
90
94
 
91
- assert_raises(ObjectDisabledException) { $ie.checkbox(:name, "box2").clear }
92
- assert(!$ie.checkbox(:name, "box2").isSet?)
95
+ assert_raises(ObjectDisabledException) { browser.checkbox(:name, "box2").clear }
96
+ assert_false(browser.checkbox(:name, "box2").isSet?)
93
97
 
94
- $ie.checkbox(:name, "box3").clear
95
- assert(!$ie.checkbox(:name, "box3").isSet?)
98
+ browser.checkbox(:name, "box3").clear
99
+ assert_false(browser.checkbox(:name, "box3").isSet?)
96
100
 
97
- $ie.checkbox(:name, "box4" , 1).clear
98
- assert(!$ie.checkbox(:name, "box4" , 1).isSet?)
101
+ browser.checkbox(:name, "box4" , 1).clear
102
+ assert_false(browser.checkbox(:name, "box4", 1).isSet?)
99
103
 
100
- $ie.checkbox(:name, "box6" , 'Tea').clear
101
- assert(!$ie.checkbox(:name, "box6" , 'Tea').isSet?)
102
-
104
+ browser.checkbox(:name, "box6" , 'Tea').clear
105
+ assert_false(browser.checkbox(:name, "box6", 'Tea').isSet?)
103
106
  end
104
107
 
105
108
  def test_checkbox_getState
106
- assert_raises(UnknownObjectException) { $ie.checkbox(:name, "noName").getState }
107
- assert_equal( false , $ie.checkbox(:name, "box1").getState )
108
- assert_equal( true , $ie.checkbox(:name, "box3").getState)
109
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").getState }
110
+ assert_equal( false, browser.checkbox(:name, "box1").getState )
111
+ assert_equal( true, browser.checkbox(:name, "box3").getState)
109
112
 
110
113
  # checkboxes that have the same name but different values
111
- assert_equal( false , $ie.checkbox(:name, "box4" , 2).getState )
112
- assert_equal( true , $ie.checkbox(:name, "box4" , 1).getState)
114
+ assert_equal( false, browser.checkbox(:name, "box4", 2).getState )
115
+ assert_equal( true, browser.checkbox(:name, "box4", 1).getState)
113
116
  end
114
117
 
115
118
  def test_checkbox_set
116
- assert_raises(UnknownObjectException) { $ie.checkbox(:name, "noName").set }
117
- $ie.checkbox(:name, "box1").set
118
- assert($ie.checkbox(:name, "box1").isSet?)
119
+ assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").set }
120
+ browser.checkbox(:name, "box1").set
121
+ assert(browser.checkbox(:name, "box1").isSet?)
119
122
 
120
- assert_raises(ObjectDisabledException) { $ie.checkbox(:name, "box2").set }
123
+ assert_raises(ObjectDisabledException) { browser.checkbox(:name, "box2").set }
121
124
 
122
- $ie.checkbox(:name, "box3").set
123
- assert($ie.checkbox(:name, "box3").isSet?)
125
+ browser.checkbox(:name, "box3").set
126
+ assert(browser.checkbox(:name, "box3").isSet?)
124
127
 
125
128
  # checkboxes that have the same name but different values
126
- $ie.checkbox(:name, "box4" , 3).set
127
- assert($ie.checkbox(:name, "box4" , 3).isSet?)
129
+ browser.checkbox(:name, "box4", 3).set
130
+ assert(browser.checkbox(:name, "box4", 3).isSet?)
128
131
 
129
132
  # test set using the optinal true/false
130
133
  # assumes the checkbox is already checked
131
- $ie.checkbox(:name, "box1").set( false )
132
- assert(!$ie.checkbox(:name, "box1").isSet?)
134
+ browser.checkbox(:name, "box1").set( false )
135
+ assert_false(browser.checkbox(:name, "box1").isSet?)
133
136
 
134
- $ie.checkbox(:name, "box1").set( true )
135
- assert($ie.checkbox(:name, "box1").isSet?)
137
+ browser.checkbox(:name, "box1").set( true )
138
+ assert(browser.checkbox(:name, "box1").isSet?)
136
139
 
137
- $ie.checkbox(:name, "box6", 'Tea').set( false )
138
- assert(!$ie.checkbox(:name, "box6", 'Tea').isSet?)
139
-
140
- $ie.checkbox(:name, "box6", 'Tea').set( true )
141
- assert($ie.checkbox(:name, "box6", 'Tea').isSet?)
140
+ browser.checkbox(:name, "box6", 'Tea').set( false )
141
+ assert_false(browser.checkbox(:name, "box6", 'Tea').isSet?)
142
142
 
143
+ browser.checkbox(:name, "box6", 'Tea').set( true )
144
+ assert(browser.checkbox(:name, "box6", 'Tea').isSet?)
145
+ end
146
+
147
+ def test_checkbox_specifying_value
148
+ browser.checkbox(:name => "box6", :value => 'Tea').set( false )
149
+ assert_false(browser.checkbox(:name => "box6", :value => 'Tea').isSet?)
150
+ end
151
+
152
+ def test_checkboxes_access
153
+ assert_equal("box1" , browser.checkboxes[1].name )
143
154
  end
144
155
 
145
156
  def test_checkbox_iterator
146
-
147
- assert_equal(13, $ie.checkboxes.length)
148
- assert_equal("box1" , $ie.checkboxes[1].name )
149
-
150
- index=1
151
- $ie.checkboxes.each do |c|
152
- assert_equal( $ie.checkbox(:index, index).name , c.name )
153
- assert_equal( $ie.checkbox(:index, index).id, c.id )
154
- assert_equal( $ie.checkbox(:index, index).value, c.value )
155
- index+=1
157
+ assert_equal(13, browser.checkboxes.length)
158
+ index = 1
159
+ browser.checkboxes.each do |c|
160
+ # puts "#{index}: #{c.name}"
161
+ assert_equal( browser.checkbox(:index, index).name , c.name )
162
+ assert_equal( browser.checkbox(:index, index).id, c.id )
163
+ assert_equal( browser.checkbox(:index, index).value, c.value )
164
+ index += 1
156
165
  end
157
- assert_equal(index-1, $ie.checkboxes.length)
158
-
166
+ assert_equal(index - 1, browser.checkboxes.length)
167
+ end
168
+
169
+ # bug 217
170
+ tag_method :test_checkbox_access_by_ole_object, :fails_on_firefox
171
+ def test_checkbox_access_by_ole_object
172
+ ole = browser.checkboxes[1].locate
173
+ browser.checkbox(:ole_object, ole).flash
159
174
  end
160
-
161
175
 
162
176
  end
@@ -1,7 +1,7 @@
1
1
  # feature tests for Check 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_CheckBox_XPath < Test::Unit::TestCase
@@ -12,96 +12,96 @@ class TC_CheckBox_XPath < Test::Unit::TestCase
12
12
  end
13
13
 
14
14
  def test_checkbox_properties
15
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.checkbox(:xpath , "//input[@name='noName']/").id }
16
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.checkbox(:xpath , "//input[@name='noName']/").name }
17
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.checkbox(:xpath , "//input[@name='noName']/").disabled }
18
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.checkbox(:xpath , "//input[@name='noName']/").type }
19
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.checkbox(:xpath , "//input[@name='noName']/").value }
20
-
21
- assert_equal("1" , $ie.checkbox(:xpath , "//input[@name='box4']/").value )
22
- assert_equal("3" , $ie.checkbox(:xpath , "//input[@name='box4' and @value='3']/").value )
23
- assert_equal("checkbox" , $ie.checkbox(:xpath , "//input[@name='box4' and @value='3']/").type )
24
- assert_equal(false , $ie.checkbox(:xpath , "//input[@name='box4' and @value='3']/").disabled )
25
- assert_equal("" , $ie.checkbox(:xpath , "//input[@name='box4' and @value='3']/").id )
26
-
27
- assert_equal("box4-value5" , $ie.checkbox(:xpath , "//input[@name='box4' and @value='5']/").title)
28
- assert_equal("" , $ie.checkbox(:xpath , "//input[@name='box4' and @value='4']/").title)
15
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").id }
16
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").name }
17
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").disabled }
18
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").type }
19
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").value }
20
+
21
+ assert_equal("1" , browser.checkbox(:xpath , "//input[@name='box4']/").value )
22
+ assert_equal("3" , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']/").value )
23
+ assert_equal("checkbox" , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']/").type )
24
+ assert_equal(false , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']/").disabled )
25
+ assert_equal("" , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']/").id )
26
+
27
+ assert_equal("box4-value5" , browser.checkbox(:xpath , "//input[@name='box4' and @value='5']/").title)
28
+ assert_equal("" , browser.checkbox(:xpath , "//input[@name='box4' and @value='4']/").title)
29
29
  end
30
30
 
31
31
  def test_CheckBox_Exists
32
- assert($ie.checkbox(:xpath , "//input[@name='box4' and @value='1']/").exists?)
33
- assert(!$ie.checkbox(:xpath , "//input[@name='box4' and @value='22']/").exists?)
32
+ assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='1']/").exists?)
33
+ assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='22']/").exists?)
34
34
  end
35
35
 
36
36
  def test_checkbox_Enabled
37
- assert_raises(UnknownObjectException) { $ie.checkbox(:xpath , "//input[@name='noName']/").enabled? }
38
- assert_raises(UnknownObjectException) { $ie.checkbox(:xpath , "//input[@id='noName']/").enabled? }
39
- assert_raises(UnknownObjectException) { $ie.checkbox(:xpath , "//input[@name='box4' and @value='6']/").enabled? }
37
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").enabled? }
38
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@id='noName']/").enabled? }
39
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='box4' and @value='6']/").enabled? }
40
40
 
41
- assert($ie.checkbox(:xpath , "//input[@name='box1']/").enabled?)
42
- assert(!$ie.checkbox(:xpath , "//input[@name='box2']/").enabled?)
41
+ assert(browser.checkbox(:xpath , "//input[@name='box1']/").enabled?)
42
+ assert_false(browser.checkbox(:xpath , "//input[@name='box2']/").enabled?)
43
43
 
44
- assert($ie.checkbox(:xpath , "//input[@name='box4' and @value='4']/").enabled?)
45
- assert(!$ie.checkbox(:xpath , "//input[@name='box4' and @value='5']/").enabled?)
44
+ assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='4']/").enabled?)
45
+ assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='5']/").enabled?)
46
46
  end
47
47
 
48
48
  def test_checkbox_isSet
49
- assert_raises(UnknownObjectException ) { $ie.checkbox(:xpath , "//input[@name='noName']/").isSet? }
49
+ assert_raises(UnknownObjectException ) { browser.checkbox(:xpath , "//input[@name='noName']/").isSet? }
50
50
 
51
- assert(!$ie.checkbox(:xpath , "//input[@name='box1']/").isSet?)
52
- assert(!$ie.checkbox(:xpath , "//input[@name='box2']/").isSet?)
53
- assert($ie.checkbox(:xpath , "//input[@name='box3']/").isSet?)
51
+ assert_false(browser.checkbox(:xpath , "//input[@name='box1']/").isSet?)
52
+ assert_false(browser.checkbox(:xpath , "//input[@name='box2']/").isSet?)
53
+ assert(browser.checkbox(:xpath , "//input[@name='box3']/").isSet?)
54
54
 
55
- assert(!$ie.checkbox(:xpath , "//input[@name='box4' and @value='2']/").isSet?)
56
- assert($ie.checkbox(:xpath , "//input[@name='box4' and @value='1']/").isSet?)
55
+ assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='2']/").isSet?)
56
+ assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='1']/").isSet?)
57
57
  end
58
58
 
59
59
  def test_checkbox_clear
60
- assert_raises(UnknownObjectException) { $ie.checkbox(:xpath , "//input[@name='noName']/").clear }
61
- $ie.checkbox(:xpath , "//input[@name='box1']/").clear
62
- assert(!$ie.checkbox(:xpath , "//input[@name='box1']/").isSet?)
60
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").clear }
61
+ browser.checkbox(:xpath , "//input[@name='box1']/").clear
62
+ assert_false(browser.checkbox(:xpath , "//input[@name='box1']/").isSet?)
63
63
 
64
- assert_raises(ObjectDisabledException) { $ie.checkbox(:xpath , "//input[@name='box2']/").clear }
65
- assert(!$ie.checkbox(:xpath , "//input[@name='box2']/").isSet?)
64
+ assert_raises(ObjectDisabledException) { browser.checkbox(:xpath , "//input[@name='box2']/").clear }
65
+ assert_false(browser.checkbox(:xpath , "//input[@name='box2']/").isSet?)
66
66
 
67
- $ie.checkbox(:xpath , "//input[@name='box3']/").clear
68
- assert(!$ie.checkbox(:xpath , "//input[@name='box3']/").isSet?)
67
+ browser.checkbox(:xpath , "//input[@name='box3']/").clear
68
+ assert_false(browser.checkbox(:xpath , "//input[@name='box3']/").isSet?)
69
69
 
70
- $ie.checkbox(:xpath , "//input[@name='box4' and @value='1']/").clear
71
- assert(!$ie.checkbox(:xpath , "//input[@name='box4' and @value='1']/").isSet?)
70
+ browser.checkbox(:xpath , "//input[@name='box4' and @value='1']/").clear
71
+ assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='1']/").isSet?)
72
72
  end
73
73
 
74
74
  def test_checkbox_getState
75
- assert_raises(UnknownObjectException) { $ie.checkbox(:xpath , "//input[@name='noName']/").getState }
76
- assert_equal( false , $ie.checkbox(:xpath , "//input[@name='box1']/").getState )
77
- assert_equal( true , $ie.checkbox(:xpath , "//input[@name='box3']/").getState)
75
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").getState }
76
+ assert_equal( false , browser.checkbox(:xpath , "//input[@name='box1']/").getState )
77
+ assert_equal( true , browser.checkbox(:xpath , "//input[@name='box3']/").getState)
78
78
 
79
79
  # checkboxes that have the same name but different values
80
- assert_equal( false , $ie.checkbox(:xpath , "//input[@name='box4' and @value='2']/").getState )
81
- assert_equal( true , $ie.checkbox(:xpath , "//input[@name='box4' and @value='1']/").getState)
80
+ assert_equal( false , browser.checkbox(:xpath , "//input[@name='box4' and @value='2']/").getState )
81
+ assert_equal( true , browser.checkbox(:xpath , "//input[@name='box4' and @value='1']/").getState)
82
82
  end
83
83
 
84
84
  def test_checkbox_set
85
- assert_raises(UnknownObjectException) { $ie.checkbox(:xpath , "//input[@name='noName']/").set }
86
- $ie.checkbox(:xpath , "//input[@name='box1']/").set
87
- assert($ie.checkbox(:xpath , "//input[@name='box1']/").isSet?)
85
+ assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']/").set }
86
+ browser.checkbox(:xpath , "//input[@name='box1']/").set
87
+ assert(browser.checkbox(:xpath , "//input[@name='box1']/").isSet?)
88
88
 
89
- assert_raises(ObjectDisabledException) { $ie.checkbox(:xpath , "//input[@name='box2']/").set }
89
+ assert_raises(ObjectDisabledException) { browser.checkbox(:xpath , "//input[@name='box2']/").set }
90
90
 
91
- $ie.checkbox(:xpath , "//input[@name='box3']/").set
92
- assert($ie.checkbox(:xpath , "//input[@name='box3']/").isSet?)
91
+ browser.checkbox(:xpath , "//input[@name='box3']/").set
92
+ assert(browser.checkbox(:xpath , "//input[@name='box3']/").isSet?)
93
93
 
94
94
  # checkboxes that have the same name but different values
95
- $ie.checkbox(:xpath , "//input[@name='box4' and @value='3']/").set
96
- assert($ie.checkbox(:xpath , "//input[@name='box4' and @value='3']/").isSet?)
95
+ browser.checkbox(:xpath , "//input[@name='box4' and @value='3']/").set
96
+ assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='3']/").isSet?)
97
97
 
98
98
  # test set using the optinal true/false
99
99
  # assumes the checkbox is already checked
100
- $ie.checkbox(:xpath , "//input[@name='box1']/").set( false )
101
- assert(!$ie.checkbox(:xpath , "//input[@name='box1']/").isSet?)
100
+ browser.checkbox(:xpath , "//input[@name='box1']/").set( false )
101
+ assert_false(browser.checkbox(:xpath , "//input[@name='box1']/").isSet?)
102
102
 
103
- $ie.checkbox(:xpath , "//input[@name='box1']/").set( true )
104
- assert($ie.checkbox(:xpath , "//input[@name='box1']/").isSet?)
103
+ browser.checkbox(:xpath , "//input[@name='box1']/").set( true )
104
+ assert(browser.checkbox(:xpath , "//input[@name='box1']/").isSet?)
105
105
 
106
106
  end
107
107
  end
@@ -1,13 +1,16 @@
1
- # these are the tests that run reliably and invisibly
2
-
3
- TOPDIR = File.join(File.dirname(__FILE__), '..')
4
- $LOAD_PATH.unshift TOPDIR
5
-
6
- require 'watir'
1
+ # these are the non-xpath tests that do not need to be visible
7
2
 
8
3
  $HIDE_IE = true
9
4
 
5
+ TOPDIR = File.join(File.dirname(__FILE__), '..')
6
+
7
+ $LOAD_PATH.unshift TOPDIR
10
8
  require 'unittests/setup'
11
9
 
12
10
  Dir.chdir TOPDIR
13
- $core_tests.each {|x| require x}
11
+ $all_tests.each {|x| require x}
12
+
13
+ Watir::UnitTest.filter_out do |test|
14
+ test.class.to_s =~ /xpath/i
15
+ end
16
+ Watir::UnitTest.filter_out_tests_tagged :must_be_visible