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 Forms
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_Forms2_XPath < Test::Unit::TestCase
@@ -10,28 +10,28 @@ class TC_Forms2_XPath < Test::Unit::TestCase
10
10
  end
11
11
 
12
12
  def test_Form_Exists
13
- assert($ie.form(:xpath , "//form[@name='test2']/").exists?)
14
- assert(!$ie.form(:xpath , "//form[@name='missing']/").exists?)
13
+ assert(browser.form(:xpath , "//form[@name='test2']/").exists?)
14
+ assert_false(browser.form(:xpath , "//form[@name='missing']/").exists?)
15
15
 
16
- assert($ie.form(:xpath , "//form[@method='get']/").exists?)
17
- assert(!$ie.form(:xpath , "//form[@method='missing']/").exists?)
16
+ assert(browser.form(:xpath , "//form[@method='get']/").exists?)
17
+ assert_false(browser.form(:xpath , "//form[@method='missing']/").exists?)
18
18
 
19
- assert($ie.form(:xpath , "//form[@action='pass.html']/").exists?)
20
- assert(!$ie.form(:xpath , "//form[@action='missing']/").exists?)
19
+ assert(browser.form(:xpath , "//form[@action='pass.html']/").exists?)
20
+ assert_false(browser.form(:xpath , "//form[@action='missing']/").exists?)
21
21
  end
22
22
 
23
23
  def test_ButtonInForm
24
- assert($ie.form(:xpath , "//form[@name='test2']/").button(:caption , "Submit").exists?)
24
+ assert(browser.form(:xpath , "//form[@name='test2']/").button(:caption , "Submit").exists?)
25
25
  end
26
26
  end
27
27
 
28
28
  require 'unittests/iostring'
29
- class TC_Form_Display < Test::Unit::TestCase
29
+ class TC_Form_Display_XPath < Test::Unit::TestCase
30
30
  include MockStdoutTestCase
31
31
  def test_showforms
32
32
  goto_page "forms2.html"
33
33
  $stdout = @mockout
34
- $ie.show_forms
34
+ browser.show_forms
35
35
  assert_equal(<<END_OF_MESSAGE, @mockout)
36
36
  There are 4 forms
37
37
  Form name:
@@ -54,125 +54,125 @@ END_OF_MESSAGE
54
54
  end
55
55
  end
56
56
 
57
- class TC_Forms3 < Test::Unit::TestCase
57
+ class TC_Forms3_XPath < Test::Unit::TestCase
58
58
  def setup
59
59
  goto_page "forms3.html"
60
60
  end
61
61
 
62
62
  def test_Form_Exists
63
- assert($ie.form(:xpath , "//form[@name='test2']/").exists?)
64
- assert(!$ie.form(:xpath , "//form[@name='missing']/").exists?)
63
+ assert(browser.form(:xpath , "//form[@name='test2']/").exists?)
64
+ assert_false(browser.form(:xpath , "//form[@name='missing']/").exists?)
65
65
 
66
- assert($ie.form(:xpath , "//form[@method='get']/").exists?)
67
- assert(!$ie.form(:xpath , "//form[@method='missing']/").exists?)
66
+ assert(browser.form(:xpath , "//form[@method='get']/").exists?)
67
+ assert_false(browser.form(:xpath , "//form[@method='missing']/").exists?)
68
68
 
69
- assert($ie.form(:xpath , "//form[@action='pass.html']/").exists?)
70
- assert(!$ie.form(:xpath , "//form[@action='missing']/").exists?)
69
+ assert(browser.form(:xpath , "//form[@action='pass.html']/").exists?)
70
+ assert_false(browser.form(:xpath , "//form[@action='missing']/").exists?)
71
71
  end
72
72
 
73
73
  def test_getObject_when_non_watir_object_before_it
74
74
  # test for bug reported by Scott Pack, http://rubyforge.org/pipermail/wtr-general/2005-June/002223.html
75
- assert_equal("check1" , $ie.checkbox(:index,1).name )
75
+ assert_equal("check1" , browser.checkbox(:index,1).name )
76
76
  end
77
77
 
78
78
  def test_showforms # add verification of output!
79
- $ie.show_forms
79
+ browser.show_forms
80
80
  end
81
81
 
82
82
  def test_reset
83
83
 
84
- $ie.text_field(:id, "t1").set("Hello, reset test!")
85
- assert_equal($ie.text_field(:id, 't1').value, 'Hello, reset test!')
84
+ browser.text_field(:id, "t1").set("Hello, reset test!")
85
+ assert_equal(browser.text_field(:id, 't1').value, 'Hello, reset test!')
86
86
 
87
- $ie.button(:caption, "Reset").click
88
- assert_equal("" , $ie.text_field(:id, 't1').value )
87
+ browser.button(:caption, "Reset").click
88
+ assert_equal("" , browser.text_field(:id, 't1').value )
89
89
 
90
90
  # also verify it works under a form
91
- $ie.text_field(:id, "t1").set("reset test - using a form")
92
- assert_equal($ie.text_field(:id, 't1').value, 'reset test - using a form')
91
+ browser.text_field(:id, "t1").set("reset test - using a form")
92
+ assert_equal(browser.text_field(:id, 't1').value, 'reset test - using a form')
93
93
 
94
94
  # also verify it works under a form, this time using the :id attribute
95
- $ie.text_field(:id, "t1").set("reset test - using a form")
96
- assert_equal($ie.text_field(:id, 't1').value, 'reset test - using a form')
95
+ browser.text_field(:id, "t1").set("reset test - using a form")
96
+ assert_equal(browser.text_field(:id, 't1').value, 'reset test - using a form')
97
97
  end
98
98
 
99
99
  def test_flash1
100
- $ie.form(:xpath , "//form[@name='test2']/").button(:caption , "Submit").flash
100
+ browser.form(:xpath , "//form[@name='test2']/").button(:caption , "Submit").flash
101
101
  end
102
102
 
103
103
  def test_objects_with_same_name
104
- assert_equal('textfield' ,$ie.text_field( :name , 'g1').value )
105
- assert_equal('button' ,$ie.button( :name , 'g1').value )
106
- assert_equal('1' ,$ie.checkbox( :name , 'g1').value )
107
- assert_equal('2' ,$ie.radio( :name , 'g1').value )
104
+ assert_equal('textfield' ,browser.text_field( :name , 'g1').value )
105
+ assert_equal('button' ,browser.button( :name , 'g1').value )
106
+ assert_equal('1' ,browser.checkbox( :name , 'g1').value )
107
+ assert_equal('2' ,browser.radio( :name , 'g1').value )
108
108
 
109
- assert_equal('textfield_id' ,$ie.text_field( :id , 'g1').value )
110
- assert_equal('button_id' ,$ie.button( :id , 'g1').value )
111
- assert_equal('1_id' ,$ie.checkbox( :id , 'g1').value )
112
- assert_equal('2_id' ,$ie.radio( :id , 'g1').value )
109
+ assert_equal('textfield_id' ,browser.text_field( :id , 'g1').value )
110
+ assert_equal('button_id' ,browser.button( :id , 'g1').value )
111
+ assert_equal('1_id' ,browser.checkbox( :id , 'g1').value )
112
+ assert_equal('2_id' ,browser.radio( :id , 'g1').value )
113
113
  end
114
114
 
115
115
  def test_flash2
116
- $ie.button(:value, 'Click Me').flash
117
- assert_raises( Watir::UnknownObjectException ) { $ie.text_field( :name , 'g177').flash }
116
+ browser.button(:value, 'Click Me').flash
117
+ assert_raises( Watir::UnknownObjectException ) { browser.text_field( :name , 'g177').flash }
118
118
  end
119
119
 
120
120
  def test_showElements # add verification!
121
- $ie.show_all_objects
121
+ browser.show_all_objects
122
122
  end
123
123
 
124
124
  def test_showText
125
- puts $ie.text
125
+ puts browser.text
126
126
  end
127
127
 
128
128
  def test_showHTML
129
- puts $ie.html
129
+ puts browser.html
130
130
  end
131
131
 
132
132
  def test_submitWithImage
133
- assert( $ie.button(:alt , "submit").exists? )
134
- assert( $ie.button(:alt , /sub/).exists? )
133
+ assert( browser.button(:alt , "submit").exists? )
134
+ assert( browser.button(:alt , /sub/).exists? )
135
135
 
136
- assert(! $ie.button(:alt , "missing").exists? )
137
- assert(! $ie.button(:alt , /missing/).exists? )
136
+ assert_false( browser.button(:alt , "missing").exists? )
137
+ assert_false( browser.button(:alt , /missing/).exists? )
138
138
 
139
- #assert( $ie.button(:src , "file:///#{$myDir}/html/images/button.jpg").exists? ) # this doesnt work for everybody
140
- assert( $ie.button(:src , /button/).exists? )
139
+ #assert( browser.button(:src , "file:///#{$myDir}/html/images/button.jpg").exists? ) # this doesnt work for everybody
140
+ assert( browser.button(:src , /button/).exists? )
141
141
 
142
- assert(! $ie.button(:src , "missing").exists? )
143
- assert(! $ie.button(:src , /missing/).exists? )
144
- assert_nothing_raised("raised an exception when it shouldnt have") { $ie.button(:src , /button/).click }
142
+ assert_false( browser.button(:src , "missing").exists? )
143
+ assert_false( browser.button(:src , /missing/).exists? )
144
+ assert_nothing_raised("raised an exception when it shouldnt have") { browser.button(:src , /button/).click }
145
145
 
146
- assert( $ie.contains_text("PASS") )
146
+ assert( browser.contains_text("PASS") )
147
147
  end
148
148
  end
149
149
 
150
- class TC_Forms4 < Test::Unit::TestCase
150
+ class TC_Forms4_XPath < Test::Unit::TestCase
151
151
  def setup
152
152
  goto_page "forms4.html"
153
153
  end
154
154
 
155
155
  def test_find_text_field_ignoring_form
156
- assert_equal($ie.text_field(:name, 'name').value, 'apple') # should it raise a not-unique error instead?
156
+ assert_equal(browser.text_field(:name, 'name').value, 'apple') # should it raise a not-unique error instead?
157
157
  end
158
158
 
159
159
  def test_correct_form_field_is_found_using_form_name
160
- assert_equal($ie.form(:xpath , "//form[@name='apple_form']/").text_field(:name, 'name').value, 'apple')
161
- assert_equal($ie.form(:xpath , "//form[@name='banana_form']/").text_field(:name, 'name').value, 'banana')
160
+ assert_equal(browser.form(:xpath , "//form[@name='apple_form']/").text_field(:name, 'name').value, 'apple')
161
+ assert_equal(browser.form(:xpath , "//form[@name='banana_form']/").text_field(:name, 'name').value, 'banana')
162
162
  end
163
163
 
164
164
  def test_using_text_on_form
165
- $ie.form(:xpath , "//form[@name='apple_form']/").text_field(:name, 'name').set('strudel')
166
- assert_equal($ie.form(:index, 1).text_field(:name, 'name').value, 'strudel')
165
+ browser.form(:xpath , "//form[@name='apple_form']/").text_field(:name, 'name').set('strudel')
166
+ assert_equal(browser.form(:index, 1).text_field(:name, 'name').value, 'strudel')
167
167
  end
168
168
 
169
169
  def test_submit
170
- $ie.form(:xpath , "//form[@name='apple_form']/").submit
171
- assert( $ie.contains_text("PASS") )
170
+ browser.form(:xpath , "//form[@name='apple_form']/").submit
171
+ assert( browser.contains_text("PASS") )
172
172
  end
173
173
  end
174
174
 
175
- class TC_Hidden_Fields < Test::Unit::TestCase
175
+ class TC_Hidden_Fields_XPath < Test::Unit::TestCase
176
176
  def setup
177
177
  goto_page "forms3.html"
178
178
  end
@@ -180,62 +180,62 @@ class TC_Hidden_Fields < Test::Unit::TestCase
180
180
  def test_hidden
181
181
 
182
182
  # test using index
183
- assert( $ie.hidden(:index,1).exists? )
184
- assert( $ie.hidden(:index,2).exists? )
185
- assert(! $ie.hidden(:index,3).exists? )
183
+ assert( browser.hidden(:index,1).exists? )
184
+ assert( browser.hidden(:index,2).exists? )
185
+ assert_false( browser.hidden(:index,3).exists? )
186
186
 
187
- $ie.hidden(:index,1).value = 44
188
- $ie.hidden(:index,2).value = 55
187
+ browser.hidden(:index,1).value = 44
188
+ browser.hidden(:index,2).value = 55
189
189
 
190
- $ie.button(:value , "Show Hidden").click
190
+ browser.button(:value , "Show Hidden").click
191
191
 
192
- assert_equal("44" , $ie.text_field(:name , "vis1").value )
193
- assert_equal("55" , $ie.text_field(:name , "vis2").value )
192
+ assert_equal("44" , browser.text_field(:name , "vis1").value )
193
+ assert_equal("55" , browser.text_field(:name , "vis2").value )
194
194
 
195
195
  # test using name and ID
196
- assert( $ie.hidden(:name ,"hid1").exists? )
197
- assert( $ie.hidden(:id,"hidden_1").exists? )
198
- assert(! $ie.hidden(:name,"hidden_44").exists? )
199
- assert(! $ie.hidden(:id,"hidden_55").exists? )
196
+ assert( browser.hidden(:name ,"hid1").exists? )
197
+ assert( browser.hidden(:id,"hidden_1").exists? )
198
+ assert_false( browser.hidden(:name,"hidden_44").exists? )
199
+ assert_false( browser.hidden(:id,"hidden_55").exists? )
200
200
 
201
- $ie.hidden(:name ,"hid1").value = 444
202
- $ie.hidden(:id,"hidden_1").value = 555
201
+ browser.hidden(:name ,"hid1").value = 444
202
+ browser.hidden(:id,"hidden_1").value = 555
203
203
 
204
- $ie.button(:value , "Show Hidden").click
204
+ browser.button(:value , "Show Hidden").click
205
205
 
206
- assert_equal("444" , $ie.text_field(:name , "vis1").value )
207
- assert_equal("555" , $ie.text_field(:name ,"vis2").value )
206
+ assert_equal("444" , browser.text_field(:name , "vis1").value )
207
+ assert_equal("555" , browser.text_field(:name ,"vis2").value )
208
208
 
209
209
  # test the over-ridden append method
210
- $ie.hidden(:name ,"hid1").append("a")
211
- $ie.button(:value , "Show Hidden").click
212
- assert_equal("444a" , $ie.text_field(:name , "vis1").value )
213
- assert_equal("555" , $ie.text_field(:name ,"vis2").value )
210
+ browser.hidden(:name ,"hid1").append("a")
211
+ browser.button(:value , "Show Hidden").click
212
+ assert_equal("444a" , browser.text_field(:name , "vis1").value )
213
+ assert_equal("555" , browser.text_field(:name ,"vis2").value )
214
214
 
215
215
  # test the over-ridden clear method
216
- $ie.hidden(:name ,"hid1").clear
217
- $ie.button(:value , "Show Hidden").click
218
- assert_equal("" , $ie.text_field(:name , "vis1").value )
219
- assert_equal("555" , $ie.text_field(:name ,"vis2").value )
216
+ browser.hidden(:name ,"hid1").clear
217
+ browser.button(:value , "Show Hidden").click
218
+ assert_equal("" , browser.text_field(:name , "vis1").value )
219
+ assert_equal("555" , browser.text_field(:name ,"vis2").value )
220
220
 
221
221
  # test using a form
222
- assert( $ie.form(:xpath , "//form[@name='has_a_hidden']/").hidden(:name ,"hid1").exists? )
223
- assert( $ie.form(:xpath , "//form[@name='has_a_hidden']/").hidden(:id,"hidden_1").exists? )
224
- assert(! $ie.form(:xpath , "//form[@name='has_a_hidden']/").hidden(:name,"hidden_44").exists? )
225
- assert(! $ie.form(:xpath , "//form[@name='has_a_hidden']/").hidden(:id,"hidden_55").exists? )
222
+ assert( browser.form(:xpath , "//form[@name='has_a_hidden']/").hidden(:name ,"hid1").exists? )
223
+ assert( browser.form(:xpath , "//form[@name='has_a_hidden']/").hidden(:id,"hidden_1").exists? )
224
+ assert_false( browser.form(:xpath , "//form[@name='has_a_hidden']/").hidden(:name,"hidden_44").exists? )
225
+ assert_false( browser.form(:xpath , "//form[@name='has_a_hidden']/").hidden(:id,"hidden_55").exists? )
226
226
 
227
- $ie.form(:xpath , "//form[@name='has_a_hidden']/").hidden(:name ,"hid1").value = 222
228
- $ie.form(:xpath , "//form[@name='has_a_hidden']/").hidden(:id,"hidden_1").value = 333
227
+ browser.form(:xpath , "//form[@name='has_a_hidden']/").hidden(:name ,"hid1").value = 222
228
+ browser.form(:xpath , "//form[@name='has_a_hidden']/").hidden(:id,"hidden_1").value = 333
229
229
 
230
- $ie.button(:value , "Show Hidden").click
230
+ browser.button(:value , "Show Hidden").click
231
231
 
232
- assert_equal("222" , $ie.text_field(:name , "vis1").value )
233
- assert_equal("333" , $ie.text_field(:name ,"vis2").value )
232
+ assert_equal("222" , browser.text_field(:name , "vis1").value )
233
+ assert_equal("333" , browser.text_field(:name ,"vis2").value )
234
234
 
235
235
  # iterators
236
- assert_equal(2, $ie.hiddens.length)
236
+ assert_equal(2, browser.hiddens.length)
237
237
  count =1
238
- $ie.hiddens.each do |h|
238
+ browser.hiddens.each do |h|
239
239
  case count
240
240
  when 1
241
241
  assert_equal( "", h.id)
@@ -247,7 +247,7 @@ class TC_Hidden_Fields < Test::Unit::TestCase
247
247
  count+=1
248
248
  end
249
249
 
250
- assert_equal("hid1" , $ie.hiddens[1].name )
251
- assert_equal("hidden_1" , $ie.hiddens[2].id )
250
+ assert_equal("hid1" , browser.hiddens[1].name )
251
+ assert_equal("hidden_1" , browser.hiddens[2].id )
252
252
  end
253
253
  end
@@ -1,7 +1,7 @@
1
1
  # feature tests for Frames
2
- # revision: $Revision: 1348 $
2
+ # revision: $Revision: 1505 $
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_Frames < Test::Unit::TestCase
@@ -12,46 +12,47 @@ class TC_Frames < Test::Unit::TestCase
12
12
  end
13
13
 
14
14
  def test_frame_no_what
15
- assert_raises(UnknownFrameException) { $ie.frame("missingFrame").button(:id, "b2").enabled? }
16
- assert_raises(UnknownObjectException) { $ie.frame("buttonFrame2").button(:id, "b2").enabled? }
17
- assert($ie.frame("buttonFrame").button(:id, "b2").enabled?)
18
- assert(!$ie.frame("buttonFrame").button(:caption, "Disabled Button").enabled?)
15
+ assert_raises(UnknownFrameException) { browser.frame("missingFrame").button(:id, "b2").enabled? }
16
+ assert_raises(UnknownObjectException) { browser.frame("buttonFrame2").button(:id, "b2").enabled? }
17
+ assert(browser.frame("buttonFrame").button(:id, "b2").enabled?)
18
+ assert_false(browser.frame("buttonFrame").button(:caption, "Disabled Button").enabled?)
19
19
  end
20
20
 
21
21
  def test_frame_using_name
22
- assert_raises(UnknownFrameException) { $ie.frame(:name , "missingFrame").button(:id, "b2").enabled? }
23
- assert_raises(UnknownObjectException) { $ie.frame(:name, "buttonFrame2").button(:id, "b2").enabled? }
24
- assert($ie.frame(:name, "buttonFrame").button(:id, "b2").enabled?)
25
- assert(!$ie.frame(:name , "buttonFrame").button(:caption, "Disabled Button").enabled?)
22
+ assert_raises(UnknownFrameException) { browser.frame(:name , "missingFrame").button(:id, "b2").enabled? }
23
+ assert_raises(UnknownObjectException) { browser.frame(:name, "buttonFrame2").button(:id, "b2").enabled? }
24
+ assert(browser.frame(:name, "buttonFrame").button(:id, "b2").enabled?)
25
+ assert_false(browser.frame(:name , "buttonFrame").button(:caption, "Disabled Button").enabled?)
26
26
  end
27
27
 
28
28
  def test_frame_using_name_and_regexp
29
- assert_raises(UnknownFrameException) { $ie.frame(:name , /missingFrame/).button(:id, "b2").enabled? }
30
- assert($ie.frame(:name, /button/).button(:id, "b2").enabled?)
29
+ assert_raises(UnknownFrameException) { browser.frame(:name , /missingFrame/).button(:id, "b2").enabled? }
30
+ assert(browser.frame(:name, /button/).button(:id, "b2").enabled?)
31
31
  end
32
32
 
33
33
  def test_frame_using_index
34
- assert_raises(UnknownFrameException) { $ie.frame(:index, 8).button(:id, "b2").enabled? }
35
- assert_raises(UnknownObjectException) { $ie.frame(:index, 2).button(:id, "b2").enabled? }
36
- assert($ie.frame(:index, 1 ).button(:id, "b2").enabled?)
37
- assert(!$ie.frame(:index, 1).button(:caption, "Disabled Button").enabled?)
34
+ assert_raises(UnknownFrameException) { browser.frame(:index, 8).button(:id, "b2").enabled? }
35
+ assert_raises(UnknownObjectException) { browser.frame(:index, 2).button(:id, "b2").enabled? }
36
+ assert(browser.frame(:index, 1 ).button(:id, "b2").enabled?)
37
+ assert_false(browser.frame(:index, 1).button(:caption, "Disabled Button").enabled?)
38
38
  end
39
39
 
40
+ tag_method :test_frame_with_invalid_attribute, :fails_on_firefox
40
41
  def test_frame_with_invalid_attribute
41
- assert_raises(ArgumentError) { $ie.frame(:blah, 'no_such_thing').button(:id, "b2").enabled? }
42
+ assert_raises(ArgumentError) { browser.frame(:blah, 'no_such_thing').button(:id, "b2").enabled? }
42
43
  end
43
44
 
44
45
  def test_preset_frame
45
46
  # with ruby's instance_eval, we are able to use the same frame for several actions
46
- results = $ie.frame("buttonFrame").instance_eval do [
47
+ results = browser.frame("buttonFrame").instance_eval do [
47
48
  button(:id, "b2").enabled?,
48
49
  button(:caption, "Disabled Button").enabled?
49
50
  ]
50
51
  end
51
52
  assert_equal([true, false], results)
52
53
  end
53
-
54
54
  end
55
+
55
56
 
56
57
  class TC_Frames2 < Test::Unit::TestCase
57
58
  include Watir::Exception
@@ -61,57 +62,55 @@ class TC_Frames2 < Test::Unit::TestCase
61
62
  end
62
63
 
63
64
  def test_frame_with_no_name
64
- assert_raises(UnknownFrameException) { $ie.frame(:name , "missingFrame").button(:id, "b2").enabled? }
65
+ assert_raises(UnknownFrameException) { browser.frame(:name , "missingFrame").button(:id, "b2").enabled? }
65
66
  end
66
67
 
67
68
  def test_frame_by_id
68
- assert_raises(UnknownFrameException) { $ie.frame(:id , "missingFrame").button(:id, "b2").enabled? }
69
- assert($ie.frame(:id, 'first_frame').button(:id, "b2").enabled?)
69
+ assert_raises(UnknownFrameException) { browser.frame(:id , "missingFrame").button(:id, "b2").enabled? }
70
+ assert(browser.frame(:id, 'first_frame').button(:id, "b2").enabled?)
70
71
  end
71
72
 
72
73
  def test_frame_by_src
73
- assert($ie.frame(:src, /pass/).button(:value, 'Close Window').exists?)
74
+ assert(browser.frame(:src, /pass/).button(:value, 'Close Window').exists?)
74
75
  end
75
76
 
76
77
  end
77
78
 
78
79
  class TC_NestedFrames < Test::Unit::TestCase
79
- include Watir::Exception
80
-
80
+ tags :fails_on_firefox
81
81
  def setup
82
82
  goto_page "nestedFrames.html"
83
83
  end
84
84
 
85
85
  def test_frame
86
- assert_raises(UnknownFrameException) { $ie.frame("missingFrame").button(:id, "b2").enabled? }
87
- assert_raises(UnknownFrameException) { $ie.frame("nestedFrame").frame("subFrame").button(:id, "b2").enabled? }
88
- assert($ie.frame("nestedFrame").frame("senderFrame").button(:name, "sendIt").enabled?)
89
- $ie.frame("nestedFrame").frame("senderFrame").text_field(:index, "1").set("Hello")
90
- $ie.frame("nestedFrame").frame("senderFrame").button(:name, "sendIt").click
91
- assert($ie.frame("nestedFrame").frame("receiverFrame").text_field(:name, "receiverText").verify_contains("Hello"))
92
-
86
+ assert_raises(UnknownFrameException) { browser.frame("missingFrame").button(:id, "b2").enabled? }
87
+ assert_raises(UnknownFrameException) { browser.frame("nestedFrame").frame("subFrame").button(:id, "b2").enabled? }
88
+ assert(browser.frame("nestedFrame").frame("senderFrame").button(:name, "sendIt").enabled?)
89
+ browser.frame("nestedFrame").frame("senderFrame").text_field(:index, "1").set("Hello")
90
+ browser.frame("nestedFrame").frame("senderFrame").button(:name, "sendIt").click
91
+ assert(browser.frame("nestedFrame").frame("receiverFrame").text_field(:name, "receiverText").verify_contains("Hello"))
93
92
  end
94
93
 
95
94
  end
96
95
 
97
96
  class TC_IFrames < Test::Unit::TestCase
98
-
97
+ tags :fails_on_firefox
98
+
99
99
  def setup
100
100
  goto_page "iframeTest.html"
101
101
  end
102
102
 
103
103
  def test_Iframe
104
- $ie.frame("senderFrame").text_field(:name , "textToSend").set( "Hello World")
105
- $ie.frame("senderFrame").button(:index, 1).click
106
- assert( $ie.frame("receiverFrame").text_field(:name , "receiverText").verify_contains("Hello World") )
107
- assert_equal($ie.frame(:src, /iframeTest2/).text_field(:name, 'receiverText').value, "Hello World")
104
+ browser.frame("senderFrame").text_field(:name , "textToSend").set( "Hello World")
105
+ browser.frame("senderFrame").button(:index, 1).click
106
+ assert( browser.frame("receiverFrame").text_field(:name , "receiverText").verify_contains("Hello World") )
107
+ assert_equal(browser.frame(:src, /iframeTest2/).text_field(:name, 'receiverText').value, "Hello World")
108
108
  end
109
109
 
110
- #VALIDATE THAT WE CAN GET THERE VIA id
111
110
  def test_iframes_id
112
- $ie.frame(:id, "sf").text_field(:name , "textToSend").set( "Hello World")
113
- $ie.frame(:id, "sf").button(:name,'sendIt').click
114
- assert( $ie.frame("receiverFrame").text_field(:name , "receiverText").verify_contains("Hello World") )
111
+ browser.frame(:id, "sf").text_field(:name , "textToSend").set( "Hello World")
112
+ browser.frame(:id, "sf").button(:name,'sendIt').click
113
+ assert( browser.frame("receiverFrame").text_field(:name , "receiverText").verify_contains("Hello World") )
115
114
  end
116
115
 
117
116
  end
@@ -121,12 +120,13 @@ class TC_show_frames < Test::Unit::TestCase
121
120
  include MockStdoutTestCase
122
121
 
123
122
  def capture_and_compare(page, expected)
124
- $ie.goto($htmlRoot + page)
123
+ goto_page page
125
124
  $stdout = @mockout
126
- $ie.showFrames
125
+ browser.showFrames
127
126
  assert_equal(expected, @mockout)
128
127
  end
129
-
128
+
129
+ tag_method :test_show_nested_frames, :fails_on_firefox
130
130
  def test_show_nested_frames
131
131
  capture_and_compare("nestedFrames.html", <<END_OF_MESSAGE)
132
132
  there are 2 frames
@@ -135,6 +135,7 @@ frame index: 2 name: nestedFrame2
135
135
  END_OF_MESSAGE
136
136
  end
137
137
 
138
+ tag_method :test_button_frames, :fails_on_firefox
138
139
  def test_button_frames
139
140
  capture_and_compare("frame_buttons.html", <<END_OF_MESSAGE)
140
141
  there are 2 frames
@@ -143,6 +144,7 @@ frame index: 2 name: buttonFrame2
143
144
  END_OF_MESSAGE
144
145
  end
145
146
 
147
+ tag_method :test_iframes, :fails_on_firefox
146
148
  def test_iframes
147
149
  capture_and_compare("iframeTest.html", <<END_OF_MESSAGE)
148
150
  there are 2 frames