watir 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/readme.rb +211 -0
  2. data/unittests/WindowLogonExample.rb +30 -0
  3. data/unittests/WindowLogonExtra.rb +7 -0
  4. data/unittests/all_tests.rb +10 -0
  5. data/unittests/all_tests_concurrent.rb +57 -0
  6. data/unittests/attachToExistingWindow_test.rb +40 -0
  7. data/unittests/buttons_test.rb +131 -0
  8. data/unittests/checkbox_test.rb +149 -0
  9. data/unittests/core_tests.rb +9 -0
  10. data/unittests/css_test.rb +60 -0
  11. data/unittests/div_test.rb +179 -0
  12. data/unittests/errorchecker_test.rb +29 -0
  13. data/unittests/filefield_test.rb +35 -0
  14. data/unittests/form_test.rb +279 -0
  15. data/unittests/frame_test.rb +141 -0
  16. data/unittests/html/blankpage.html +12 -0
  17. data/unittests/html/buttons1.html +40 -0
  18. data/unittests/html/checkboxes1.html +69 -0
  19. data/unittests/html/complex_table.html +36 -0
  20. data/unittests/html/cssTest.html +42 -0
  21. data/unittests/html/div.html +105 -0
  22. data/unittests/html/fileupload.html +45 -0
  23. data/unittests/html/formTest1.html +39 -0
  24. data/unittests/html/forms2.html +45 -0
  25. data/unittests/html/forms3.html +132 -0
  26. data/unittests/html/forms4.html +27 -0
  27. data/unittests/html/frame_buttons.html +4 -0
  28. data/unittests/html/frame_links.html +4 -0
  29. data/unittests/html/frame_multi.html +5 -0
  30. data/unittests/html/iframeTest.html +13 -0
  31. data/unittests/html/iframeTest1.html +7 -0
  32. data/unittests/html/iframeTest2.html +6 -0
  33. data/unittests/html/images/1.gif +0 -0
  34. data/unittests/html/images/2.GIF +0 -0
  35. data/unittests/html/images/3.GIF +0 -0
  36. data/unittests/html/images/button.jpg +0 -0
  37. data/unittests/html/images/circle.jpg +0 -0
  38. data/unittests/html/images/minus.GIF +0 -0
  39. data/unittests/html/images/originaltriangle.jpg +0 -0
  40. data/unittests/html/images/plus.gif +0 -0
  41. data/unittests/html/images/square.jpg +0 -0
  42. data/unittests/html/images/triangle.jpg +0 -0
  43. data/unittests/html/images1.html +52 -0
  44. data/unittests/html/javascriptevents.html +39 -0
  45. data/unittests/html/link_pass.html +11 -0
  46. data/unittests/html/links1.html +37 -0
  47. data/unittests/html/links2.html +11 -0
  48. data/unittests/html/nestedFrames.html +6 -0
  49. data/unittests/html/pass.html +10 -0
  50. data/unittests/html/popups1.html +60 -0
  51. data/unittests/html/radioButtons1.html +71 -0
  52. data/unittests/html/select_tealeaf.html +54 -0
  53. data/unittests/html/selectboxes1.html +55 -0
  54. data/unittests/html/simple_table.html +26 -0
  55. data/unittests/html/simple_table_buttons.html +104 -0
  56. data/unittests/html/simple_table_columns.html +76 -0
  57. data/unittests/html/table1.html +142 -0
  58. data/unittests/html/textarea.html +30 -0
  59. data/unittests/html/textfields1.html +87 -0
  60. data/unittests/html/textsearch.html +44 -0
  61. data/unittests/ie_mock.rb +93 -0
  62. data/unittests/ie_test.rb +50 -0
  63. data/unittests/images_test.rb +179 -0
  64. data/unittests/iostring.rb +30 -0
  65. data/unittests/iostring_test.rb +48 -0
  66. data/unittests/js_events_test.rb +77 -0
  67. data/unittests/jscriptExtraAlert.rb +6 -0
  68. data/unittests/jscriptExtraConfirmCancel.rb +7 -0
  69. data/unittests/jscriptExtraConfirmOk.rb +7 -0
  70. data/unittests/jscriptPushButton.rb +5 -0
  71. data/unittests/jscript_test.rb +57 -0
  72. data/unittests/links_test.rb +169 -0
  73. data/unittests/minmax_test.rb +31 -0
  74. data/unittests/navigate_test.rb +56 -0
  75. data/unittests/non_core_tests.rb +9 -0
  76. data/unittests/pagecontainstext_test.rb +49 -0
  77. data/unittests/popups_test.rb +44 -0
  78. data/unittests/radios_test.rb +164 -0
  79. data/unittests/screen_capture_test.rb +53 -0
  80. data/unittests/selectbox_test.rb +197 -0
  81. data/unittests/send_keys_test.rb +29 -0
  82. data/unittests/setup.rb +47 -0
  83. data/unittests/table_test.rb +306 -0
  84. data/unittests/textAreafields_test.rb +81 -0
  85. data/unittests/textfields_test.rb +239 -0
  86. data/watir.rb +3744 -0
  87. data/watir/AutoItX3.dll +0 -0
  88. data/watir/WindowHelper.rb +47 -0
  89. data/watir/camel_case.rb +37 -0
  90. data/watir/clickJSDialog.rb +19 -0
  91. data/watir/cookiemanager.rb +53 -0
  92. data/watir/exceptions.rb +60 -0
  93. data/watir/screen_capture.rb +115 -0
  94. data/watir/setFileDialog.rb +16 -0
  95. data/watir/testUnitAddons.rb +47 -0
  96. data/watir/watir_simple.rb +475 -0
  97. data/watir/winClicker.rb +505 -0
  98. metadata +152 -0
@@ -0,0 +1,149 @@
1
+ # feature tests for Check Boxes
2
+ # revision: $Revision: 1.30 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
+ require 'unittests/setup'
6
+
7
+ class TC_CheckBox < Test::Unit::TestCase
8
+ include Watir
9
+
10
+ def setup()
11
+ $ie.goto($htmlRoot + "checkboxes1.html")
12
+ end
13
+
14
+ 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("1" , $ie.checkbox(:name,"box4").value )
28
+ assert_equal("3" , $ie.checkbox(:name,"box4" , 3).value )
29
+ assert_equal("checkbox" , $ie.checkbox(:name,"box4" , 3).type )
30
+ assert_equal(false , $ie.checkbox(:name,"box4" , 3).disabled )
31
+ assert_equal("" , $ie.checkbox(:name,"box4" , 3).id )
32
+
33
+ assert_equal("box4-value5" , $ie.checkbox(:name,"box4" , 5).title)
34
+ assert_equal("" , $ie.checkbox(:name,"box4" , 4).title)
35
+ end
36
+
37
+ def test_onClick
38
+ assert_false($ie.button(:value , "foo").enabled?)
39
+ $ie.checkBox(:name, "box5").set
40
+ assert($ie.button(:value , "foo").enabled?)
41
+
42
+ $ie.checkBox(:name, "box5").clear
43
+ assert_false($ie.button(:value , "foo").enabled?)
44
+
45
+ $ie.checkBox(:name, "box5").clear
46
+ assert_false($ie.button(:value , "foo").enabled?)
47
+ end
48
+
49
+ def test_CheckBox_Exists
50
+ assert($ie.checkBox(:name, "box1").exists?)
51
+ assert_false($ie.checkBox(:name, "missing").exists?)
52
+
53
+ assert($ie.checkbox(:name, "box4" , 1).exists?)
54
+ assert_false($ie.checkbox(:name, "box4" , 22).exists?)
55
+ end
56
+
57
+ def test_checkbox_Enabled
58
+ assert_raises(UnknownObjectException) { $ie.checkbox(:name, "noName").enabled? }
59
+ assert_raises(UnknownObjectException) { $ie.checkbox(:id, "noName").enabled? }
60
+ assert_raises(UnknownObjectException) { $ie.checkbox(:name, "box4" , 6).enabled? }
61
+
62
+ assert($ie.checkbox(:name, "box1").enabled?)
63
+ assert_false($ie.checkbox(:name, "box2").enabled?)
64
+
65
+ assert($ie.checkbox(:name, "box4", 4).enabled?)
66
+ assert_false($ie.checkbox(:name, "box4" , 5 ).enabled?)
67
+ end
68
+
69
+ def test_checkbox_isSet
70
+ assert_raises(UnknownObjectException ) { $ie.checkbox(:name, "noName").isSet? }
71
+
72
+ assert_false($ie.checkbox(:name, "box1").isSet?)
73
+ assert_false($ie.checkbox(:name, "box2").isSet?)
74
+ assert($ie.checkbox(:name, "box3").isSet?)
75
+
76
+ assert_false($ie.checkbox(:name, "box4" , 2 ).isSet?)
77
+ assert($ie.checkbox(:name, "box4" , 1 ).isSet?)
78
+ end
79
+
80
+ def test_checkbox_clear
81
+ assert_raises(UnknownObjectException) { $ie.checkbox(:name, "noName").clear }
82
+ $ie.checkbox(:name, "box1").clear
83
+ assert_false($ie.checkbox(:name, "box1").isSet?)
84
+
85
+ assert_raises(ObjectDisabledException) { $ie.checkbox(:name, "box2").clear }
86
+ assert_false($ie.checkbox(:name, "box2").isSet?)
87
+
88
+ $ie.checkbox(:name, "box3").clear
89
+ assert_false($ie.checkbox(:name, "box3").isSet?)
90
+
91
+ $ie.checkbox(:name, "box4" , 1).clear
92
+ assert_false($ie.checkbox(:name, "box4" , 1).isSet?)
93
+ end
94
+
95
+ def test_checkbox_getState
96
+ assert_raises(UnknownObjectException) { $ie.checkbox(:name, "noName").getState }
97
+ assert_equal( false , $ie.checkbox(:name, "box1").getState )
98
+ assert_equal( true , $ie.checkbox(:name, "box3").getState)
99
+
100
+ # checkboxes that have the same name but different values
101
+ assert_equal( false , $ie.checkbox(:name, "box4" , 2).getState )
102
+ assert_equal( true , $ie.checkbox(:name, "box4" , 1).getState)
103
+ end
104
+
105
+ def test_checkbox_set
106
+ assert_raises(UnknownObjectException) { $ie.checkbox(:name, "noName").set }
107
+ $ie.checkbox(:name, "box1").set
108
+ assert($ie.checkbox(:name, "box1").isSet?)
109
+
110
+ assert_raises(ObjectDisabledException) { $ie.checkbox(:name, "box2").set }
111
+
112
+ $ie.checkbox(:name, "box3").set
113
+ assert($ie.checkbox(:name, "box3").isSet?)
114
+
115
+ # checkboxes that have the same name but different values
116
+ $ie.checkbox(:name, "box4" , 3).set
117
+ assert($ie.checkbox(:name, "box4" , 3).isSet?)
118
+
119
+ # test set using the optinal true/false
120
+ # assumes the checkbox is already checked
121
+ $ie.checkbox(:name, "box1").set( false )
122
+ assert_false($ie.checkbox(:name, "box1").isSet?)
123
+
124
+ $ie.checkbox(:name, "box1").set( true )
125
+ assert($ie.checkbox(:name, "box1").isSet?)
126
+
127
+
128
+
129
+
130
+ end
131
+
132
+ def test_checkbox_iterator
133
+
134
+ assert_equal(11, $ie.checkboxes.length)
135
+ assert_equal("box1" , $ie.checkboxes[1].name )
136
+
137
+ index=1
138
+ $ie.checkboxes.each do |c|
139
+ assert_equal( $ie.checkbox(:index, index).name , c.name )
140
+ assert_equal( $ie.checkbox(:index, index).id, c.id )
141
+ assert_equal( $ie.checkbox(:index, index).value, c.value )
142
+ index+=1
143
+ end
144
+ assert_equal(index-1, $ie.checkboxes.length)
145
+
146
+ end
147
+
148
+
149
+ end
@@ -0,0 +1,9 @@
1
+ TOPDIR = File.join(File.dirname(__FILE__), '..')
2
+ $LOAD_PATH.unshift TOPDIR
3
+
4
+ require 'unittests/setup.rb'
5
+
6
+ Dir.chdir TOPDIR
7
+ $core_tests.each {|x| require x}
8
+
9
+
@@ -0,0 +1,60 @@
1
+ # feature tests for css
2
+ # revision: $Revision: 1.14.4.1 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
+ require 'unittests/setup'
6
+
7
+ class TC_CSS < Test::Unit::TestCase
8
+ include Watir
9
+
10
+ def divTester( message )
11
+
12
+ divs = $ie.getIE.document.getElementsByTagName("DIV")
13
+ puts "Found #{divs.length} div tags"
14
+ divs.each do |d|
15
+ puts "Checking div #{d.id}"
16
+ puts "div #{d.invoke("id") } class is #{d.invoke("className") }"
17
+ end
18
+ end
19
+
20
+ def isMessageDisplayed(message)
21
+
22
+ s = false
23
+ divs = $ie.getIE.document.getElementsByTagName("DIV")
24
+ #puts "Found #{divs.length} div tags"
25
+ divs.each do |d|
26
+ #puts "----Checking div #{d.id} innertext is ( #{d.innerText} )"
27
+
28
+ if d.innerText.to_s.downcase.match( /#{message}/i )
29
+
30
+ #puts "div #{d.invoke("id") } class is #{d.invoke("className") }"
31
+ if d.invoke("className").to_s.downcase.match(/show/i)
32
+ #puts "message is shown!!!"
33
+ s = true
34
+ end
35
+
36
+ end
37
+ end
38
+
39
+ #puts "Not Shown " if s== false
40
+ return s
41
+ end
42
+
43
+ def gotoCSSPage()
44
+ $ie.goto($htmlRoot + "cssTest.html")
45
+ end
46
+
47
+ def test_SuccessMessage
48
+ gotoCSSPage()
49
+ $ie.button( :caption , "Success").click
50
+
51
+ #isMessageDisplayed( "Success" )
52
+ #divTester( "Success" )
53
+ assert( isMessageDisplayed("Success") )
54
+
55
+ $ie.button( :caption , "Failure").click
56
+
57
+ assert_false(isMessageDisplayed("Success") )
58
+ end
59
+ end
60
+
@@ -0,0 +1,179 @@
1
+ # feature tests for Divs, Spans and P's
2
+ # revision: $Revision: 1.15 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
+ require 'unittests/setup'
6
+
7
+ class TC_Divs < Test::Unit::TestCase
8
+ include Watir
9
+
10
+ def setup()
11
+ $ie.goto($htmlRoot + "div.html")
12
+ end
13
+
14
+ def test_divs
15
+ assert_raises(UnknownObjectException) {$ie.div(:id , "div77").click }
16
+ assert_raises(UnknownObjectException) {$ie.div(:title , "div77").click }
17
+
18
+ assert($ie.text_field(:name, "text1").verify_contains("0") )
19
+ $ie.div(:id , "div3").click
20
+ assert($ie.text_field(:name, "text1").verify_contains("1") )
21
+ $ie.div(:id , "div4").click
22
+ assert($ie.text_field(:name, "text1").verify_contains("0") )
23
+ end
24
+
25
+ def test_div_properties
26
+ assert_raises(UnknownObjectException) {$ie.div(:id , "div77").text }
27
+ assert_raises(UnknownObjectException) {$ie.div(:title , "div77").text }
28
+
29
+ assert_equal("This div has an onClick that increments text1",
30
+ $ie.div(:id , "div3").text.strip )
31
+ assert_equal("This text is in a div with an id of div1 and title of test1",
32
+ $ie.div(:title , "Test1").text.strip )
33
+
34
+ assert_raises(UnknownObjectException) {$ie.div(:id , "div77").class_name }
35
+ assert_equal("blueText" , $ie.div(:id , "div2").class_name )
36
+ assert_equal("" , $ie.div(:id , "div1").class_name )
37
+
38
+ assert_raises(UnknownObjectException) {$ie.div(:index , 44).class_name }
39
+ assert_equal("div1" , $ie.div(:index , 1).id )
40
+ assert_equal("" , $ie.div(:index , 1).class_name )
41
+ assert_equal("blueText" , $ie.div(:index , 2).class_name )
42
+ assert_equal("Div" , $ie.div(:index , 2).type)
43
+ assert_equal("" , $ie.div(:index , 2).value)
44
+ assert_equal(false , $ie.div(:index , 2).disabled)
45
+ assert_equal("" , $ie.div(:index , 2).name)
46
+ assert_equal("div2", $ie.div(:index , 2).id)
47
+ end
48
+
49
+ def test_div_iterator
50
+ assert_equal( 7 , $ie.divs.length)
51
+ assert_equal( "div1" , $ie.divs[1].id )
52
+
53
+ index =1
54
+ $ie.divs.each do |s|
55
+ # puts "each - div= " + s.to_s
56
+ assert_equal($ie.div(:index, index ).name , s.name )
57
+ assert_equal($ie.div(:index, index ).id , s.id )
58
+ assert_equal($ie.div(:index, index ).class_name , s.class_name )
59
+ index +=1
60
+ end
61
+ assert_equal(index-1, $ie.divs.length) # -1 as we add 1 at the end of the loop
62
+ end
63
+
64
+ def test_objects_in_div
65
+ assert($ie.div(:id, 'buttons1').button(:index,1).exists? )
66
+ assert_false($ie.div(:id, 'buttons1').button(:index,3).exists? )
67
+ assert($ie.div(:id, 'buttons1').button(:name,'b1').exists? )
68
+
69
+ assert($ie.div(:id, 'buttons2').button(:index,1).exists? )
70
+ assert($ie.div(:id, 'buttons2').button(:index,2).exists? )
71
+ assert_false($ie.div(:id, 'buttons1').button(:index,3).exists? )
72
+
73
+ $ie.div(:id, 'buttons1').button(:index,1).click
74
+
75
+ assert_equal( 'button1' , $ie.div(:id , 'text_fields1').text_field(:index,1).value)
76
+
77
+ assert_equal( 3 , $ie.div(:id , 'text_fields1').text_fields.length )
78
+ end
79
+
80
+ #---- Span Tests ---
81
+ def test_spans
82
+ assert_raises(UnknownObjectException) {$ie.span(:id , "span77").click }
83
+ assert_raises(UnknownObjectException) {$ie.span(:title , "span77").click }
84
+
85
+ assert($ie.text_field(:name, "text2").verify_contains("0") )
86
+ $ie.span(:id , "span3").click
87
+ assert($ie.text_field(:name, "text2").verify_contains("1") )
88
+
89
+ $ie.span(:id , "span4").click
90
+ assert($ie.text_field(:name, "text2").verify_contains("0") )
91
+
92
+ end
93
+
94
+ def test_span_properties
95
+ assert_raises(UnknownObjectException) {$ie.span(:id , "span77").text }
96
+ assert_raises(UnknownObjectException) {$ie.span(:title , "span77").text }
97
+
98
+ assert_equal("This span has an onClick that increments text2" , $ie.span(:id , "span3").text.strip )
99
+ assert_equal("This text is in a span with an id of span1 and title of test2" , $ie.span(:title , "Test2").text.strip )
100
+
101
+ assert_raises(UnknownObjectException) {$ie.span(:id , "span77").class_name }
102
+ assert_equal("blueText" , $ie.span(:id , "span2").class_name )
103
+ assert_equal("" , $ie.span(:id , "span1").class_name )
104
+
105
+ assert_raises(UnknownObjectException) {$ie.span(:index , 44).class_name }
106
+ assert_equal("span1" , $ie.span(:index , 1).id )
107
+ assert_equal("" , $ie.span(:index , 1).class_name )
108
+ assert_equal("blueText" , $ie.span(:index , 2).class_name )
109
+ assert_equal("Span" , $ie.span(:index , 2).type)
110
+ assert_equal("" , $ie.span(:index , 2).value)
111
+ assert_equal(false , $ie.span(:index , 2).disabled)
112
+ assert_equal("" , $ie.span(:index , 2).name)
113
+ assert_equal("span2", $ie.span(:index , 2).id)
114
+ end
115
+
116
+ def test_span_iterator
117
+ assert_equal( 7 , $ie.spans.length)
118
+ assert_equal( "span1" , $ie.spans[1].id )
119
+
120
+ index = 1
121
+ $ie.spans.each do |s|
122
+ # puts "each - span = " + s.to_s
123
+ assert_equal($ie.span(:index, index ).name , s.name )
124
+ assert_equal($ie.span(:index, index ).id , s.id )
125
+ assert_equal($ie.span(:index, index ).class_name , s.class_name )
126
+ index +=1
127
+ end
128
+ assert_equal(index-1, $ie.spans.length) # -1 as we add 1 at the end of the loop
129
+ end
130
+
131
+ def test_objects_in_span
132
+ assert($ie.span(:id, 'buttons1').button(:index,1).exists? )
133
+ assert_false($ie.span(:id, 'buttons1').button(:index,3).exists? )
134
+ assert($ie.span(:id, 'buttons1').button(:name,'b1').exists? )
135
+
136
+ assert($ie.span(:id, 'buttons2').button(:index,1).exists? )
137
+ assert($ie.span(:id, 'buttons2').button(:index,2).exists? )
138
+ assert_false($ie.span(:id, 'buttons1').button(:index,3).exists? )
139
+
140
+ $ie.span(:id, 'buttons1').button(:index,1).click
141
+
142
+ assert_equal( 'button1' , $ie.span(:id , 'text_fields1').text_field(:index,1).value)
143
+
144
+ assert_equal( 3 , $ie.span(:id , 'text_fields1').text_fields.length )
145
+ end
146
+
147
+ def test_p
148
+ assert($ie.p(:id, 'number1').exists?)
149
+ assert($ie.p(:index, 3).exists?)
150
+ assert($ie.p(:title, 'test_3').exists?)
151
+
152
+ assert_false($ie.p(:id, 'missing').exists?)
153
+ assert_false($ie.p(:index, 8).exists?)
154
+ assert_false($ie.p(:title, 'test_55').exists?)
155
+
156
+ assert_raises( UnknownObjectException) {$ie.p(:id , 'missing').class_name }
157
+ assert_raises( UnknownObjectException) {$ie.p(:id , 'missing').text }
158
+ assert_raises( UnknownObjectException) {$ie.p(:id , 'missing').title }
159
+ assert_raises( UnknownObjectException) {$ie.p(:id , 'missing').to_s }
160
+ assert_raises( UnknownObjectException) {$ie.p(:id , 'missing').disabled }
161
+
162
+ assert_equal( 'redText' , $ie.p(:index,1).class_name)
163
+ assert_equal( 'P_tag_1' , $ie.p(:index,1).title)
164
+ assert_equal( 'This text is in a p with an id of number2' , $ie.p(:index,2).text)
165
+ end
166
+
167
+ def test_p_iterator
168
+ assert_equal( 3, $ie.ps.length)
169
+ assert_equal( 'italicText', $ie.ps[2].class_name)
170
+ assert_equal( 'number3', $ie.ps[3].id)
171
+
172
+ count=1
173
+ $ie.ps.each do |p|
174
+ assert_equal('number'+count.to_s , p.id)
175
+ count+=1
176
+ end
177
+ assert_equal( count-1 , $ie.ps.length)
178
+ end
179
+ end
@@ -0,0 +1,29 @@
1
+ # feature tests for Goto
2
+ # revision: $Revision: 1.2 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
+ require 'unittests/setup'
6
+
7
+ class TC_error_checker< Test::Unit::TestCase
8
+ include Watir
9
+
10
+ def goto_page(page)
11
+ $ie.goto($htmlRoot + page)
12
+ end
13
+
14
+ def test_simple_checker
15
+ button_checker = Proc.new{
16
+ |ie| raise RuntimeError, "text 'buttons' was missing" if !ie.pageContainsText(/buttons/)
17
+ }
18
+
19
+ $ie.add_checker(button_checker )
20
+ assert_raises( RuntimeError ) { goto_page('forms3.html') }
21
+ assert_nothing_raised { goto_page('buttons1.html') }
22
+
23
+ $ie.disable_checker( button_checker )
24
+ assert_nothing_raised { goto_page('forms3.html') }
25
+
26
+ end
27
+
28
+
29
+ end
@@ -0,0 +1,35 @@
1
+ # feature tests for TextArea Fields
2
+ # revision: $Revision: 1.3 $
3
+
4
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
+ require 'unittests/setup'
6
+
7
+ class TC_FileField < Test::Unit::TestCase
8
+ include Watir
9
+
10
+ def gotoPage()
11
+ $ie.goto($htmlRoot + "fileupload.html")
12
+ end
13
+
14
+ def test_fileField_Exists
15
+ gotoPage()
16
+ #test for existance of 4 file area
17
+ assert($ie.fileField(:name,"file1").exists?)
18
+ assert($ie.fileField(:id,"file2").exists?)
19
+ #test for missing
20
+ assert_false($ie.fileField(:name, "missing").exists?)
21
+ assert_false($ie.fileField(:name,"totallybogus").exists?)
22
+ #pop one open and put something in it.
23
+ $ie.fileField(:name,"file1").set($htmlRoot + "fileupload.html")
24
+ #click the upload button
25
+ $ie.button(:name,"upload").click
26
+
27
+ assert($ie.contains_text("PASS"))
28
+ end
29
+
30
+ def test_iterator
31
+ gotoPage()
32
+ assert_equal(6, $ie.file_fields.length)
33
+ end
34
+
35
+ end