firewatir 1.6.5 → 1.6.6.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +461 -0
- data/LICENSE +31 -31
- data/README.rdoc +112 -0
- data/VERSION +1 -0
- data/lib/firewatir.rb +41 -40
- data/lib/firewatir/container.rb +491 -491
- data/lib/firewatir/document.rb +239 -239
- data/lib/firewatir/element.rb +1364 -1364
- data/lib/firewatir/element_collections.rb +314 -314
- data/lib/firewatir/elements/button.rb +15 -15
- data/lib/firewatir/elements/file_field.rb +29 -29
- data/lib/firewatir/elements/form.rb +40 -40
- data/lib/firewatir/elements/frame.rb +55 -55
- data/lib/firewatir/elements/hidden.rb +56 -56
- data/lib/firewatir/elements/image.rb +139 -139
- data/lib/firewatir/elements/input_element.rb +44 -44
- data/lib/firewatir/elements/link.rb +76 -76
- data/lib/firewatir/elements/non_control_element.rb +53 -53
- data/lib/firewatir/elements/non_control_elements.rb +108 -108
- data/lib/firewatir/elements/not_used.rb +278 -278
- data/lib/firewatir/elements/option.rb +130 -130
- data/lib/firewatir/elements/radio_check_common.rb +163 -163
- data/lib/firewatir/elements/select_list.rb +188 -188
- data/lib/firewatir/elements/table.rb +218 -218
- data/lib/firewatir/elements/table_cell.rb +54 -54
- data/lib/firewatir/elements/table_row.rb +100 -100
- data/lib/firewatir/elements/text_field.rb +218 -218
- data/lib/firewatir/exceptions.rb +10 -10
- data/lib/firewatir/firefox.rb +984 -1040
- data/lib/firewatir/jssh_socket.rb +100 -100
- data/lib/firewatir/winClicker.rb +122 -122
- data/lib/firewatir/x11.rb +192 -192
- data/rakefile.rb +15 -0
- data/unittests/attach_to_new_window_test.rb +49 -49
- data/unittests/bug_fixes_test.rb +195 -195
- data/unittests/buttons_xpath_test.rb +88 -88
- data/unittests/checkbox_test.rb +158 -158
- data/unittests/checkbox_xpath_test.rb +107 -107
- data/unittests/div_test.rb +275 -275
- data/unittests/ff_test.rb +47 -0
- data/unittests/filefield_test.rb +49 -49
- data/unittests/filefield_xpath_test.rb +35 -35
- data/unittests/form_test.rb +296 -296
- data/unittests/frame_test.rb +159 -159
- data/unittests/hidden_test.rb +85 -85
- data/unittests/hidden_xpath_test.rb +72 -72
- data/unittests/html/JavascriptClick.html +42 -42
- data/unittests/html/blankpage.html +11 -11
- data/unittests/html/buttons1.html +61 -61
- data/unittests/html/checkboxes1.html +70 -70
- data/unittests/html/complex_table.html +36 -36
- data/unittests/html/cssTest.html +42 -42
- data/unittests/html/div.html +72 -72
- data/unittests/html/div_xml.html +20 -20
- data/unittests/html/fileupload.html +45 -45
- data/unittests/html/formTest1.html +38 -38
- data/unittests/html/forms2.html +45 -45
- data/unittests/html/forms3.html +132 -132
- data/unittests/html/forms4.html +27 -27
- data/unittests/html/frame_buttons.html +3 -3
- data/unittests/html/frame_links.html +3 -3
- data/unittests/html/frame_multi.html +4 -4
- data/unittests/html/iframeTest.html +14 -14
- data/unittests/html/iframeTest1.html +13 -13
- data/unittests/html/iframeTest2.html +5 -5
- data/unittests/html/images1.html +66 -66
- data/unittests/html/javascriptevents.html +35 -35
- data/unittests/html/link_pass.html +10 -10
- data/unittests/html/links1.html +42 -42
- data/unittests/html/links2.html +10 -10
- data/unittests/html/modal_dialog.html +8 -8
- data/unittests/html/modal_dialog_launcher.html +11 -11
- data/unittests/html/nestedFrames.html +6 -6
- data/unittests/html/new_browser.html +17 -17
- data/unittests/html/new_browser_popup.html +7 -7
- data/unittests/html/pass.html +9 -9
- data/unittests/html/popups1.html +60 -60
- data/unittests/html/pre.html +27 -27
- data/unittests/html/radioButtons1.html +70 -70
- 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/select_tealeaf.html +54 -54
- data/unittests/html/selectboxes1.html +55 -55
- data/unittests/html/simple_table.html +26 -26
- data/unittests/html/simple_table_buttons.html +104 -104
- data/unittests/html/simple_table_columns.html +74 -74
- data/unittests/html/table1.html +165 -165
- data/unittests/html/tableCell_using_xpath.html +19 -19
- data/unittests/html/textarea.html +30 -30
- data/unittests/html/textfields1.html +62 -62
- data/unittests/html/textsearch.html +44 -44
- data/unittests/images_test.rb +198 -198
- data/unittests/images_xpath_test.rb +118 -118
- data/unittests/javascript_test.rb +75 -75
- data/unittests/links_test.rb +231 -231
- data/unittests/links_xpath_test.rb +79 -79
- data/unittests/mozilla_all_tests.rb +7 -7
- data/unittests/pre_test.rb +75 -75
- data/unittests/radios_test.rb +166 -166
- 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 -29
- data/unittests/table_test.rb +385 -385
- data/unittests/table_xpath_test.rb +185 -185
- data/unittests/textfields_test.rb +234 -234
- data/unittests/textfields_xpath_test.rb +113 -113
- metadata +51 -19
- data/lib/firewatir/version.rb +0 -5
@@ -1,185 +1,185 @@
|
|
1
|
-
# feature tests for Tables
|
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_Tables_XPath < Test::Unit::TestCase
|
8
|
-
|
9
|
-
|
10
|
-
def setup
|
11
|
-
goto_page("table1.html")
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_Table_Exists
|
15
|
-
assert_false(browser.table(:xpath , "//table[@id = 'missingTable']").exists?)
|
16
|
-
assert(browser.table(:xpath, "//table[@id = 't1']").exists?)
|
17
|
-
end
|
18
|
-
|
19
|
-
tag_method :test_element_by_xpath_class, :fails_on_ie
|
20
|
-
def test_element_by_xpath_class
|
21
|
-
element = browser.element_by_xpath("//table[@id = 't1']")
|
22
|
-
assert_class(element, 'Table')
|
23
|
-
# FIXME really bizarre: this one should be a Table, but
|
24
|
-
# Firefox.element_factory gets HTMLAnchorElement as input
|
25
|
-
# TODO: If element is not present, this should return null or raises exception
|
26
|
-
#element = browser.element_by_xpath("//table[@id = 'missingTable']")
|
27
|
-
#assert(element.instance_of?(Table),"element class should be #{Table}; got #{element.class}")
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_rows
|
31
|
-
assert_raises(UnknownObjectException ){ browser.table(:xpath, "//table[@id = 'missingTable']").row_count }
|
32
|
-
assert_raises(UnknownObjectException){ browser.table(:xpath, "//table[@bad_attribute = 99]").row_count }
|
33
|
-
|
34
|
-
assert_equal(5, browser.table(:xpath, "//table[@id = 't1']").row_count) # 4 rows and a header
|
35
|
-
assert_equal(5, browser.table(:xpath, "//table[@id = 't1']").rows.length)
|
36
|
-
|
37
|
-
# test the each iterator on rows - ie, go through each cell
|
38
|
-
row = browser.table(:xpath, "//table[@id = 't1']")[2]
|
39
|
-
count = 1
|
40
|
-
row.each do |cell|
|
41
|
-
if count == 1
|
42
|
-
assert_equal('Row 1 Col1', cell.to_s.strip)
|
43
|
-
elsif count==2
|
44
|
-
assert_equal('Row 1 Col2', cell.to_s.strip)
|
45
|
-
end
|
46
|
-
count += 1
|
47
|
-
end
|
48
|
-
assert_equal(2, count -1)
|
49
|
-
assert_equal(2, browser.table(:xpath, "//table[@id = 't1']")[2].column_count)
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_dynamic_tables
|
53
|
-
t = browser.table(:xpath, "//table[@id = 't1']")
|
54
|
-
assert_equal(5, t.row_count)
|
55
|
-
|
56
|
-
browser.button(:xpath, "//input[@value = 'add row']").click
|
57
|
-
assert_equal(6, t.row_count)
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_columns
|
61
|
-
assert_raises(UnknownObjectException ){ browser.table(:xpath, "//table[@id = 'missingTable']").column_count }
|
62
|
-
assert_equal(1, browser.table(:xpath, "//table[@id = 't1']").column_count) # row one has 1 cell with a colspan of 2
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_to_a
|
66
|
-
table1Expected = [["Table 2"], ["Row 1 Col1" , "Row 1 Col2"] ,[ "Row 2 Col1" , "Row 2 Col2"],[ "Row 3 Col1" , "Row 3 Col2"],[ "Row 4 Col1" , "Row 4 Col2"] ]
|
67
|
-
assert_equal(table1Expected, browser.table(:xpath, "//table[@id = 't1']").to_a )
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_links_and_images_in_table
|
71
|
-
table = browser.table(:xpath, "//table[@id = 'pic_table']")
|
72
|
-
image = table[1][2].image(:index,1)
|
73
|
-
assert_equal("106", image.width)
|
74
|
-
|
75
|
-
link = table[2][2].link(:index,1)
|
76
|
-
assert_equal("Google", link.innerText)
|
77
|
-
end
|
78
|
-
|
79
|
-
#def test_cell_directly
|
80
|
-
# assert( browser.cell(:id, 'cell1').exists? )
|
81
|
-
# assert_false( browser.cell(:id, 'no_exist').exists? )
|
82
|
-
# assert_equal( "Row 1 Col1", browser.cell(:id, 'cell1').to_s.strip )
|
83
|
-
#
|
84
|
-
# # not really cell directly, but just to show another way of geting the cell
|
85
|
-
# assert_equal( "Row 1 Col1", browser.table(:index,1)[1][1].to_s.strip )
|
86
|
-
#end
|
87
|
-
|
88
|
-
#def test_row_directly
|
89
|
-
# assert( browser.row(:id, 'row1').exists? )
|
90
|
-
# assert_false( browser.row(:id, 'no_exist').exists? )
|
91
|
-
#
|
92
|
-
# assert_equal('Row 2 Col1' , browser.row(:id, 'row1')[1].to_s.strip )
|
93
|
-
#end
|
94
|
-
|
95
|
-
def test_row_iterator
|
96
|
-
t = browser.table(:xpath, "//table[@id = 't1']")
|
97
|
-
count = 1
|
98
|
-
t.each do |row|
|
99
|
-
if count == 1
|
100
|
-
assert("Table 2", row[1].text)
|
101
|
-
elsif count == 2
|
102
|
-
assert("Row 1 Col1", row[1].text)
|
103
|
-
assert("Row 1 Col2", row[2].text)
|
104
|
-
elsif count == 3
|
105
|
-
assert("Row 2 Col1", row[1].text)
|
106
|
-
assert("Row 2 Col2", row[2].text)
|
107
|
-
elsif count == 4
|
108
|
-
assert("Row 3 Col1", row[1].text)
|
109
|
-
assert("Row 4 Col2", row[2].text)
|
110
|
-
elsif count == 5
|
111
|
-
assert("Row 4 Col1", row[1].text)
|
112
|
-
assert("Row 4 Col2", row[2].text)
|
113
|
-
end
|
114
|
-
count += 1
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_row_collection
|
119
|
-
t = browser.table(:xpath, "//table[@id = 't1']")
|
120
|
-
count = 1
|
121
|
-
t.rows.each do |row|
|
122
|
-
if count == 1
|
123
|
-
assert("Table 2", row[1].text)
|
124
|
-
elsif count == 2
|
125
|
-
assert("Row 1 Col1", row[1].text)
|
126
|
-
assert("Row 1 Col2", row[2].text)
|
127
|
-
elsif count == 3
|
128
|
-
assert("Row 2 Col1", row[1].text)
|
129
|
-
assert("Row 2 Col2", row[2].text)
|
130
|
-
elsif count == 4
|
131
|
-
assert("Row 3 Col1", row[1].text)
|
132
|
-
assert("Row 4 Col2", row[2].text)
|
133
|
-
elsif count == 5
|
134
|
-
assert("Row 4 Col1", row[1].text)
|
135
|
-
assert("Row 4 Col2", row[2].text)
|
136
|
-
end
|
137
|
-
count += 1
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
#def test_table_body
|
142
|
-
# assert_equal( 1, browser.table(:index,1).bodies.length )
|
143
|
-
# assert_equal( 3, browser.table(:id, 'body_test' ).bodies.length )
|
144
|
-
#
|
145
|
-
# count = 1
|
146
|
-
# browser.table(:id, 'body_test').bodies.each do |n|
|
147
|
-
#
|
148
|
-
# # do something better here!
|
149
|
-
# # n.flash # this line commented out to speed up the test
|
150
|
-
#
|
151
|
-
# case count
|
152
|
-
# when 1
|
153
|
-
# compare_text = "This text is in the FRST TBODY."
|
154
|
-
# when 2
|
155
|
-
# compare_text = "This text is in the SECOND TBODY."
|
156
|
-
# when 3
|
157
|
-
# compare_text = "This text is in the THIRD TBODY."
|
158
|
-
# end
|
159
|
-
#
|
160
|
-
# assert_equal(compare_text, n[1][1].to_s.strip ) # this is the 1st cell of the first row of this particular body
|
161
|
-
#
|
162
|
-
# count += 1
|
163
|
-
# end
|
164
|
-
# assert_equal( count - 1, browser.table(:id, 'body_test').bodies.length )
|
165
|
-
#
|
166
|
-
# assert_equal( "This text is in the THIRD TBODY." ,browser.table(:id, 'body_test' ).body(:index,3)[1][1].to_s.strip )
|
167
|
-
#
|
168
|
-
# # iterate through all the rows in a table body
|
169
|
-
# count = 1
|
170
|
-
# browser.table(:id, 'body_test').body(:index, 2).each do | row |
|
171
|
-
# # row.flash # this line commented out, to speed up the tests
|
172
|
-
# if count == 1
|
173
|
-
# assert_equal('This text is in the SECOND TBODY.', row[1].text.strip )
|
174
|
-
# elsif count == 1 # BUG: Huh?
|
175
|
-
# assert_equal('This text is also in the SECOND TBODY.', row[1].text.strip )
|
176
|
-
# end
|
177
|
-
# count+=1
|
178
|
-
# end
|
179
|
-
# end
|
180
|
-
|
181
|
-
def test_table_container
|
182
|
-
assert_nothing_raised { browser.table(:id, 't1').html }
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
1
|
+
# feature tests for Tables
|
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_Tables_XPath < Test::Unit::TestCase
|
8
|
+
|
9
|
+
|
10
|
+
def setup
|
11
|
+
goto_page("table1.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_Table_Exists
|
15
|
+
assert_false(browser.table(:xpath , "//table[@id = 'missingTable']").exists?)
|
16
|
+
assert(browser.table(:xpath, "//table[@id = 't1']").exists?)
|
17
|
+
end
|
18
|
+
|
19
|
+
tag_method :test_element_by_xpath_class, :fails_on_ie
|
20
|
+
def test_element_by_xpath_class
|
21
|
+
element = browser.element_by_xpath("//table[@id = 't1']")
|
22
|
+
assert_class(element, 'Table')
|
23
|
+
# FIXME really bizarre: this one should be a Table, but
|
24
|
+
# Firefox.element_factory gets HTMLAnchorElement as input
|
25
|
+
# TODO: If element is not present, this should return null or raises exception
|
26
|
+
#element = browser.element_by_xpath("//table[@id = 'missingTable']")
|
27
|
+
#assert(element.instance_of?(Table),"element class should be #{Table}; got #{element.class}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_rows
|
31
|
+
assert_raises(UnknownObjectException ){ browser.table(:xpath, "//table[@id = 'missingTable']").row_count }
|
32
|
+
assert_raises(UnknownObjectException){ browser.table(:xpath, "//table[@bad_attribute = 99]").row_count }
|
33
|
+
|
34
|
+
assert_equal(5, browser.table(:xpath, "//table[@id = 't1']").row_count) # 4 rows and a header
|
35
|
+
assert_equal(5, browser.table(:xpath, "//table[@id = 't1']").rows.length)
|
36
|
+
|
37
|
+
# test the each iterator on rows - ie, go through each cell
|
38
|
+
row = browser.table(:xpath, "//table[@id = 't1']")[2]
|
39
|
+
count = 1
|
40
|
+
row.each do |cell|
|
41
|
+
if count == 1
|
42
|
+
assert_equal('Row 1 Col1', cell.to_s.strip)
|
43
|
+
elsif count==2
|
44
|
+
assert_equal('Row 1 Col2', cell.to_s.strip)
|
45
|
+
end
|
46
|
+
count += 1
|
47
|
+
end
|
48
|
+
assert_equal(2, count -1)
|
49
|
+
assert_equal(2, browser.table(:xpath, "//table[@id = 't1']")[2].column_count)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_dynamic_tables
|
53
|
+
t = browser.table(:xpath, "//table[@id = 't1']")
|
54
|
+
assert_equal(5, t.row_count)
|
55
|
+
|
56
|
+
browser.button(:xpath, "//input[@value = 'add row']").click
|
57
|
+
assert_equal(6, t.row_count)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_columns
|
61
|
+
assert_raises(UnknownObjectException ){ browser.table(:xpath, "//table[@id = 'missingTable']").column_count }
|
62
|
+
assert_equal(1, browser.table(:xpath, "//table[@id = 't1']").column_count) # row one has 1 cell with a colspan of 2
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_to_a
|
66
|
+
table1Expected = [["Table 2"], ["Row 1 Col1" , "Row 1 Col2"] ,[ "Row 2 Col1" , "Row 2 Col2"],[ "Row 3 Col1" , "Row 3 Col2"],[ "Row 4 Col1" , "Row 4 Col2"] ]
|
67
|
+
assert_equal(table1Expected, browser.table(:xpath, "//table[@id = 't1']").to_a )
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_links_and_images_in_table
|
71
|
+
table = browser.table(:xpath, "//table[@id = 'pic_table']")
|
72
|
+
image = table[1][2].image(:index,1)
|
73
|
+
assert_equal("106", image.width)
|
74
|
+
|
75
|
+
link = table[2][2].link(:index,1)
|
76
|
+
assert_equal("Google", link.innerText)
|
77
|
+
end
|
78
|
+
|
79
|
+
#def test_cell_directly
|
80
|
+
# assert( browser.cell(:id, 'cell1').exists? )
|
81
|
+
# assert_false( browser.cell(:id, 'no_exist').exists? )
|
82
|
+
# assert_equal( "Row 1 Col1", browser.cell(:id, 'cell1').to_s.strip )
|
83
|
+
#
|
84
|
+
# # not really cell directly, but just to show another way of geting the cell
|
85
|
+
# assert_equal( "Row 1 Col1", browser.table(:index,1)[1][1].to_s.strip )
|
86
|
+
#end
|
87
|
+
|
88
|
+
#def test_row_directly
|
89
|
+
# assert( browser.row(:id, 'row1').exists? )
|
90
|
+
# assert_false( browser.row(:id, 'no_exist').exists? )
|
91
|
+
#
|
92
|
+
# assert_equal('Row 2 Col1' , browser.row(:id, 'row1')[1].to_s.strip )
|
93
|
+
#end
|
94
|
+
|
95
|
+
def test_row_iterator
|
96
|
+
t = browser.table(:xpath, "//table[@id = 't1']")
|
97
|
+
count = 1
|
98
|
+
t.each do |row|
|
99
|
+
if count == 1
|
100
|
+
assert("Table 2", row[1].text)
|
101
|
+
elsif count == 2
|
102
|
+
assert("Row 1 Col1", row[1].text)
|
103
|
+
assert("Row 1 Col2", row[2].text)
|
104
|
+
elsif count == 3
|
105
|
+
assert("Row 2 Col1", row[1].text)
|
106
|
+
assert("Row 2 Col2", row[2].text)
|
107
|
+
elsif count == 4
|
108
|
+
assert("Row 3 Col1", row[1].text)
|
109
|
+
assert("Row 4 Col2", row[2].text)
|
110
|
+
elsif count == 5
|
111
|
+
assert("Row 4 Col1", row[1].text)
|
112
|
+
assert("Row 4 Col2", row[2].text)
|
113
|
+
end
|
114
|
+
count += 1
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_row_collection
|
119
|
+
t = browser.table(:xpath, "//table[@id = 't1']")
|
120
|
+
count = 1
|
121
|
+
t.rows.each do |row|
|
122
|
+
if count == 1
|
123
|
+
assert("Table 2", row[1].text)
|
124
|
+
elsif count == 2
|
125
|
+
assert("Row 1 Col1", row[1].text)
|
126
|
+
assert("Row 1 Col2", row[2].text)
|
127
|
+
elsif count == 3
|
128
|
+
assert("Row 2 Col1", row[1].text)
|
129
|
+
assert("Row 2 Col2", row[2].text)
|
130
|
+
elsif count == 4
|
131
|
+
assert("Row 3 Col1", row[1].text)
|
132
|
+
assert("Row 4 Col2", row[2].text)
|
133
|
+
elsif count == 5
|
134
|
+
assert("Row 4 Col1", row[1].text)
|
135
|
+
assert("Row 4 Col2", row[2].text)
|
136
|
+
end
|
137
|
+
count += 1
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
#def test_table_body
|
142
|
+
# assert_equal( 1, browser.table(:index,1).bodies.length )
|
143
|
+
# assert_equal( 3, browser.table(:id, 'body_test' ).bodies.length )
|
144
|
+
#
|
145
|
+
# count = 1
|
146
|
+
# browser.table(:id, 'body_test').bodies.each do |n|
|
147
|
+
#
|
148
|
+
# # do something better here!
|
149
|
+
# # n.flash # this line commented out to speed up the test
|
150
|
+
#
|
151
|
+
# case count
|
152
|
+
# when 1
|
153
|
+
# compare_text = "This text is in the FRST TBODY."
|
154
|
+
# when 2
|
155
|
+
# compare_text = "This text is in the SECOND TBODY."
|
156
|
+
# when 3
|
157
|
+
# compare_text = "This text is in the THIRD TBODY."
|
158
|
+
# end
|
159
|
+
#
|
160
|
+
# assert_equal(compare_text, n[1][1].to_s.strip ) # this is the 1st cell of the first row of this particular body
|
161
|
+
#
|
162
|
+
# count += 1
|
163
|
+
# end
|
164
|
+
# assert_equal( count - 1, browser.table(:id, 'body_test').bodies.length )
|
165
|
+
#
|
166
|
+
# assert_equal( "This text is in the THIRD TBODY." ,browser.table(:id, 'body_test' ).body(:index,3)[1][1].to_s.strip )
|
167
|
+
#
|
168
|
+
# # iterate through all the rows in a table body
|
169
|
+
# count = 1
|
170
|
+
# browser.table(:id, 'body_test').body(:index, 2).each do | row |
|
171
|
+
# # row.flash # this line commented out, to speed up the tests
|
172
|
+
# if count == 1
|
173
|
+
# assert_equal('This text is in the SECOND TBODY.', row[1].text.strip )
|
174
|
+
# elsif count == 1 # BUG: Huh?
|
175
|
+
# assert_equal('This text is also in the SECOND TBODY.', row[1].text.strip )
|
176
|
+
# end
|
177
|
+
# count+=1
|
178
|
+
# end
|
179
|
+
# end
|
180
|
+
|
181
|
+
def test_table_container
|
182
|
+
assert_nothing_raised { browser.table(:id, 't1').html }
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
@@ -1,234 +1,234 @@
|
|
1
|
-
# feature tests for Text Fields & Labels
|
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_Fields < Test::Unit::TestCase
|
8
|
-
|
9
|
-
|
10
|
-
def setup
|
11
|
-
goto_page("textfields1.html")
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_text_field_exists
|
15
|
-
assert(browser.text_field(:name, "text1").exists?)
|
16
|
-
assert_false(browser.text_field(:name, "missing").exists?)
|
17
|
-
|
18
|
-
assert(browser.text_field(:id, "text2").exists?)
|
19
|
-
assert_false(browser.text_field(:id, "alsomissing").exists?)
|
20
|
-
|
21
|
-
# TODO: Need to find an alternative to this in Mozilla
|
22
|
-
#assert(browser.text_field(:beforeText, "This Text After").exists? )
|
23
|
-
#assert(browser.text_field(:afterText, "This Text Before").exists? )
|
24
|
-
|
25
|
-
#assert(browser.text_field(:beforeText, /after/i).exists? )
|
26
|
-
#assert(browser.text_field(:afterText, /before/i).exists? )
|
27
|
-
end
|
28
|
-
|
29
|
-
# Drag Contents to in not supported by Mozilla because onDragStart, onDragEnd etc are not
|
30
|
-
# supported in Mozilla
|
31
|
-
#def test_text_field_dragContentsTo
|
32
|
-
|
33
|
-
#browser.text_field(:name, "text1").dragContentsTo(:id, "text2")
|
34
|
-
#assert_equal(browser.text_field(:name, "text1").value, "")
|
35
|
-
#assert_equal(browser.text_field(:id, "text2").value, "goodbye allHello World")
|
36
|
-
#end
|
37
|
-
|
38
|
-
def test_text_field_verify_contains
|
39
|
-
assert(browser.text_field(:name, "text1").verify_contains("Hello World"))
|
40
|
-
assert(browser.text_field(:name, "text1").verify_contains(/Hello\sW/))
|
41
|
-
assert_false(browser.text_field(:name, "text1").verify_contains("Ruby"))
|
42
|
-
assert_false(browser.text_field(:name, "text1").verify_contains(/R/))
|
43
|
-
assert_raises(UnknownObjectException) { browser.text_field(:name, "NoName").verify_contains("No field to get a value of") }
|
44
|
-
|
45
|
-
assert(browser.text_field(:id, "text2").verify_contains("goodbye all") )
|
46
|
-
assert_raises(UnknownObjectException) { browser.text_field(:id, "noID").verify_contains("No field to get a value of") }
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_text_field_enabled
|
50
|
-
assert_false(browser.text_field(:name, "disabled").enabled? )
|
51
|
-
assert(browser.text_field(:name, "text1").enabled? )
|
52
|
-
assert(browser.text_field(:id, "text2").enabled? )
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_text_field_readonly
|
56
|
-
assert_false(browser.text_field(:name, "disabled").readonly? )
|
57
|
-
assert(browser.text_field(:name, "readOnly").readonly? )
|
58
|
-
assert(browser.text_field(:id, "readOnly2").readonly? )
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_text_field_get_contents
|
62
|
-
assert_raises(UnknownObjectException) { browser.text_field(:name, "missing_field").append("Some Text") }
|
63
|
-
assert_equal("Hello World", browser.text_field(:name, "text1").value)
|
64
|
-
end
|
65
|
-
|
66
|
-
tag_method :test_text_field_to_s, :fails_on_ie
|
67
|
-
def test_text_field_to_s
|
68
|
-
expected = [
|
69
|
-
"name: text1",
|
70
|
-
"type: text",
|
71
|
-
"id: ",
|
72
|
-
"value: Hello World",
|
73
|
-
"disabled: false",
|
74
|
-
#"style: ",
|
75
|
-
#" for: ",
|
76
|
-
"read only: false",
|
77
|
-
"max length: 500",
|
78
|
-
"length: 0"
|
79
|
-
]
|
80
|
-
|
81
|
-
assert_equal(expected.sort, browser.text_field(:index, 1).to_s.split("\n").sort)
|
82
|
-
expected[0] = "name: "
|
83
|
-
expected[2] = "id: text2"
|
84
|
-
expected[3] = "value: goodbye all"
|
85
|
-
assert_equal(expected.sort, browser.text_field(:index, 2).to_s.split("\n").sort)
|
86
|
-
assert_raises(UnknownObjectException) { browser.text_field(:index, 999).to_s }
|
87
|
-
#puts browser.text_field(:name, "text1").to_s
|
88
|
-
#puts browser.text_field(:name, "readOnly").to_s
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_text_field_append
|
92
|
-
assert_raises(ObjectReadOnlyException) { browser.text_field(:id, "readOnly2").append("Some Text") }
|
93
|
-
assert_raises(ObjectDisabledException) { browser.text_field(:name, "disabled").append("Some Text") }
|
94
|
-
assert_raises(UnknownObjectException) { browser.text_field(:name, "missing_field").append("Some Text") }
|
95
|
-
|
96
|
-
browser.text_field(:name, "text1").append(" Some Text")
|
97
|
-
assert_equal("Hello World Some Text", browser.text_field(:name, "text1").value)
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_text_field_clear
|
101
|
-
browser.text_field(:name, "text1").clear
|
102
|
-
assert_equal("", browser.text_field(:name, "text1").value)
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_text_field_set
|
106
|
-
browser.text_field(:name, "text1").set("FireWatir Firefox Controller")
|
107
|
-
assert_equal("FireWatir Firefox Controller", browser.text_field(:name, "text1").value)
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_text_field_properties
|
111
|
-
assert_raises(UnknownObjectException) { browser.text_field(:index, 199).value }
|
112
|
-
assert_raises(UnknownObjectException) { browser.text_field(:index, 199).name }
|
113
|
-
assert_raises(UnknownObjectException) { browser.text_field(:index, 199).id }
|
114
|
-
assert_raises(UnknownObjectException) { browser.text_field(:index, 199).disabled }
|
115
|
-
assert_raises(UnknownObjectException) { browser.text_field(:index, 199).type }
|
116
|
-
|
117
|
-
assert_equal("Hello World" , browser.text_field(:index, 1).value)
|
118
|
-
assert_equal("text" , browser.text_field(:index, 1).type)
|
119
|
-
assert_equal("text1" , browser.text_field(:index, 1).name)
|
120
|
-
assert_equal("" , browser.text_field(:index, 1).id)
|
121
|
-
assert_equal(false , browser.text_field(:index, 1).disabled)
|
122
|
-
|
123
|
-
assert_equal("" , browser.text_field(:index, 2).name)
|
124
|
-
assert_equal("text2" , browser.text_field(:index, 2).id)
|
125
|
-
|
126
|
-
assert(browser.text_field(:index, 3).disabled)
|
127
|
-
|
128
|
-
assert_equal("This used to test :afterText", browser.text_field(:name, "aftertest").title)
|
129
|
-
assert_equal("", browser.text_field(:index, 1).title)
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_text_field_iterators
|
133
|
-
assert_equal(12, browser.text_fields.length)
|
134
|
-
|
135
|
-
# watir is 1 based, so this is the first text field
|
136
|
-
assert_equal("Hello World" , browser.text_fields[1].value)
|
137
|
-
assert_equal("text1" , browser.text_fields[1].name)
|
138
|
-
assert_equal("password" , browser.text_fields[browser.text_fields.length].type)
|
139
|
-
|
140
|
-
index = 1
|
141
|
-
browser.text_fields.each do |t|
|
142
|
-
assert_equal(browser.text_field(:index, index).value, t.value)
|
143
|
-
assert_equal(browser.text_field(:index, index).id, t.id)
|
144
|
-
assert_equal(browser.text_field(:index, index).name, t.name)
|
145
|
-
index += 1
|
146
|
-
end
|
147
|
-
assert_equal(index - 1, browser.text_fields.length)
|
148
|
-
end
|
149
|
-
|
150
|
-
tag_method :test_JS_Events, :fails_on_ie
|
151
|
-
def test_JS_Events
|
152
|
-
browser.text_field(:name, 'events_tester').set('p')
|
153
|
-
|
154
|
-
# the following line has an extra keypress at the begining, as we mimic the delete key being pressed
|
155
|
-
assert_equal( "keypresskeydownkeypresskeyup" , browser.text_field(:name , 'events_text').value.gsub("\n" , "") )
|
156
|
-
browser.button(:value , "Clear Events Box").click
|
157
|
-
browser.text_field(:name , 'events_tester').set('ab')
|
158
|
-
|
159
|
-
# the following line has an extra keypress at the begining, as we mimic the delete key being pressed
|
160
|
-
assert_equal( "keypresskeydownkeypresskeyupkeydownkeypresskeyup" , browser.text_field(:name , 'events_text').value.gsub("\n" , "") )
|
161
|
-
|
162
|
-
browser.text_field(:name, "events_text").set("angrez\nsingh")
|
163
|
-
browser.text_field(:name, "events_text").append("\n")
|
164
|
-
browser.text_field(:name, "events_text").append("singh") #\\nsupel")
|
165
|
-
end
|
166
|
-
|
167
|
-
def test_password
|
168
|
-
browser.text_field(:name , "password1").set("secret")
|
169
|
-
assert( 'secret' , browser.text_field(:name , "password1").value )
|
170
|
-
|
171
|
-
browser.text_field(:id , "password1").set("top_secret")
|
172
|
-
assert( 'top_secret' , browser.text_field(:id, "password1").value )
|
173
|
-
end
|
174
|
-
|
175
|
-
def test_labels_iterator
|
176
|
-
assert_equal(3, browser.labels.length)
|
177
|
-
assert_equal('Label For this Field' , browser.labels[1].innerText.strip )
|
178
|
-
assert_equal('Password With ID ( the text here is a label for it )' , browser.labels[3].innerText )
|
179
|
-
|
180
|
-
count=0
|
181
|
-
browser.labels.each do |l|
|
182
|
-
count +=1
|
183
|
-
end
|
184
|
-
assert_equal(count, browser.labels.length)
|
185
|
-
end
|
186
|
-
|
187
|
-
def test_label_properties
|
188
|
-
assert_raises(UnknownObjectException) { browser.label(:index,20).innerText }
|
189
|
-
assert_raises(UnknownObjectException) { browser.label(:index,20).for }
|
190
|
-
assert_raises(UnknownObjectException) { browser.label(:index,20).name }
|
191
|
-
assert_raises(UnknownObjectException) { browser.label(:index,20).type }
|
192
|
-
assert_raises(UnknownObjectException) { browser.label(:index,20).id }
|
193
|
-
|
194
|
-
assert_false(browser.label(:index,10).exists?)
|
195
|
-
assert_false(browser.label(:id,'missing').exists?)
|
196
|
-
assert(browser.label(:index,1).exists?)
|
197
|
-
|
198
|
-
assert_equal("", browser.label(:index,1).id)
|
199
|
-
assert_false( browser.label(:index,1).disabled?)
|
200
|
-
assert( browser.label(:index,1).enabled?)
|
201
|
-
|
202
|
-
assert_equal("label2", browser.label(:index,2).id )
|
203
|
-
|
204
|
-
assert_equal("Password With ID ( the text here is a label for it )" , browser.label(:index,3).innerText)
|
205
|
-
assert_equal("password1", browser.label(:index,3).for)
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
class TC_Labels_Display < Test::Unit::TestCase
|
210
|
-
|
211
|
-
include CaptureIOHelper
|
212
|
-
|
213
|
-
tag_method :test_showLabels, :fails_on_ie
|
214
|
-
def test_showLabels
|
215
|
-
goto_page("textfields1.html")
|
216
|
-
|
217
|
-
actual = capture_stdout { browser.showLabels }
|
218
|
-
assert_equal(<<END_OF_MESSAGE, actual)
|
219
|
-
There are 3 labels
|
220
|
-
label: name:
|
221
|
-
id:
|
222
|
-
for: text2
|
223
|
-
index: 1
|
224
|
-
label: name:
|
225
|
-
id: label2
|
226
|
-
for: readOnly2
|
227
|
-
index: 2
|
228
|
-
label: name:
|
229
|
-
id:
|
230
|
-
for: password1
|
231
|
-
index: 3
|
232
|
-
END_OF_MESSAGE
|
233
|
-
end
|
234
|
-
end
|
1
|
+
# feature tests for Text Fields & Labels
|
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_Fields < Test::Unit::TestCase
|
8
|
+
|
9
|
+
|
10
|
+
def setup
|
11
|
+
goto_page("textfields1.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_text_field_exists
|
15
|
+
assert(browser.text_field(:name, "text1").exists?)
|
16
|
+
assert_false(browser.text_field(:name, "missing").exists?)
|
17
|
+
|
18
|
+
assert(browser.text_field(:id, "text2").exists?)
|
19
|
+
assert_false(browser.text_field(:id, "alsomissing").exists?)
|
20
|
+
|
21
|
+
# TODO: Need to find an alternative to this in Mozilla
|
22
|
+
#assert(browser.text_field(:beforeText, "This Text After").exists? )
|
23
|
+
#assert(browser.text_field(:afterText, "This Text Before").exists? )
|
24
|
+
|
25
|
+
#assert(browser.text_field(:beforeText, /after/i).exists? )
|
26
|
+
#assert(browser.text_field(:afterText, /before/i).exists? )
|
27
|
+
end
|
28
|
+
|
29
|
+
# Drag Contents to in not supported by Mozilla because onDragStart, onDragEnd etc are not
|
30
|
+
# supported in Mozilla
|
31
|
+
#def test_text_field_dragContentsTo
|
32
|
+
|
33
|
+
#browser.text_field(:name, "text1").dragContentsTo(:id, "text2")
|
34
|
+
#assert_equal(browser.text_field(:name, "text1").value, "")
|
35
|
+
#assert_equal(browser.text_field(:id, "text2").value, "goodbye allHello World")
|
36
|
+
#end
|
37
|
+
|
38
|
+
def test_text_field_verify_contains
|
39
|
+
assert(browser.text_field(:name, "text1").verify_contains("Hello World"))
|
40
|
+
assert(browser.text_field(:name, "text1").verify_contains(/Hello\sW/))
|
41
|
+
assert_false(browser.text_field(:name, "text1").verify_contains("Ruby"))
|
42
|
+
assert_false(browser.text_field(:name, "text1").verify_contains(/R/))
|
43
|
+
assert_raises(UnknownObjectException) { browser.text_field(:name, "NoName").verify_contains("No field to get a value of") }
|
44
|
+
|
45
|
+
assert(browser.text_field(:id, "text2").verify_contains("goodbye all") )
|
46
|
+
assert_raises(UnknownObjectException) { browser.text_field(:id, "noID").verify_contains("No field to get a value of") }
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_text_field_enabled
|
50
|
+
assert_false(browser.text_field(:name, "disabled").enabled? )
|
51
|
+
assert(browser.text_field(:name, "text1").enabled? )
|
52
|
+
assert(browser.text_field(:id, "text2").enabled? )
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_text_field_readonly
|
56
|
+
assert_false(browser.text_field(:name, "disabled").readonly? )
|
57
|
+
assert(browser.text_field(:name, "readOnly").readonly? )
|
58
|
+
assert(browser.text_field(:id, "readOnly2").readonly? )
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_text_field_get_contents
|
62
|
+
assert_raises(UnknownObjectException) { browser.text_field(:name, "missing_field").append("Some Text") }
|
63
|
+
assert_equal("Hello World", browser.text_field(:name, "text1").value)
|
64
|
+
end
|
65
|
+
|
66
|
+
tag_method :test_text_field_to_s, :fails_on_ie
|
67
|
+
def test_text_field_to_s
|
68
|
+
expected = [
|
69
|
+
"name: text1",
|
70
|
+
"type: text",
|
71
|
+
"id: ",
|
72
|
+
"value: Hello World",
|
73
|
+
"disabled: false",
|
74
|
+
#"style: ",
|
75
|
+
#" for: ",
|
76
|
+
"read only: false",
|
77
|
+
"max length: 500",
|
78
|
+
"length: 0"
|
79
|
+
]
|
80
|
+
|
81
|
+
assert_equal(expected.sort, browser.text_field(:index, 1).to_s.split("\n").sort)
|
82
|
+
expected[0] = "name: "
|
83
|
+
expected[2] = "id: text2"
|
84
|
+
expected[3] = "value: goodbye all"
|
85
|
+
assert_equal(expected.sort, browser.text_field(:index, 2).to_s.split("\n").sort)
|
86
|
+
assert_raises(UnknownObjectException) { browser.text_field(:index, 999).to_s }
|
87
|
+
#puts browser.text_field(:name, "text1").to_s
|
88
|
+
#puts browser.text_field(:name, "readOnly").to_s
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_text_field_append
|
92
|
+
assert_raises(ObjectReadOnlyException) { browser.text_field(:id, "readOnly2").append("Some Text") }
|
93
|
+
assert_raises(ObjectDisabledException) { browser.text_field(:name, "disabled").append("Some Text") }
|
94
|
+
assert_raises(UnknownObjectException) { browser.text_field(:name, "missing_field").append("Some Text") }
|
95
|
+
|
96
|
+
browser.text_field(:name, "text1").append(" Some Text")
|
97
|
+
assert_equal("Hello World Some Text", browser.text_field(:name, "text1").value)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_text_field_clear
|
101
|
+
browser.text_field(:name, "text1").clear
|
102
|
+
assert_equal("", browser.text_field(:name, "text1").value)
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_text_field_set
|
106
|
+
browser.text_field(:name, "text1").set("FireWatir Firefox Controller")
|
107
|
+
assert_equal("FireWatir Firefox Controller", browser.text_field(:name, "text1").value)
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_text_field_properties
|
111
|
+
assert_raises(UnknownObjectException) { browser.text_field(:index, 199).value }
|
112
|
+
assert_raises(UnknownObjectException) { browser.text_field(:index, 199).name }
|
113
|
+
assert_raises(UnknownObjectException) { browser.text_field(:index, 199).id }
|
114
|
+
assert_raises(UnknownObjectException) { browser.text_field(:index, 199).disabled }
|
115
|
+
assert_raises(UnknownObjectException) { browser.text_field(:index, 199).type }
|
116
|
+
|
117
|
+
assert_equal("Hello World" , browser.text_field(:index, 1).value)
|
118
|
+
assert_equal("text" , browser.text_field(:index, 1).type)
|
119
|
+
assert_equal("text1" , browser.text_field(:index, 1).name)
|
120
|
+
assert_equal("" , browser.text_field(:index, 1).id)
|
121
|
+
assert_equal(false , browser.text_field(:index, 1).disabled)
|
122
|
+
|
123
|
+
assert_equal("" , browser.text_field(:index, 2).name)
|
124
|
+
assert_equal("text2" , browser.text_field(:index, 2).id)
|
125
|
+
|
126
|
+
assert(browser.text_field(:index, 3).disabled)
|
127
|
+
|
128
|
+
assert_equal("This used to test :afterText", browser.text_field(:name, "aftertest").title)
|
129
|
+
assert_equal("", browser.text_field(:index, 1).title)
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_text_field_iterators
|
133
|
+
assert_equal(12, browser.text_fields.length)
|
134
|
+
|
135
|
+
# watir is 1 based, so this is the first text field
|
136
|
+
assert_equal("Hello World" , browser.text_fields[1].value)
|
137
|
+
assert_equal("text1" , browser.text_fields[1].name)
|
138
|
+
assert_equal("password" , browser.text_fields[browser.text_fields.length].type)
|
139
|
+
|
140
|
+
index = 1
|
141
|
+
browser.text_fields.each do |t|
|
142
|
+
assert_equal(browser.text_field(:index, index).value, t.value)
|
143
|
+
assert_equal(browser.text_field(:index, index).id, t.id)
|
144
|
+
assert_equal(browser.text_field(:index, index).name, t.name)
|
145
|
+
index += 1
|
146
|
+
end
|
147
|
+
assert_equal(index - 1, browser.text_fields.length)
|
148
|
+
end
|
149
|
+
|
150
|
+
tag_method :test_JS_Events, :fails_on_ie
|
151
|
+
def test_JS_Events
|
152
|
+
browser.text_field(:name, 'events_tester').set('p')
|
153
|
+
|
154
|
+
# the following line has an extra keypress at the begining, as we mimic the delete key being pressed
|
155
|
+
assert_equal( "keypresskeydownkeypresskeyup" , browser.text_field(:name , 'events_text').value.gsub("\n" , "") )
|
156
|
+
browser.button(:value , "Clear Events Box").click
|
157
|
+
browser.text_field(:name , 'events_tester').set('ab')
|
158
|
+
|
159
|
+
# the following line has an extra keypress at the begining, as we mimic the delete key being pressed
|
160
|
+
assert_equal( "keypresskeydownkeypresskeyupkeydownkeypresskeyup" , browser.text_field(:name , 'events_text').value.gsub("\n" , "") )
|
161
|
+
|
162
|
+
browser.text_field(:name, "events_text").set("angrez\nsingh")
|
163
|
+
browser.text_field(:name, "events_text").append("\n")
|
164
|
+
browser.text_field(:name, "events_text").append("singh") #\\nsupel")
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_password
|
168
|
+
browser.text_field(:name , "password1").set("secret")
|
169
|
+
assert( 'secret' , browser.text_field(:name , "password1").value )
|
170
|
+
|
171
|
+
browser.text_field(:id , "password1").set("top_secret")
|
172
|
+
assert( 'top_secret' , browser.text_field(:id, "password1").value )
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_labels_iterator
|
176
|
+
assert_equal(3, browser.labels.length)
|
177
|
+
assert_equal('Label For this Field' , browser.labels[1].innerText.strip )
|
178
|
+
assert_equal('Password With ID ( the text here is a label for it )' , browser.labels[3].innerText )
|
179
|
+
|
180
|
+
count=0
|
181
|
+
browser.labels.each do |l|
|
182
|
+
count +=1
|
183
|
+
end
|
184
|
+
assert_equal(count, browser.labels.length)
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_label_properties
|
188
|
+
assert_raises(UnknownObjectException) { browser.label(:index,20).innerText }
|
189
|
+
assert_raises(UnknownObjectException) { browser.label(:index,20).for }
|
190
|
+
assert_raises(UnknownObjectException) { browser.label(:index,20).name }
|
191
|
+
assert_raises(UnknownObjectException) { browser.label(:index,20).type }
|
192
|
+
assert_raises(UnknownObjectException) { browser.label(:index,20).id }
|
193
|
+
|
194
|
+
assert_false(browser.label(:index,10).exists?)
|
195
|
+
assert_false(browser.label(:id,'missing').exists?)
|
196
|
+
assert(browser.label(:index,1).exists?)
|
197
|
+
|
198
|
+
assert_equal("", browser.label(:index,1).id)
|
199
|
+
assert_false( browser.label(:index,1).disabled?)
|
200
|
+
assert( browser.label(:index,1).enabled?)
|
201
|
+
|
202
|
+
assert_equal("label2", browser.label(:index,2).id )
|
203
|
+
|
204
|
+
assert_equal("Password With ID ( the text here is a label for it )" , browser.label(:index,3).innerText)
|
205
|
+
assert_equal("password1", browser.label(:index,3).for)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
class TC_Labels_Display < Test::Unit::TestCase
|
210
|
+
|
211
|
+
include CaptureIOHelper
|
212
|
+
|
213
|
+
tag_method :test_showLabels, :fails_on_ie
|
214
|
+
def test_showLabels
|
215
|
+
goto_page("textfields1.html")
|
216
|
+
|
217
|
+
actual = capture_stdout { browser.showLabels }
|
218
|
+
assert_equal(<<END_OF_MESSAGE, actual)
|
219
|
+
There are 3 labels
|
220
|
+
label: name:
|
221
|
+
id:
|
222
|
+
for: text2
|
223
|
+
index: 1
|
224
|
+
label: name:
|
225
|
+
id: label2
|
226
|
+
for: readOnly2
|
227
|
+
index: 2
|
228
|
+
label: name:
|
229
|
+
id:
|
230
|
+
for: password1
|
231
|
+
index: 3
|
232
|
+
END_OF_MESSAGE
|
233
|
+
end
|
234
|
+
end
|