firewatir 1.6.2 → 1.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +32 -0
- data/lib/firewatir.rb +40 -50
- data/lib/firewatir/container.rb +491 -534
- data/lib/firewatir/document.rb +239 -0
- data/lib/firewatir/element.rb +1365 -0
- data/lib/firewatir/element_collections.rb +314 -0
- data/lib/firewatir/elements/button.rb +15 -0
- data/lib/firewatir/elements/file_field.rb +29 -0
- data/lib/firewatir/elements/form.rb +40 -0
- data/lib/firewatir/elements/frame.rb +55 -0
- data/lib/firewatir/elements/hidden.rb +56 -0
- data/lib/firewatir/elements/image.rb +139 -0
- data/lib/firewatir/elements/input_element.rb +44 -0
- data/lib/firewatir/elements/link.rb +76 -0
- data/lib/firewatir/elements/non_control_element.rb +53 -0
- data/lib/firewatir/elements/non_control_elements.rb +108 -0
- data/lib/firewatir/elements/not_used.rb +278 -0
- data/lib/firewatir/elements/option.rb +131 -0
- data/lib/firewatir/elements/radio_check_common.rb +163 -0
- data/lib/firewatir/elements/select_list.rb +188 -0
- data/lib/firewatir/elements/table.rb +218 -0
- data/lib/firewatir/elements/table_cell.rb +54 -0
- data/lib/firewatir/elements/table_row.rb +100 -0
- data/lib/firewatir/elements/text_field.rb +218 -0
- data/lib/firewatir/exceptions.rb +10 -10
- data/lib/firewatir/firefox.rb +1040 -1127
- data/lib/firewatir/jssh_socket.rb +101 -0
- data/lib/firewatir/version.rb +5 -5
- data/unittests/attach_to_new_window_test.rb +49 -42
- data/unittests/bug_fixes_test.rb +195 -198
- data/unittests/buttons_xpath_test.rb +88 -88
- data/unittests/checkbox_test.rb +158 -155
- data/unittests/checkbox_xpath_test.rb +107 -107
- data/unittests/div_test.rb +275 -276
- data/unittests/filefield_test.rb +49 -45
- data/unittests/filefield_xpath_test.rb +35 -35
- data/unittests/form_test.rb +296 -308
- data/unittests/frame_test.rb +159 -152
- data/unittests/hidden_test.rb +85 -85
- data/unittests/hidden_xpath_test.rb +72 -72
- data/unittests/html/blankpage.html +11 -11
- data/unittests/html/buttons1.html +61 -61
- data/unittests/html/cssTest.html +42 -42
- data/unittests/html/div.html +72 -72
- data/unittests/html/fileupload.html +45 -45
- data/unittests/html/formTest1.html +38 -38
- data/unittests/html/forms2.html +45 -45
- data/unittests/html/frame_buttons.html +3 -3
- data/unittests/html/iframeTest.html +14 -14
- data/unittests/html/iframeTest1.html +13 -13
- data/unittests/html/iframeTest2.html +5 -5
- data/unittests/html/links1.html +42 -42
- data/unittests/html/nestedFrames.html +6 -6
- data/unittests/html/new_browser.html +1 -0
- data/unittests/html/new_browser_popup.html +8 -0
- data/unittests/html/pass.html +9 -9
- data/unittests/html/pre.html +27 -27
- data/unittests/html/redirect.html +10 -10
- data/unittests/html/redirect1.html +8 -8
- data/unittests/html/redirect2.html +8 -8
- data/unittests/html/redirect3.html +8 -8
- data/unittests/html/simple_table_columns.html +74 -74
- data/unittests/html/table1.html +165 -165
- data/unittests/html/textfields1.html +62 -62
- data/unittests/images_test.rb +198 -205
- data/unittests/images_xpath_test.rb +118 -119
- data/unittests/javascript_test.rb +75 -75
- data/unittests/links_test.rb +231 -232
- data/unittests/links_xpath_test.rb +79 -79
- data/unittests/mozilla_all_tests.rb +7 -7
- data/unittests/pre_test.rb +75 -76
- data/unittests/radios_xpath_test.rb +101 -101
- data/unittests/redirect_test.rb +41 -41
- data/unittests/selectbox_test.rb +142 -142
- data/unittests/selectbox_xpath_test.rb +129 -129
- data/unittests/setup.rb +29 -30
- data/unittests/table_test.rb +385 -373
- data/unittests/table_xpath_test.rb +185 -185
- data/unittests/textfields_test.rb +234 -233
- data/unittests/textfields_xpath_test.rb +113 -113
- metadata +33 -11
- data/lib/firewatir/MozillaBaseElement.rb +0 -1863
- data/lib/firewatir/htmlelements.rb +0 -1911
- data/unittests/iostring.rb +0 -30
- data/unittests/iostring_test.rb +0 -48
data/unittests/filefield_test.rb
CHANGED
@@ -1,45 +1,49 @@
|
|
1
|
-
# feature tests for file Fields
|
2
|
-
# revision: $Revision: 1.0 $
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
|
-
require 'unittests/setup'
|
6
|
-
|
7
|
-
class TC_FileField < Test::Unit::TestCase
|
8
|
-
|
9
|
-
|
10
|
-
def
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_fileField_Exists
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
1
|
+
# feature tests for file Fields
|
2
|
+
# revision: $Revision: 1.0 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_FileField < Test::Unit::TestCase
|
8
|
+
|
9
|
+
|
10
|
+
def setup
|
11
|
+
goto_page("fileupload.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_fileField_Exists
|
15
|
+
#test for existance of 4 file area
|
16
|
+
assert(browser.file_field(:name,"file1").exists?)
|
17
|
+
assert(browser.file_field(:id,"file2").exists?)
|
18
|
+
#test for missing
|
19
|
+
assert_false(browser.file_field(:name, "missing").exists?)
|
20
|
+
assert_false(browser.file_field(:name,"totallybogus").exists?)
|
21
|
+
#pop one open and put something in it.
|
22
|
+
browser.file_field(:name,"file3").set($htmlRoot + "fileupload.html")
|
23
|
+
#click the upload button
|
24
|
+
browser.button(:name,"upload").click
|
25
|
+
|
26
|
+
assert(browser.text.include?("PASS"))
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_iterator
|
30
|
+
assert_equal(6, browser.file_fields.length)
|
31
|
+
arrFileFields = browser.file_fields
|
32
|
+
assert_equal("file1", arrFileFields[1].name)
|
33
|
+
assert_equal("file2", arrFileFields[2].id)
|
34
|
+
assert_equal("disabled", arrFileFields[3].name)
|
35
|
+
assert_equal("file3", arrFileFields[4].name)
|
36
|
+
assert_equal("beforetest", arrFileFields[5].name)
|
37
|
+
assert_equal("aftertest", arrFileFields[6].name)
|
38
|
+
arrFileFields.each do |fileField|
|
39
|
+
assert_equal("file", fileField.type)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_file_field_onchange
|
44
|
+
assert_equal("", browser.file_field(:name, 'file3').alt)
|
45
|
+
browser.file_field(:name,"file3").set($htmlRoot + "fileupload.html")
|
46
|
+
assert_equal("changed", browser.file_field(:name, 'file3').alt)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -1,35 +1,35 @@
|
|
1
|
-
# feature tests for TextArea Fields
|
2
|
-
# revision: $Revision: 1.0 $
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
|
-
require 'unittests/setup'
|
6
|
-
|
7
|
-
class TC_FileField_XPath < Test::Unit::TestCase
|
8
|
-
|
9
|
-
|
10
|
-
def gotoPage
|
11
|
-
goto_page("fileupload.html")
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_file_field_Exists
|
15
|
-
gotoPage()
|
16
|
-
#test for existance of 4 file area
|
17
|
-
assert(browser.file_field(:xpath, "//input[@name='file1']").exists?)
|
18
|
-
assert(browser.file_field(:xpath, "//input[@id='file2']").exists?)
|
19
|
-
#test for missing
|
20
|
-
assert_false(browser.file_field(:xpath, "//input[@name='missing']").exists?)
|
21
|
-
assert_false(browser.file_field(:xpath, "//input[@name='totallybogus']").exists?)
|
22
|
-
#pop one open and put something in it.
|
23
|
-
browser.file_field(:xpath, "//input[@name='file3']").set($htmlRoot + "fileupload.html")
|
24
|
-
#click the upload button
|
25
|
-
browser.button(:xpath, "//input[@name='upload']").click
|
26
|
-
|
27
|
-
assert(browser.text.include?("PASS"))
|
28
|
-
end
|
29
|
-
|
30
|
-
#def test_iterator
|
31
|
-
# gotoPage()
|
32
|
-
# assert_equal(6, browser.file_fields.length)
|
33
|
-
#end
|
34
|
-
|
35
|
-
end
|
1
|
+
# feature tests for TextArea Fields
|
2
|
+
# revision: $Revision: 1.0 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_FileField_XPath < Test::Unit::TestCase
|
8
|
+
|
9
|
+
|
10
|
+
def gotoPage
|
11
|
+
goto_page("fileupload.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_file_field_Exists
|
15
|
+
gotoPage()
|
16
|
+
#test for existance of 4 file area
|
17
|
+
assert(browser.file_field(:xpath, "//input[@name='file1']").exists?)
|
18
|
+
assert(browser.file_field(:xpath, "//input[@id='file2']").exists?)
|
19
|
+
#test for missing
|
20
|
+
assert_false(browser.file_field(:xpath, "//input[@name='missing']").exists?)
|
21
|
+
assert_false(browser.file_field(:xpath, "//input[@name='totallybogus']").exists?)
|
22
|
+
#pop one open and put something in it.
|
23
|
+
browser.file_field(:xpath, "//input[@name='file3']").set($htmlRoot + "fileupload.html")
|
24
|
+
#click the upload button
|
25
|
+
browser.button(:xpath, "//input[@name='upload']").click
|
26
|
+
|
27
|
+
assert(browser.text.include?("PASS"))
|
28
|
+
end
|
29
|
+
|
30
|
+
#def test_iterator
|
31
|
+
# gotoPage()
|
32
|
+
# assert_equal(6, browser.file_fields.length)
|
33
|
+
#end
|
34
|
+
|
35
|
+
end
|
data/unittests/form_test.rb
CHANGED
@@ -1,308 +1,296 @@
|
|
1
|
-
# feature tests for Forms
|
2
|
-
# revision: $Revision: 1.0 $
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
|
-
require 'unittests/setup'
|
6
|
-
|
7
|
-
class TC_Forms2 < Test::Unit::TestCase # Note: there is no TC_Forms
|
8
|
-
|
9
|
-
|
10
|
-
def setup
|
11
|
-
goto_page("forms2.html")
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_Form_Exists
|
15
|
-
assert(browser.form(:name, "test2").exists?)
|
16
|
-
assert_false(browser.form(:name, "missing").exists?)
|
17
|
-
|
18
|
-
assert(browser.form("test2").exists?)
|
19
|
-
assert_false(browser.form( "missing").exists?)
|
20
|
-
|
21
|
-
assert(browser.form(:index, 1).exists?)
|
22
|
-
assert_false(browser.form(:index, 88).exists?)
|
23
|
-
|
24
|
-
assert(browser.form(:method, "get").exists?)
|
25
|
-
assert_false(browser.form(:method, "missing").exists?)
|
26
|
-
|
27
|
-
assert(browser.form(:id, 'f2').exists?)
|
28
|
-
assert_false(browser.form(:id, 'missing').exists?)
|
29
|
-
|
30
|
-
assert(browser.form(:action, /pass.html/).exists?)
|
31
|
-
assert_false(browser.form(:action, "missing").exists?)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_ButtonInForm
|
35
|
-
assert(browser.form(:name, "test2").button(:caption , "Submit").exists?)
|
36
|
-
end
|
37
|
-
|
38
|
-
# The following tests from bug 2261
|
39
|
-
tag_method :test_form_html, :fails_on_ie
|
40
|
-
def test_form_html
|
41
|
-
assert_equal("\n<BR><INPUT value=\"Submit\" type=\"submit\">\n".downcase(),
|
42
|
-
browser.form(:name, 'test2').html.downcase())
|
43
|
-
end
|
44
|
-
def test_form_flash
|
45
|
-
assert_nothing_raised{ browser.form(:name, 'test2').flash }
|
46
|
-
end
|
47
|
-
def test_form_sub_element
|
48
|
-
assert_equal('Click Me', browser.form(:index, 1).button(:name, 'b1').value)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
class TC_Form_Display < Test::Unit::TestCase
|
53
|
-
|
54
|
-
include
|
55
|
-
|
56
|
-
def test_showforms
|
57
|
-
goto_page("forms2.html")
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
browser.text_field(:id,
|
117
|
-
|
118
|
-
|
119
|
-
browser.
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
browser.text_field(:id,
|
124
|
-
|
125
|
-
|
126
|
-
browser.
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
browser.text_field(:id,
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
##
|
138
|
-
##
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
assert_equal('
|
143
|
-
assert_equal('
|
144
|
-
assert_equal('
|
145
|
-
|
146
|
-
|
147
|
-
assert_equal('
|
148
|
-
assert_equal('
|
149
|
-
assert_equal('
|
150
|
-
|
151
|
-
|
152
|
-
assert_equal('
|
153
|
-
assert_equal('
|
154
|
-
assert_equal('
|
155
|
-
|
156
|
-
|
157
|
-
assert_equal('
|
158
|
-
assert_equal('
|
159
|
-
assert_equal('
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
#
|
164
|
-
# browser.
|
165
|
-
#
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
assert( browser.button(:alt ,
|
170
|
-
|
171
|
-
|
172
|
-
assert_false( browser.button(:alt ,
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
assert_false( browser.button(:src ,
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
end
|
222
|
-
|
223
|
-
def
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
assert( browser.hidden(:
|
240
|
-
|
241
|
-
|
242
|
-
browser.hidden(:
|
243
|
-
|
244
|
-
|
245
|
-
browser.
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
browser.
|
257
|
-
|
258
|
-
|
259
|
-
browser.
|
260
|
-
|
261
|
-
assert_equal("
|
262
|
-
assert_equal("555" , browser.text_field(:name ,"vis2").value )
|
263
|
-
|
264
|
-
#
|
265
|
-
browser.
|
266
|
-
browser.
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
browser.
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
##
|
292
|
-
|
293
|
-
## browser.hiddens.
|
294
|
-
##
|
295
|
-
|
296
|
-
|
297
|
-
## assert_equal( "hid1", h.name)
|
298
|
-
## when 2
|
299
|
-
## assert_equal( "", h.name)
|
300
|
-
## assert_equal( "hidden_1", h.id)
|
301
|
-
## end
|
302
|
-
## count+=1
|
303
|
-
## end
|
304
|
-
#
|
305
|
-
## assert_equal("hid1" , browser.hiddens[1].name )
|
306
|
-
## assert_equal("hidden_1" , browser.hiddens[2].id )
|
307
|
-
end
|
308
|
-
end
|
1
|
+
# feature tests for Forms
|
2
|
+
# revision: $Revision: 1.0 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_Forms2 < Test::Unit::TestCase # Note: there is no TC_Forms
|
8
|
+
|
9
|
+
|
10
|
+
def setup
|
11
|
+
goto_page("forms2.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_Form_Exists
|
15
|
+
assert(browser.form(:name, "test2").exists?)
|
16
|
+
assert_false(browser.form(:name, "missing").exists?)
|
17
|
+
|
18
|
+
assert(browser.form("test2").exists?)
|
19
|
+
assert_false(browser.form( "missing").exists?)
|
20
|
+
|
21
|
+
assert(browser.form(:index, 1).exists?)
|
22
|
+
assert_false(browser.form(:index, 88).exists?)
|
23
|
+
|
24
|
+
assert(browser.form(:method, "get").exists?)
|
25
|
+
assert_false(browser.form(:method, "missing").exists?)
|
26
|
+
|
27
|
+
assert(browser.form(:id, 'f2').exists?)
|
28
|
+
assert_false(browser.form(:id, 'missing').exists?)
|
29
|
+
|
30
|
+
assert(browser.form(:action, /pass.html/).exists?)
|
31
|
+
assert_false(browser.form(:action, "missing").exists?)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_ButtonInForm
|
35
|
+
assert(browser.form(:name, "test2").button(:caption , "Submit").exists?)
|
36
|
+
end
|
37
|
+
|
38
|
+
# The following tests from bug 2261
|
39
|
+
tag_method :test_form_html, :fails_on_ie
|
40
|
+
def test_form_html
|
41
|
+
assert_equal("\n<BR><INPUT value=\"Submit\" type=\"submit\">\n".downcase(),
|
42
|
+
browser.form(:name, 'test2').html.downcase())
|
43
|
+
end
|
44
|
+
def test_form_flash
|
45
|
+
assert_nothing_raised{ browser.form(:name, 'test2').flash }
|
46
|
+
end
|
47
|
+
def test_form_sub_element
|
48
|
+
assert_equal('Click Me', browser.form(:index, 1).button(:name, 'b1').value)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class TC_Form_Display < Test::Unit::TestCase
|
53
|
+
|
54
|
+
include CaptureIOHelper
|
55
|
+
|
56
|
+
def test_showforms
|
57
|
+
goto_page("forms2.html")
|
58
|
+
actual = capture_stdout { browser.showForms }
|
59
|
+
assert_equal(<<END_OF_MESSAGE, actual)
|
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
|
+
|
83
|
+
def setup
|
84
|
+
goto_page("forms3.html")
|
85
|
+
end
|
86
|
+
|
87
|
+
# The following tests from bug 2261
|
88
|
+
def test_p_in_form
|
89
|
+
browser.form(:name, 'buttonsubmit').p(:index, 1).text
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_Form_Exists
|
93
|
+
assert(browser.form(:name, "test2").exists?)
|
94
|
+
assert_false(browser.form(:name, "missing").exists?)
|
95
|
+
|
96
|
+
assert(browser.form("test2").exists?)
|
97
|
+
assert_false(browser.form( "missing").exists?)
|
98
|
+
|
99
|
+
assert(browser.form(:index, 1).exists?)
|
100
|
+
assert_false(browser.form(:index, 88).exists?)
|
101
|
+
|
102
|
+
assert(browser.form(:method, "get").exists?)
|
103
|
+
assert_false(browser.form(:method, "missing").exists?)
|
104
|
+
|
105
|
+
assert(browser.form(:action, "pass.html").exists?)
|
106
|
+
assert_false(browser.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" , browser.checkbox(:index,1).name )
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_reset
|
115
|
+
browser.text_field(:id, "t1").set("Hello, reset test!")
|
116
|
+
assert_equal(browser.text_field(:id, 't1').value, 'Hello, reset test!')
|
117
|
+
|
118
|
+
browser.button(:id, "reset_button").click
|
119
|
+
assert_equal("" , browser.text_field(:id, 't1').value )
|
120
|
+
|
121
|
+
# also verify it works under a form
|
122
|
+
browser.text_field(:id, "t1").set("reset test - using a form")
|
123
|
+
assert_equal(browser.text_field(:id, 't1').value, 'reset test - using a form')
|
124
|
+
|
125
|
+
browser.form(:index,2).button(:index,2).click
|
126
|
+
assert_equal("" , browser.text_field(:id, 't1').value )
|
127
|
+
|
128
|
+
# also verify it works under a form, this time using the :id attribute
|
129
|
+
browser.text_field(:id, "t1").set("reset test - using a form")
|
130
|
+
assert_equal(browser.text_field(:id, 't1').value, 'reset test - using a form')
|
131
|
+
|
132
|
+
browser.form(:index,2).button(:id,'reset_button').click
|
133
|
+
assert_equal("" , browser.text_field(:id, 't1').value )
|
134
|
+
end
|
135
|
+
|
136
|
+
## def test_flash1
|
137
|
+
## browser.form(:name ,"test2").button(:caption , "Submit").flash
|
138
|
+
## end
|
139
|
+
#
|
140
|
+
def test_objects_with_same_name
|
141
|
+
assert_equal('textfield' ,browser.text_field( :name , 'g1').value )
|
142
|
+
assert_equal('button' ,browser.button( :name , 'g1').value )
|
143
|
+
assert_equal('1' ,browser.checkbox( :name , 'g1').value )
|
144
|
+
assert_equal('2' ,browser.radio( :name , 'g1').value )
|
145
|
+
|
146
|
+
assert_equal('textfield' ,browser.text_field( :name , /g1/).value )
|
147
|
+
assert_equal('button' ,browser.button( :name , /g1/).value )
|
148
|
+
assert_equal('1' ,browser.checkbox( :name , /g1/).value )
|
149
|
+
assert_equal('2' ,browser.radio( :name , /g1/).value )
|
150
|
+
|
151
|
+
assert_equal('textfield_id' ,browser.text_field( :id , 'g1').value )
|
152
|
+
assert_equal('button_id' ,browser.button( :id , 'g1').value )
|
153
|
+
assert_equal('1_id' ,browser.checkbox( :id , 'g1').value )
|
154
|
+
assert_equal('2_id' ,browser.radio( :id , 'g1').value )
|
155
|
+
|
156
|
+
assert_equal('textfield_id' ,browser.text_field( :id , /g1/).value )
|
157
|
+
assert_equal('button_id' ,browser.button( :id , /g1/).value )
|
158
|
+
assert_equal('1_id' ,browser.checkbox( :id , /g1/).value )
|
159
|
+
assert_equal('2_id' ,browser.radio( :id , /g1/).value )
|
160
|
+
end
|
161
|
+
|
162
|
+
# def test_flash2
|
163
|
+
# browser.button(:value, 'Click Me').flash
|
164
|
+
# assert_raises( Watir::UnknownObjectException ) { browser.text_field( :name , 'g177').flash }
|
165
|
+
# end
|
166
|
+
|
167
|
+
def test_submitWithImage
|
168
|
+
assert( browser.button(:alt , "submit").exists? )
|
169
|
+
assert( browser.button(:alt , /sub/).exists? )
|
170
|
+
|
171
|
+
assert_false( browser.button(:alt , "missing").exists? )
|
172
|
+
assert_false( browser.button(:alt , /missing/).exists? )
|
173
|
+
|
174
|
+
#assert( browser.button(:src , "file:///#{$myDir}/html/images/button.jpg").exists? ) # this doesnt work for everybody
|
175
|
+
assert( browser.button(:src , /button/).exists? )
|
176
|
+
|
177
|
+
assert_false( browser.button(:src , "missing").exists? )
|
178
|
+
assert_false( browser.button(:src , /missing/).exists? )
|
179
|
+
assert_nothing_raised("raised an exception when it shouldnt have") { browser.button(:src , /button/).click }
|
180
|
+
|
181
|
+
assert( browser.text.include?("PASS") )
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
|
186
|
+
class TC_Forms4 < Test::Unit::TestCase
|
187
|
+
|
188
|
+
def setup
|
189
|
+
goto_page("forms4.html")
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_find_text_field_ignoring_form
|
193
|
+
assert_equal(browser.text_field(:name, 'name').value, 'apple') # should it raise a not-unique error instead?
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_correct_form_field_is_found_using_form_name
|
197
|
+
assert_equal(browser.form(:name, 'apple_form').text_field(:name, 'name').value, 'apple')
|
198
|
+
assert_equal(browser.form(:name, 'banana_form').text_field(:name, 'name').value, 'banana')
|
199
|
+
end
|
200
|
+
|
201
|
+
def test_correct_form_field_is_found_using_form_index
|
202
|
+
assert_equal(browser.form(:index, 1).text_field(:name, 'name').value, 'apple')
|
203
|
+
assert_equal(browser.form(:index, 2).text_field(:name, 'name').value, 'banana')
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_using_text_on_form
|
207
|
+
browser.form(:name, 'apple_form').text_field(:name, 'name').set('strudel')
|
208
|
+
assert_equal(browser.form(:index, 1).text_field(:name, 'name').value, 'strudel')
|
209
|
+
end
|
210
|
+
|
211
|
+
def test_submit
|
212
|
+
browser.form(:name, 'apple_form').submit
|
213
|
+
assert( browser.text.include?("PASS") )
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
class TC_Hidden_Fields2 < Test::Unit::TestCase
|
218
|
+
|
219
|
+
def setup
|
220
|
+
goto_page("forms3.html")
|
221
|
+
end
|
222
|
+
|
223
|
+
def test_hidden
|
224
|
+
|
225
|
+
# test using index
|
226
|
+
assert( browser.hidden(:index,1).exists? )
|
227
|
+
assert( browser.hidden(:index,2).exists? )
|
228
|
+
assert_false( browser.hidden(:index,3).exists? )
|
229
|
+
|
230
|
+
browser.hidden(:index,1).value = 44
|
231
|
+
browser.hidden(:index,2).value = 55
|
232
|
+
|
233
|
+
browser.button(:value , "Show Hidden").click
|
234
|
+
|
235
|
+
assert_equal("44" , browser.text_field(:name , "vis1").value )
|
236
|
+
assert_equal("55" , browser.text_field(:name , "vis2").value )
|
237
|
+
|
238
|
+
# test using name and ID
|
239
|
+
assert( browser.hidden(:name ,"hid1").exists? )
|
240
|
+
assert( browser.hidden(:id,"hidden_1").exists? )
|
241
|
+
assert_false( browser.hidden(:name,"hidden_44").exists? )
|
242
|
+
assert_false( browser.hidden(:id,"hidden_55").exists? )
|
243
|
+
|
244
|
+
browser.hidden(:name ,"hid1").value = 444
|
245
|
+
browser.hidden(:id,"hidden_1").value = 555
|
246
|
+
|
247
|
+
browser.button(:value , "Show Hidden").click
|
248
|
+
|
249
|
+
assert_equal("444" , browser.text_field(:name , "vis1").value )
|
250
|
+
assert_equal("555" , browser.text_field(:name ,"vis2").value )
|
251
|
+
|
252
|
+
# test the over-ridden append method
|
253
|
+
browser.hidden(:name ,"hid1").append("a")
|
254
|
+
browser.button(:value , "Show Hidden").click
|
255
|
+
assert_equal("444a" , browser.text_field(:name , "vis1").value )
|
256
|
+
assert_equal("555" , browser.text_field(:name ,"vis2").value )
|
257
|
+
|
258
|
+
# test the over-ridden clear method
|
259
|
+
browser.hidden(:name ,"hid1").clear
|
260
|
+
browser.button(:value , "Show Hidden").click
|
261
|
+
assert_equal("" , browser.text_field(:name , "vis1").value )
|
262
|
+
assert_equal("555" , browser.text_field(:name ,"vis2").value )
|
263
|
+
|
264
|
+
# test using a form
|
265
|
+
assert( browser.form(:name , "has_a_hidden").hidden(:name ,"hid1").exists? )
|
266
|
+
assert( browser.form(:name , "has_a_hidden").hidden(:id,"hidden_1").exists? )
|
267
|
+
assert_false( browser.form(:name , "has_a_hidden").hidden(:name,"hidden_44").exists? )
|
268
|
+
assert_false( browser.form(:name , "has_a_hidden").hidden(:id,"hidden_55").exists? )
|
269
|
+
|
270
|
+
browser.form(:name , "has_a_hidden").hidden(:name ,"hid1").value = 222
|
271
|
+
browser.form(:name , "has_a_hidden").hidden(:id,"hidden_1").value = 333
|
272
|
+
|
273
|
+
browser.button(:value , "Show Hidden").click
|
274
|
+
|
275
|
+
assert_equal("222" , browser.text_field(:name , "vis1").value )
|
276
|
+
assert_equal("333" , browser.text_field(:name ,"vis2").value )
|
277
|
+
|
278
|
+
# iterators
|
279
|
+
## assert_equal(2, browser.hiddens.length)
|
280
|
+
## count =1
|
281
|
+
## browser.hiddens.each do |h|
|
282
|
+
## case count
|
283
|
+
## when 1
|
284
|
+
## assert_equal( "", h.id)
|
285
|
+
## assert_equal( "hid1", h.name)
|
286
|
+
## when 2
|
287
|
+
## assert_equal( "", h.name)
|
288
|
+
## assert_equal( "hidden_1", h.id)
|
289
|
+
## end
|
290
|
+
## count+=1
|
291
|
+
## end
|
292
|
+
#
|
293
|
+
## assert_equal("hid1" , browser.hiddens[1].name )
|
294
|
+
## assert_equal("hidden_1" , browser.hiddens[2].id )
|
295
|
+
end
|
296
|
+
end
|