firewatir 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/MozillaBaseElement.rb +1778 -0
  2. data/container.rb +889 -0
  3. data/firewatir/exceptions.rb +44 -0
  4. data/firewatir/testUnitAddons.rb +8 -0
  5. data/firewatir.rb +1130 -0
  6. data/htmlelements.rb +2277 -0
  7. data/unittests/attach_to_new_window_test.rb +34 -0
  8. data/unittests/bug_fixes_test.rb +188 -0
  9. data/unittests/buttons_test.rb +215 -0
  10. data/unittests/buttons_xpath_test.rb +87 -0
  11. data/unittests/checkbox_test.rb +154 -0
  12. data/unittests/checkbox_xpath_test.rb +107 -0
  13. data/unittests/div_test.rb +274 -0
  14. data/unittests/filefield_test.rb +45 -0
  15. data/unittests/filefield_xpath_test.rb +35 -0
  16. data/unittests/form_test.rb +307 -0
  17. data/unittests/frame_test.rb +151 -0
  18. data/unittests/hidden_test.rb +85 -0
  19. data/unittests/hidden_xpath_test.rb +72 -0
  20. data/unittests/html/JavascriptClick.html +42 -0
  21. data/unittests/html/blankpage.html +12 -0
  22. data/unittests/html/buttons1.html +61 -0
  23. data/unittests/html/checkboxes1.html +71 -0
  24. data/unittests/html/complex_table.html +36 -0
  25. data/unittests/html/cssTest.html +42 -0
  26. data/unittests/html/div.html +72 -0
  27. data/unittests/html/div_xml.html +21 -0
  28. data/unittests/html/fileupload.html +45 -0
  29. data/unittests/html/formTest1.html +39 -0
  30. data/unittests/html/forms2.html +45 -0
  31. data/unittests/html/forms3.html +132 -0
  32. data/unittests/html/forms4.html +27 -0
  33. data/unittests/html/frame_buttons.html +4 -0
  34. data/unittests/html/frame_links.html +4 -0
  35. data/unittests/html/frame_multi.html +5 -0
  36. data/unittests/html/iframeTest.html +15 -0
  37. data/unittests/html/iframeTest1.html +14 -0
  38. data/unittests/html/iframeTest2.html +6 -0
  39. data/unittests/html/images/1.gif +0 -0
  40. data/unittests/html/images/2.GIF +0 -0
  41. data/unittests/html/images/3.GIF +0 -0
  42. data/unittests/html/images/button.jpg +0 -0
  43. data/unittests/html/images/circle.jpg +0 -0
  44. data/unittests/html/images/minus.GIF +0 -0
  45. data/unittests/html/images/originaltriangle.jpg +0 -0
  46. data/unittests/html/images/plus.gif +0 -0
  47. data/unittests/html/images/square.jpg +0 -0
  48. data/unittests/html/images/triangle.jpg +0 -0
  49. data/unittests/html/images1.html +67 -0
  50. data/unittests/html/javascriptevents.html +35 -0
  51. data/unittests/html/link_pass.html +11 -0
  52. data/unittests/html/links1.html +42 -0
  53. data/unittests/html/links2.html +11 -0
  54. data/unittests/html/modal_dialog.html +8 -0
  55. data/unittests/html/modal_dialog_launcher.html +12 -0
  56. data/unittests/html/nestedFrames.html +6 -0
  57. data/unittests/html/new_browser.html +17 -0
  58. data/unittests/html/pass.html +10 -0
  59. data/unittests/html/popups1.html +60 -0
  60. data/unittests/html/pre.html +28 -0
  61. data/unittests/html/radioButtons1.html +71 -0
  62. data/unittests/html/redirect.html +10 -0
  63. data/unittests/html/redirect1.html +9 -0
  64. data/unittests/html/redirect2.html +9 -0
  65. data/unittests/html/redirect3.html +9 -0
  66. data/unittests/html/select_tealeaf.html +54 -0
  67. data/unittests/html/selectboxes1.html +55 -0
  68. data/unittests/html/simple_table.html +26 -0
  69. data/unittests/html/simple_table_buttons.html +104 -0
  70. data/unittests/html/simple_table_columns.html +74 -0
  71. data/unittests/html/table1.html +165 -0
  72. data/unittests/html/tableCell_using_xpath.html +19 -0
  73. data/unittests/html/textarea.html +30 -0
  74. data/unittests/html/textfields1.html +62 -0
  75. data/unittests/html/textsearch.html +44 -0
  76. data/unittests/images_test.rb +204 -0
  77. data/unittests/images_xpath_test.rb +118 -0
  78. data/unittests/iostring.rb +30 -0
  79. data/unittests/iostring_test.rb +48 -0
  80. data/unittests/javascript_test.rb +71 -0
  81. data/unittests/links_test.rb +230 -0
  82. data/unittests/links_xpath_test.rb +79 -0
  83. data/unittests/mozilla_all_tests.rb +18 -0
  84. data/unittests/pre_test.rb +74 -0
  85. data/unittests/radios_test.rb +166 -0
  86. data/unittests/radios_xpath_test.rb +101 -0
  87. data/unittests/redirect_test.rb +40 -0
  88. data/unittests/selectbox_test.rb +141 -0
  89. data/unittests/selectbox_xpath_test.rb +127 -0
  90. data/unittests/setup.rb +35 -0
  91. data/unittests/table_test.rb +372 -0
  92. data/unittests/table_xpath_test.rb +184 -0
  93. data/unittests/textfields_test.rb +230 -0
  94. data/unittests/textfields_xpath_test.rb +112 -0
  95. metadata +144 -0
@@ -0,0 +1,307 @@
1
+ # feature tests for Forms
2
+ # revision: $Revision: 1.0 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
+ require 'unittests/setup'
6
+
7
+ class TC_Forms2 < Test::Unit::TestCase # Note: there is no TC_Forms
8
+ include FireWatir
9
+
10
+ def setup
11
+ $ff.goto($htmlRoot + "forms2.html")
12
+ end
13
+
14
+ def test_Form_Exists
15
+ assert($ff.form(:name, "test2").exists?)
16
+ assert(!$ff.form(:name, "missing").exists?)
17
+
18
+ assert($ff.form("test2").exists?)
19
+ assert(!$ff.form( "missing").exists?)
20
+
21
+ assert($ff.form(:index, 1).exists?)
22
+ assert(!$ff.form(:index, 88).exists?)
23
+
24
+ assert($ff.form(:method, "get").exists?)
25
+ assert(!$ff.form(:method, "missing").exists?)
26
+
27
+ assert($ff.form(:id, 'f2').exists?)
28
+ assert(!$ff.form(:id, 'missing').exists?)
29
+
30
+ assert($ff.form(:action, /pass.html/).exists?)
31
+ assert(!$ff.form(:action, "missing").exists?)
32
+ end
33
+
34
+ def test_ButtonInForm
35
+ assert($ff.form(:name, "test2").button(:caption , "Submit").exists?)
36
+ end
37
+
38
+ # The following tests from bug 2261
39
+ def test_form_html
40
+ assert_equal("\n<BR><INPUT value=\"Submit\" type=\"submit\">\n".downcase(),
41
+ $ff.form(:name, 'test2').html.downcase())
42
+ end
43
+ def test_form_flash
44
+ assert_nothing_raised{ $ff.form(:name, 'test2').flash }
45
+ end
46
+ def test_form_sub_element
47
+ assert_equal('Click Me', $ff.form(:index, 1).button(:name, 'b1').value)
48
+ end
49
+ end
50
+
51
+ class TC_Form_Display < Test::Unit::TestCase
52
+ include FireWatir
53
+ include MockStdoutTestCase
54
+
55
+ def test_showforms
56
+ $ff.goto($htmlRoot + "forms2.html")
57
+ $stdout = @mockout
58
+ $ff.showForms
59
+ assert_equal(<<END_OF_MESSAGE, @mockout)
60
+ There are 4 forms
61
+ Form name:
62
+ id:
63
+ method: get
64
+ action: pass.html
65
+ Form name: test2
66
+ id: f2
67
+ method: get
68
+ action: pass2.html
69
+ Form name: test3
70
+ id:
71
+ method: get
72
+ action: pass2.html
73
+ Form name: test2
74
+ id:
75
+ method: get
76
+ action: pass2.html
77
+ END_OF_MESSAGE
78
+ end
79
+ end
80
+
81
+ class TC_Forms3 < Test::Unit::TestCase
82
+ include FireWatir
83
+ def setup
84
+ $ff.goto($htmlRoot + "forms3.html")
85
+ end
86
+
87
+ # The following tests from bug 2261
88
+ def test_p_in_form
89
+ $ff.form(:name, 'buttonsubmit').p(:index, 1).text
90
+ end
91
+
92
+ def test_Form_Exists
93
+ assert($ff.form(:name, "test2").exists?)
94
+ assert(!$ff.form(:name, "missing").exists?)
95
+
96
+ assert($ff.form("test2").exists?)
97
+ assert(!$ff.form( "missing").exists?)
98
+
99
+ assert($ff.form(:index, 1).exists?)
100
+ assert(!$ff.form(:index, 88).exists?)
101
+
102
+ assert($ff.form(:method, "get").exists?)
103
+ assert(!$ff.form(:method, "missing").exists?)
104
+
105
+ assert($ff.form(:action, "pass.html").exists?)
106
+ assert(!$ff.form(:action, "missing").exists?)
107
+ end
108
+
109
+ def test_index_other_element_before_it
110
+ # test for bug reported by Scott Pack, http://rubyforge.org/pipermail/wtr-general/2005-June/002223.html
111
+ assert_equal("check1" , $ff.checkbox(:index,1).name )
112
+ end
113
+
114
+ def test_reset
115
+ $ff.text_field(:id, "t1").set("Hello, reset test!")
116
+ assert_equal($ff.text_field(:id, 't1').getContents, 'Hello, reset test!')
117
+
118
+ $ff.button(:id, "reset_button").click
119
+ assert_equal("" , $ff.text_field(:id, 't1').getContents )
120
+
121
+ # also verify it works under a form
122
+ $ff.text_field(:id, "t1").set("reset test - using a form")
123
+ assert_equal($ff.text_field(:id, 't1').getContents, 'reset test - using a form')
124
+
125
+ $ff.form(:index,2).button(:index,2).click
126
+ assert_equal("" , $ff.text_field(:id, 't1').getContents )
127
+
128
+ # also verify it works under a form, this time using the :id attribute
129
+ $ff.text_field(:id, "t1").set("reset test - using a form")
130
+ assert_equal($ff.text_field(:id, 't1').getContents, 'reset test - using a form')
131
+
132
+ $ff.form(:index,2).button(:id,'reset_button').click
133
+ assert_equal("" , $ff.text_field(:id, 't1').getContents )
134
+ end
135
+
136
+ ## def test_flash1
137
+ ## $ff.form(:name ,"test2").button(:caption , "Submit").flash
138
+ ## end
139
+ #
140
+ def test_objects_with_same_name
141
+ assert_equal('textfield' ,$ff.text_field( :name , 'g1').value )
142
+ assert_equal('button' ,$ff.button( :name , 'g1').value )
143
+ assert_equal('1' ,$ff.checkbox( :name , 'g1').value )
144
+ assert_equal('2' ,$ff.radio( :name , 'g1').value )
145
+
146
+ assert_equal('textfield' ,$ff.text_field( :name , /g1/).value )
147
+ assert_equal('button' ,$ff.button( :name , /g1/).value )
148
+ assert_equal('1' ,$ff.checkbox( :name , /g1/).value )
149
+ assert_equal('2' ,$ff.radio( :name , /g1/).value )
150
+
151
+ assert_equal('textfield_id' ,$ff.text_field( :id , 'g1').value )
152
+ assert_equal('button_id' ,$ff.button( :id , 'g1').value )
153
+ assert_equal('1_id' ,$ff.checkbox( :id , 'g1').value )
154
+ assert_equal('2_id' ,$ff.radio( :id , 'g1').value )
155
+
156
+ assert_equal('textfield_id' ,$ff.text_field( :id , /g1/).value )
157
+ assert_equal('button_id' ,$ff.button( :id , /g1/).value )
158
+ assert_equal('1_id' ,$ff.checkbox( :id , /g1/).value )
159
+ assert_equal('2_id' ,$ff.radio( :id , /g1/).value )
160
+ end
161
+
162
+ # def test_flash2
163
+ # $ff.button(:value, 'Click Me').flash
164
+ # assert_raises( Watir::UnknownObjectException ) { $ff.text_field( :name , 'g177').flash }
165
+ # end
166
+
167
+ def test_submitWithImage
168
+ assert( $ff.button(:alt , "submit").exists? )
169
+ assert( $ff.button(:alt , /sub/).exists? )
170
+
171
+ assert(! $ff.button(:alt , "missing").exists? )
172
+ assert(! $ff.button(:alt , /missing/).exists? )
173
+
174
+ #assert( $ff.button(:src , "file:///#{$myDir}/html/images/button.jpg").exists? ) # this doesnt work for everybody
175
+ assert( $ff.button(:src , /button/).exists? )
176
+
177
+ assert(! $ff.button(:src , "missing").exists? )
178
+ assert(! $ff.button(:src , /missing/).exists? )
179
+ assert_nothing_raised("raised an exception when it shouldnt have") { $ff.button(:src , /button/).click }
180
+
181
+ assert( $ff.text.include?("PASS") )
182
+ end
183
+ end
184
+
185
+ #class TC_Forms3_Display < Test::Unit::TestCase
186
+ # include FireWatir
187
+ # include MockStdoutTestCase # BUG in test: output not verified!
188
+ # def test_show_stuff
189
+ # $ff.goto($htmlRoot + "forms3.html")
190
+ # $stdout = @mockout
191
+ # $ff.showAllObjects
192
+ # puts $ff.getText
193
+ # puts $ff.getHTML
194
+ # end
195
+ #end
196
+
197
+ class TC_Forms4 < Test::Unit::TestCase
198
+ include FireWatir
199
+ def setup
200
+ $ff.goto($htmlRoot + "forms4.html")
201
+ end
202
+
203
+ def test_find_text_field_ignoring_form
204
+ assert_equal($ff.text_field(:name, 'name').getContents, 'apple') # should it raise a not-unique error instead?
205
+ end
206
+
207
+ def test_correct_form_field_is_found_using_form_name
208
+ assert_equal($ff.form(:name, 'apple_form').text_field(:name, 'name').getContents, 'apple')
209
+ assert_equal($ff.form(:name, 'banana_form').text_field(:name, 'name').getContents, 'banana')
210
+ end
211
+
212
+ def test_correct_form_field_is_found_using_form_index
213
+ assert_equal($ff.form(:index, 1).text_field(:name, 'name').getContents, 'apple')
214
+ assert_equal($ff.form(:index, 2).text_field(:name, 'name').getContents, 'banana')
215
+ end
216
+
217
+ def test_using_text_on_form
218
+ $ff.form(:name, 'apple_form').text_field(:name, 'name').set('strudel')
219
+ assert_equal($ff.form(:index, 1).text_field(:name, 'name').getContents, 'strudel')
220
+ end
221
+
222
+ def test_submit
223
+ $ff.form(:name, 'apple_form').submit
224
+ assert( $ff.text.include?("PASS") )
225
+ end
226
+ end
227
+
228
+ class TC_Hidden_Fields2 < Test::Unit::TestCase
229
+ include FireWatir
230
+ def setup
231
+ $ff.goto($htmlRoot + "forms3.html")
232
+ end
233
+
234
+ def test_hidden
235
+
236
+ # test using index
237
+ assert( $ff.hidden(:index,1).exists? )
238
+ assert( $ff.hidden(:index,2).exists? )
239
+ assert(! $ff.hidden(:index,3).exists? )
240
+
241
+ $ff.hidden(:index,1).value = 44
242
+ $ff.hidden(:index,2).value = 55
243
+
244
+ $ff.button(:value , "Show Hidden").click
245
+
246
+ assert_equal("44" , $ff.text_field(:name , "vis1").value )
247
+ assert_equal("55" , $ff.text_field(:name , "vis2").value )
248
+
249
+ # test using name and ID
250
+ assert( $ff.hidden(:name ,"hid1").exists? )
251
+ assert( $ff.hidden(:id,"hidden_1").exists? )
252
+ assert(! $ff.hidden(:name,"hidden_44").exists? )
253
+ assert(! $ff.hidden(:id,"hidden_55").exists? )
254
+
255
+ $ff.hidden(:name ,"hid1").value = 444
256
+ $ff.hidden(:id,"hidden_1").value = 555
257
+
258
+ $ff.button(:value , "Show Hidden").click
259
+
260
+ assert_equal("444" , $ff.text_field(:name , "vis1").value )
261
+ assert_equal("555" , $ff.text_field(:name ,"vis2").value )
262
+
263
+ # test the over-ridden append method
264
+ $ff.hidden(:name ,"hid1").append("a")
265
+ $ff.button(:value , "Show Hidden").click
266
+ assert_equal("444a" , $ff.text_field(:name , "vis1").value )
267
+ assert_equal("555" , $ff.text_field(:name ,"vis2").value )
268
+
269
+ # test the over-ridden clear method
270
+ $ff.hidden(:name ,"hid1").clear
271
+ $ff.button(:value , "Show Hidden").click
272
+ assert_equal("" , $ff.text_field(:name , "vis1").value )
273
+ assert_equal("555" , $ff.text_field(:name ,"vis2").value )
274
+
275
+ # test using a form
276
+ assert( $ff.form(:name , "has_a_hidden").hidden(:name ,"hid1").exists? )
277
+ assert( $ff.form(:name , "has_a_hidden").hidden(:id,"hidden_1").exists? )
278
+ assert(! $ff.form(:name , "has_a_hidden").hidden(:name,"hidden_44").exists? )
279
+ assert(! $ff.form(:name , "has_a_hidden").hidden(:id,"hidden_55").exists? )
280
+
281
+ $ff.form(:name , "has_a_hidden").hidden(:name ,"hid1").value = 222
282
+ $ff.form(:name , "has_a_hidden").hidden(:id,"hidden_1").value = 333
283
+
284
+ $ff.button(:value , "Show Hidden").click
285
+
286
+ assert_equal("222" , $ff.text_field(:name , "vis1").value )
287
+ assert_equal("333" , $ff.text_field(:name ,"vis2").value )
288
+
289
+ # iterators
290
+ ## assert_equal(2, $ff.hiddens.length)
291
+ ## count =1
292
+ ## $ff.hiddens.each do |h|
293
+ ## case count
294
+ ## when 1
295
+ ## assert_equal( "", h.id)
296
+ ## assert_equal( "hid1", h.name)
297
+ ## when 2
298
+ ## assert_equal( "", h.name)
299
+ ## assert_equal( "hidden_1", h.id)
300
+ ## end
301
+ ## count+=1
302
+ ## end
303
+ #
304
+ ## assert_equal("hid1" , $ff.hiddens[1].name )
305
+ ## assert_equal("hidden_1" , $ff.hiddens[2].id )
306
+ end
307
+ end
@@ -0,0 +1,151 @@
1
+ # feature tests for Frames
2
+ # revision: $Revision: 1.0 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
+ require 'unittests/setup'
6
+
7
+ class TC_Frames < Test::Unit::TestCase
8
+ include FireWatir
9
+
10
+ def setup
11
+ $ff.goto($htmlRoot + "frame_buttons.html")
12
+ end
13
+
14
+ def test_frame_no_what
15
+ assert_raises(UnknownFrameException) { $ff.frame("missingFrame").button(:id, "b2").enabled? }
16
+ assert_raises(UnknownObjectException) { $ff.frame("buttonFrame2").button(:id, "b2").enabled? }
17
+ assert($ff.frame("buttonFrame").button(:id, "b2").enabled?)
18
+ assert(!$ff.frame("buttonFrame").button(:caption, "Disabled Button").enabled?)
19
+ end
20
+
21
+ def test_frame_using_name
22
+ assert_raises(UnknownFrameException) { $ff.frame(:name , "missingFrame").button(:id, "b2").enabled? }
23
+ assert_raises(UnknownObjectException) { $ff.frame(:name, "buttonFrame2").button(:id, "b2").enabled? }
24
+ assert($ff.frame(:name, "buttonFrame").button(:id, "b2").enabled?)
25
+ assert(!$ff.frame(:name , "buttonFrame").button(:caption, "Disabled Button").enabled?)
26
+ end
27
+
28
+ def test_frame_using_name_and_regexp
29
+ assert_raises(UnknownFrameException) { $ff.frame(:name , /missingFrame/).button(:id, "b2").enabled? }
30
+ assert($ff.frame(:name, /button/).button(:id, "b2").enabled?)
31
+ end
32
+
33
+ def test_frame_using_index
34
+ assert_raises(UnknownFrameException) { $ff.frame(:index, 8).button(:id, "b2").enabled? }
35
+ assert_raises(UnknownObjectException) { $ff.frame(:index, 2).button(:id, "b2").enabled? }
36
+ assert($ff.frame(:index, 1 ).button(:id, "b2").enabled?)
37
+ assert(!$ff.frame(:index, 1).button(:caption, "Disabled Button").enabled?)
38
+ end
39
+
40
+ # def test_frame_with_invalid_attribute
41
+ # assert_raises(ArgumentError) { $ff.frame(:blah, 'no_such_thing').button(:id, "b2").enabled? }
42
+ # end
43
+
44
+ def test_preset_frame
45
+ # with ruby's instance_eval, we are able to use the same frame for several actions
46
+ results = $ff.frame("buttonFrame").instance_eval do [
47
+ button(:id, "b2").enabled?,
48
+ button(:caption, "Disabled Button").enabled?
49
+ ]
50
+ end
51
+ assert_equal([true, false], results)
52
+ end
53
+
54
+ end
55
+
56
+ class TC_Frames2 < Test::Unit::TestCase
57
+ include FireWatir
58
+
59
+ def setup
60
+ $ff.goto($htmlRoot + "frame_multi.html")
61
+ end
62
+
63
+ def test_frame_with_no_name
64
+ assert_raises(UnknownFrameException) { $ff.frame(:name , "missingFrame").button(:id, "b2").enabled? }
65
+ end
66
+
67
+ def test_frame_by_id
68
+ assert_raises(UnknownFrameException) { $ff.frame(:id , "missingFrame").button(:id, "b2").enabled? }
69
+ assert($ff.frame(:id, 'first_frame').button(:id, "b2").enabled?)
70
+ assert(/.*Test page for buttons.*/ =~ $ff.frame(:id, 'first_frame').html)
71
+ end
72
+ end
73
+
74
+ class TC_NestedFrames < Test::Unit::TestCase
75
+ include FireWatir
76
+
77
+ def setup
78
+ $ff.goto($htmlRoot + "nestedFrames.html")
79
+ end
80
+
81
+ def test_frame
82
+ assert_raises(UnknownFrameException) { $ff.frame("missingFrame").button(:id, "b2").enabled? }
83
+ assert_raises(UnknownFrameException) { $ff.frame("nestedFrame").frame("subFrame").button(:id, "b2").enabled? }
84
+ assert($ff.frame("nestedFrame").frame("senderFrame").button(:name, "sendIt").enabled?)
85
+ $ff.frame("nestedFrame").frame("senderFrame").text_field(:index, "1").set("Hello")
86
+ $ff.frame("nestedFrame").frame("senderFrame").button(:name, "sendIt").click
87
+ assert($ff.frame("nestedFrame").frame("receiverFrame").text_field(:name, "receiverText").verify_contains("Hello"))
88
+ end
89
+
90
+ end
91
+
92
+ class TC_IFrames < Test::Unit::TestCase
93
+ include FireWatir
94
+
95
+ def setup
96
+ $ff.goto($htmlRoot + "iframeTest.html")
97
+ end
98
+
99
+ def test_Iframe
100
+ f = $ff.frame("senderFrame")
101
+ f.text_field(:name, "textToSend").set("Hello World")
102
+ $ff.frame("senderFrame").text_field(:name , "textToSend").set( "Hello World")
103
+ $ff.frame("senderFrame").button(:index, 1).click
104
+ assert( $ff.frame("receiverFrame").text_field(:name , "receiverText").verify_contains("Hello World") )
105
+ end
106
+
107
+ end
108
+
109
+ require 'unittests/iostring'
110
+ class TC_show_frames < Test::Unit::TestCase
111
+ include MockStdoutTestCase
112
+
113
+ def capture_and_compare(page, expected)
114
+ $ff.goto($htmlRoot + page)
115
+ $stdout = @mockout
116
+ $ff.showFrames
117
+ assert_equal(expected, @mockout)
118
+ end
119
+
120
+ def test_show_nested_frames
121
+ capture_and_compare("nestedFrames.html", <<END_OF_MESSAGE)
122
+ There are 2 frames
123
+ frame: name: nestedFrame
124
+ index: 1
125
+ frame: name: nestedFrame2
126
+ index: 2
127
+ END_OF_MESSAGE
128
+ end
129
+
130
+ def test_button_frames
131
+ capture_and_compare("frame_buttons.html", <<END_OF_MESSAGE)
132
+ There are 2 frames
133
+ frame: name: buttonFrame
134
+ index: 1
135
+ frame: name: buttonFrame2
136
+ index: 2
137
+ END_OF_MESSAGE
138
+ end
139
+
140
+ def test_iframes
141
+ capture_and_compare("iframeTest.html", <<END_OF_MESSAGE)
142
+ There are 2 frames
143
+ frame: name: senderFrame
144
+ index: 1
145
+ frame: name: receiverFrame
146
+ index: 2
147
+ END_OF_MESSAGE
148
+ end
149
+
150
+ end
151
+
@@ -0,0 +1,85 @@
1
+ # feature tests for Input Hidden elements
2
+ # revision: $Revision: 1.0 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
+ require 'unittests/setup'
6
+
7
+ class TC_Hidden_Fields < Test::Unit::TestCase
8
+ def setup
9
+ $ff.goto($htmlRoot + "forms3.html")
10
+ end
11
+
12
+ def test_hidden
13
+
14
+ # test using index
15
+ assert( $ff.hidden(:index,1).exists? )
16
+ assert( $ff.hidden(:index,2).exists? )
17
+ assert_false( $ff.hidden(:index,3).exists? )
18
+
19
+ $ff.hidden(:index,1).value = 44
20
+ $ff.hidden(:index,2).value = 55
21
+
22
+ $ff.button(:value , "Show Hidden").click
23
+
24
+ assert_equal("44" , $ff.text_field(:name , "vis1").value )
25
+ assert_equal("55" , $ff.text_field(:name , "vis2").value )
26
+
27
+ # test using name and ID
28
+ assert( $ff.hidden(:name ,"hid1").exists? )
29
+ assert( $ff.hidden(:id,"hidden_1").exists? )
30
+ assert_false( $ff.hidden(:name,"hidden_44").exists? )
31
+ assert_false( $ff.hidden(:id,"hidden_55").exists? )
32
+
33
+ $ff.hidden(:name ,"hid1").value = 444
34
+ $ff.hidden(:id,"hidden_1").value = 555
35
+
36
+ $ff.button(:value , "Show Hidden").click
37
+
38
+ assert_equal("444" , $ff.text_field(:name , "vis1").value )
39
+ assert_equal("555" , $ff.text_field(:name ,"vis2").value )
40
+
41
+ # test the over-ridden append method
42
+ $ff.hidden(:name ,"hid1").append("a")
43
+ $ff.button(:value , "Show Hidden").click
44
+ assert_equal("444a" , $ff.text_field(:name , "vis1").value )
45
+ assert_equal("555" , $ff.text_field(:name ,"vis2").value )
46
+
47
+ # test the over-ridden clear method
48
+ $ff.hidden(:name ,"hid1").clear
49
+ $ff.button(:value , "Show Hidden").click
50
+ assert_equal("" , $ff.text_field(:name , "vis1").value )
51
+ assert_equal("555" , $ff.text_field(:name ,"vis2").value )
52
+
53
+ # test using a form
54
+ assert( $ff.form(:name , "has_a_hidden").hidden(:name ,"hid1").exists? )
55
+ assert( $ff.form(:name , "has_a_hidden").hidden(:id,"hidden_1").exists? )
56
+ assert_false( $ff.form(:name , "has_a_hidden").hidden(:name,"hidden_44").exists? )
57
+ assert_false( $ff.form(:name , "has_a_hidden").hidden(:id,"hidden_55").exists? )
58
+
59
+ $ff.form(:name , "has_a_hidden").hidden(:name ,"hid1").value = 222
60
+ $ff.form(:name , "has_a_hidden").hidden(:id,"hidden_1").value = 333
61
+
62
+ $ff.button(:value , "Show Hidden").click
63
+
64
+ assert_equal("222" , $ff.text_field(:name , "vis1").value )
65
+ assert_equal("333" , $ff.text_field(:name ,"vis2").value )
66
+
67
+ # iterators
68
+ assert_equal(2, $ff.hiddens.length)
69
+ count =1
70
+ $ff.hiddens.each do |h|
71
+ case count
72
+ when 1
73
+ assert_equal( "", h.id)
74
+ assert_equal( "hid1", h.name)
75
+ when 2
76
+ assert_equal( "", h.name)
77
+ assert_equal( "hidden_1", h.id)
78
+ end
79
+ count+=1
80
+ end
81
+
82
+ assert_equal("hid1" , $ff.hiddens[1].name )
83
+ assert_equal("hidden_1" , $ff.hiddens[2].id )
84
+ end
85
+ end
@@ -0,0 +1,72 @@
1
+ # feature tests for Input Hidden elements
2
+ # revision: $Revision: 1.0 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
+ require 'unittests/setup'
6
+
7
+ class TC_Hidden_Fields_XPath < Test::Unit::TestCase
8
+ def setup
9
+ $ff.goto($htmlRoot + "forms3.html")
10
+ end
11
+
12
+ def test_hidden
13
+
14
+ # test using name and ID
15
+ assert( $ff.hidden(:xpath,"//input[@type='hidden' and @name='hid1']").exists? )
16
+ assert( $ff.hidden(:xpath,"//input[@type='hidden' and @id='hidden_1']").exists? )
17
+ assert_false( $ff.hidden(:xpath,"//input[@type='hidden' and @name='hidden_44']").exists? )
18
+ assert_false( $ff.hidden(:xpath,"//input[@type='hidden' and @id='hidden_55']").exists? )
19
+
20
+ $ff.hidden(:xpath,"//input[@type='hidden' and @name='hid1']").value = 444
21
+ $ff.hidden(:xpath,"//input[@type='hidden' and @id='hidden_1']").value = 555
22
+
23
+ $ff.button(:xpath , "//input[@type='button' and @value='Show Hidden']").click
24
+
25
+ assert_equal("444" , $ff.text_field(:xpath , "//input[@name='vis1']").value )
26
+ assert_equal("555" , $ff.text_field(:xpath ,"//input[@name='vis2']").value )
27
+
28
+ # test the over-ridden append method
29
+ $ff.hidden(:xpath,"//input[@type='hidden' and @name='hid1']").append("a")
30
+ $ff.button(:xpath , "//input[@type='button' and @value='Show Hidden']").click
31
+ assert_equal("444a" , $ff.text_field(:xpath , "//input[@name='vis1']").value )
32
+ assert_equal("555" , $ff.text_field(:xpath ,"//input[@name='vis2']").value )
33
+
34
+ # test the over-ridden clear method
35
+ $ff.hidden(:xpath,"//input[@type='hidden' and @name='hid1']").clear
36
+ $ff.button(:xpath , "//input[@type='button' and @value='Show Hidden']").click
37
+ assert_equal("" , $ff.text_field(:xpath , "//input[@name='vis1']").value )
38
+ assert_equal("555" , $ff.text_field(:xpath ,"//input[@name='vis2']").value )
39
+
40
+ # test using a form
41
+ #assert( $ff.form(:name , "has_a_hidden").hidden(:name ,"hid1").exists? )
42
+ #assert( $ff.form(:name , "has_a_hidden").hidden(:id,"hidden_1").exists? )
43
+ #assert_false( $ff.form(:name , "has_a_hidden").hidden(:name,"hidden_44").exists? )
44
+ #assert_false( $ff.form(:name , "has_a_hidden").hidden(:id,"hidden_55").exists? )
45
+
46
+ #$ff.form(:name , "has_a_hidden").hidden(:name ,"hid1").value = 222
47
+ #$ff.form(:name , "has_a_hidden").hidden(:id,"hidden_1").value = 333
48
+
49
+ #$ff.button(:value , "Show Hidden").click
50
+
51
+ #assert_equal("222" , $ff.text_field(:name , "vis1").value )
52
+ #assert_equal("333" , $ff.text_field(:name ,"vis2").value )
53
+
54
+ # iterators
55
+ #assert_equal(2, $ff.hiddens.length)
56
+ #count =1
57
+ #$ff.hiddens.each do |h|
58
+ # case count
59
+ # when 1
60
+ # assert_equal( "", h.id)
61
+ # assert_equal( "hid1", h.name)
62
+ # when 2
63
+ # assert_equal( "", h.name)
64
+ # assert_equal( "hidden_1", h.id)
65
+ # end
66
+ # count+=1
67
+ #end
68
+
69
+ #assert_equal("hid1" , $ff.hiddens[1].name )
70
+ #assert_equal("hidden_1" , $ff.hiddens[2].id )
71
+ end
72
+ end
@@ -0,0 +1,42 @@
1
+ <html>
2
+ <head>
3
+ <title>Alert Test</title>
4
+ <script type="text/javascript">
5
+ function disp_confirm()
6
+ {
7
+ testResult = document.getElementById('testResult');
8
+ var name=confirm("Press a button")
9
+ if (name==true) {
10
+ testResult.value = "You pressed the Confirm and OK button!"
11
+ }
12
+ else{
13
+ testResult.value = "You pressed the Confirm and Cancel button!"
14
+ }
15
+ }
16
+ function disp_alert()
17
+ {
18
+ testResult = document.getElementById('testResult');
19
+ alert("Press OK")
20
+ testResult.value = "You pressed the Alert button!"
21
+ }
22
+ </script>
23
+
24
+ </head>
25
+ <body>
26
+ <form action="get">
27
+ <p>There are two basic methods for bringing up dialogs using javascript.</p>
28
+ <ul>
29
+ <li>
30
+ alert(message) -- Display message and OK button.<br/>
31
+ <input type="button" id="btnAlert" value="alert" OnClick="disp_alert();" />
32
+ </li>
33
+ <li>
34
+ confirm(message) -- Display message and OK and Cancel buttons.<br/>
35
+ <input type="button" id="btnConfirm" value="confirm" OnClick="disp_confirm();" /> </li>
36
+ </ul>
37
+ <p>Results of dialogs:</p>
38
+ <input type="text" style="width:248px;" id="testResult" value="Test Result" />
39
+ </form>
40
+ </body>
41
+
42
+ </html>
@@ -0,0 +1,12 @@
1
+ <html>
2
+ <head>
3
+ <title>
4
+ Test page for buttons
5
+ </title>
6
+ </head>
7
+ <body>
8
+ CVS Revision: $Revision 1.0$
9
+ <br>
10
+ Blank page to fill in the frames
11
+ </body>
12
+ </html>