watir 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/readme.rb +211 -0
- data/unittests/WindowLogonExample.rb +30 -0
- data/unittests/WindowLogonExtra.rb +7 -0
- data/unittests/all_tests.rb +10 -0
- data/unittests/all_tests_concurrent.rb +57 -0
- data/unittests/attachToExistingWindow_test.rb +40 -0
- data/unittests/buttons_test.rb +131 -0
- data/unittests/checkbox_test.rb +149 -0
- data/unittests/core_tests.rb +9 -0
- data/unittests/css_test.rb +60 -0
- data/unittests/div_test.rb +179 -0
- data/unittests/errorchecker_test.rb +29 -0
- data/unittests/filefield_test.rb +35 -0
- data/unittests/form_test.rb +279 -0
- data/unittests/frame_test.rb +141 -0
- data/unittests/html/blankpage.html +12 -0
- data/unittests/html/buttons1.html +40 -0
- data/unittests/html/checkboxes1.html +69 -0
- data/unittests/html/complex_table.html +36 -0
- data/unittests/html/cssTest.html +42 -0
- data/unittests/html/div.html +105 -0
- data/unittests/html/fileupload.html +45 -0
- data/unittests/html/formTest1.html +39 -0
- data/unittests/html/forms2.html +45 -0
- data/unittests/html/forms3.html +132 -0
- data/unittests/html/forms4.html +27 -0
- data/unittests/html/frame_buttons.html +4 -0
- data/unittests/html/frame_links.html +4 -0
- data/unittests/html/frame_multi.html +5 -0
- data/unittests/html/iframeTest.html +13 -0
- data/unittests/html/iframeTest1.html +7 -0
- data/unittests/html/iframeTest2.html +6 -0
- data/unittests/html/images/1.gif +0 -0
- data/unittests/html/images/2.GIF +0 -0
- data/unittests/html/images/3.GIF +0 -0
- data/unittests/html/images/button.jpg +0 -0
- data/unittests/html/images/circle.jpg +0 -0
- data/unittests/html/images/minus.GIF +0 -0
- data/unittests/html/images/originaltriangle.jpg +0 -0
- data/unittests/html/images/plus.gif +0 -0
- data/unittests/html/images/square.jpg +0 -0
- data/unittests/html/images/triangle.jpg +0 -0
- data/unittests/html/images1.html +52 -0
- data/unittests/html/javascriptevents.html +39 -0
- data/unittests/html/link_pass.html +11 -0
- data/unittests/html/links1.html +37 -0
- data/unittests/html/links2.html +11 -0
- data/unittests/html/nestedFrames.html +6 -0
- data/unittests/html/pass.html +10 -0
- data/unittests/html/popups1.html +60 -0
- data/unittests/html/radioButtons1.html +71 -0
- data/unittests/html/select_tealeaf.html +54 -0
- data/unittests/html/selectboxes1.html +55 -0
- data/unittests/html/simple_table.html +26 -0
- data/unittests/html/simple_table_buttons.html +104 -0
- data/unittests/html/simple_table_columns.html +76 -0
- data/unittests/html/table1.html +142 -0
- data/unittests/html/textarea.html +30 -0
- data/unittests/html/textfields1.html +87 -0
- data/unittests/html/textsearch.html +44 -0
- data/unittests/ie_mock.rb +93 -0
- data/unittests/ie_test.rb +50 -0
- data/unittests/images_test.rb +179 -0
- data/unittests/iostring.rb +30 -0
- data/unittests/iostring_test.rb +48 -0
- data/unittests/js_events_test.rb +77 -0
- data/unittests/jscriptExtraAlert.rb +6 -0
- data/unittests/jscriptExtraConfirmCancel.rb +7 -0
- data/unittests/jscriptExtraConfirmOk.rb +7 -0
- data/unittests/jscriptPushButton.rb +5 -0
- data/unittests/jscript_test.rb +57 -0
- data/unittests/links_test.rb +169 -0
- data/unittests/minmax_test.rb +31 -0
- data/unittests/navigate_test.rb +56 -0
- data/unittests/non_core_tests.rb +9 -0
- data/unittests/pagecontainstext_test.rb +49 -0
- data/unittests/popups_test.rb +44 -0
- data/unittests/radios_test.rb +164 -0
- data/unittests/screen_capture_test.rb +53 -0
- data/unittests/selectbox_test.rb +197 -0
- data/unittests/send_keys_test.rb +29 -0
- data/unittests/setup.rb +47 -0
- data/unittests/table_test.rb +306 -0
- data/unittests/textAreafields_test.rb +81 -0
- data/unittests/textfields_test.rb +239 -0
- data/watir.rb +3744 -0
- data/watir/AutoItX3.dll +0 -0
- data/watir/WindowHelper.rb +47 -0
- data/watir/camel_case.rb +37 -0
- data/watir/clickJSDialog.rb +19 -0
- data/watir/cookiemanager.rb +53 -0
- data/watir/exceptions.rb +60 -0
- data/watir/screen_capture.rb +115 -0
- data/watir/setFileDialog.rb +16 -0
- data/watir/testUnitAddons.rb +47 -0
- data/watir/watir_simple.rb +475 -0
- data/watir/winClicker.rb +505 -0
- metadata +152 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
# feature tests for IE#send_keys
|
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_Fields < Test::Unit::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def setup()
|
11
|
+
$ie.goto($htmlRoot + "textfields1.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_tabbing
|
15
|
+
$ie.text_field(:name, 'text1').focus
|
16
|
+
$ie.send_keys('{tab}')
|
17
|
+
$ie.send_keys('Scooby')
|
18
|
+
assert('Scooby', $ie.text_field(:name, 'beforetest').value)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_enter
|
22
|
+
$ie.text_field(:name, 'text1').focus
|
23
|
+
$ie.send_keys('{tab}{tab}{tab}{tab}')
|
24
|
+
$ie.send_keys('Dooby{enter}')
|
25
|
+
assert($ie.contains_text('PASS'))
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
data/unittests/setup.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
END {$ie.close if $ie} # close ie at completion of the tests
|
2
|
+
|
3
|
+
# libraries used by feature tests
|
4
|
+
require 'watir'
|
5
|
+
require 'test/unit'
|
6
|
+
require 'test/unit/ui/console/testrunner'
|
7
|
+
require 'watir/testUnitAddons'
|
8
|
+
|
9
|
+
topdir = File.join(File.dirname(__FILE__), '..')
|
10
|
+
Dir.chdir topdir do
|
11
|
+
$all_tests = Dir["unittests/*_test.rb"]
|
12
|
+
end
|
13
|
+
|
14
|
+
$non_core_tests =
|
15
|
+
['popups', # has problems when run in a suite (is ok when run alone);
|
16
|
+
# must be visible
|
17
|
+
# will be revised to use autoit
|
18
|
+
# takes 15 seconds to run
|
19
|
+
'images', # failing tests; also assumes working dir is unittests
|
20
|
+
'screen_capture', # is always visible; takes 25 secons
|
21
|
+
'filefield', # is always visible; takes 40 seconds
|
22
|
+
'jscript',
|
23
|
+
'js_events', # is always visible
|
24
|
+
'minmax', # becomes visible
|
25
|
+
'send_keys' # uses autoit
|
26
|
+
].collect {|x| "unittests/#{x}_test.rb"}
|
27
|
+
|
28
|
+
$core_tests = $all_tests - $non_core_tests
|
29
|
+
|
30
|
+
def start_ie_with_logger
|
31
|
+
$ie = Watir::IE.new()
|
32
|
+
# $ie.logger = Watir::WatirLogger.new( 'debug.txt', 4, 10000 )
|
33
|
+
$ie.set_fast_speed
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_local_dir
|
37
|
+
$myDir = File.expand_path(File.dirname(__FILE__))
|
38
|
+
$myDir.sub!( %r{/cygdrive/(\w)/}, '\1:/' ) # convert from cygwin to dos
|
39
|
+
# if you run the unit tests form a local file system use this line
|
40
|
+
$htmlRoot = "file://#{$myDir}/html/"
|
41
|
+
# if you run the unit tests from a web server use this line
|
42
|
+
# $htmlRoot = "http://localhost:8080/watir/html/"
|
43
|
+
end
|
44
|
+
|
45
|
+
start_ie_with_logger
|
46
|
+
set_local_dir
|
47
|
+
|
@@ -0,0 +1,306 @@
|
|
1
|
+
# feature tests for Tables
|
2
|
+
# revision: $Revision: 1.29 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_Tables < Test::Unit::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def setup
|
11
|
+
gotoTablePage
|
12
|
+
end
|
13
|
+
|
14
|
+
def gotoTablePage()
|
15
|
+
$ie.goto($htmlRoot + "table1.html")
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_Table_Exists
|
19
|
+
assert_false($ie.table(:id , 'missingTable').exists? )
|
20
|
+
assert_false($ie.table(:index, 33).exists? )
|
21
|
+
|
22
|
+
assert($ie.table(:id, 't1').exists? )
|
23
|
+
assert($ie.table(:id, /t/).exists? )
|
24
|
+
assert_false($ie.table(:id , /missing_table/).exists? )
|
25
|
+
|
26
|
+
|
27
|
+
assert($ie.table(:index, 1).exists? )
|
28
|
+
assert($ie.table(:index, 2).exists? )
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_rows
|
32
|
+
assert_raises( UnknownTableException ){ $ie.table(:id , 'missingTable').row_count }
|
33
|
+
assert_raises( UnknownTableException ){ $ie.table(:index , 66).row_count }
|
34
|
+
|
35
|
+
assert_equal( 2 , $ie.table(:index , 1).row_count)
|
36
|
+
assert_equal( 5 , $ie.table(:id, 't1').row_count) # 4 rows and a header
|
37
|
+
assert_equal( 5 , $ie.table(:index, 2).row_count) # same table as above, just accessed by index
|
38
|
+
|
39
|
+
# test the each iterator on rows - ie, go through each cell
|
40
|
+
row = $ie.table(:index, 2)[2]
|
41
|
+
count=1
|
42
|
+
row.each do |cell|
|
43
|
+
# cell.flash # this line commented out to speed up the test
|
44
|
+
if count == 1
|
45
|
+
assert_equal('Row 1 Col1' , cell.to_s.strip )
|
46
|
+
elsif count==2
|
47
|
+
assert_equal('Row 1 Col2' , cell.to_s.strip )
|
48
|
+
end
|
49
|
+
count+=1
|
50
|
+
end
|
51
|
+
assert_equal(2, count -1)
|
52
|
+
assert_equal(2, $ie.table(:index, 2)[2].column_count)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_dynamic_tables
|
56
|
+
t = $ie.table(:id, 't1')
|
57
|
+
assert_equal( 5, t.row_count)
|
58
|
+
|
59
|
+
$ie.button(:value , 'add row').click
|
60
|
+
assert_equal( 6, t.row_count)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_columns
|
64
|
+
|
65
|
+
assert_raises( UnknownTableException ){ $ie.table(:id , 'missingTable').column_count }
|
66
|
+
assert_raises( UnknownTableException ){ $ie.table(:index , 77).column_count }
|
67
|
+
assert_equal( 2 , $ie.table(:index , 1).column_count)
|
68
|
+
assert_equal( 1 , $ie.table(:id, 't1').column_count) # row one has 1 cell with a colspan of 2
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_to_a
|
72
|
+
table1Expected = [ ["Row 1 Col1" , "Row 1 Col2"] ,[ "Row 2 Col1" , "Row 2 Col2"] ]
|
73
|
+
assert_arrayEquals(table1Expected, $ie.table(:index , 1).to_a )
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_simple_table_access
|
77
|
+
$ie.goto($htmlRoot + "simple_table.html")
|
78
|
+
|
79
|
+
table = $ie.table(:index,1)
|
80
|
+
|
81
|
+
assert_equal("Row 3 Col1",table[3][1].text.strip)
|
82
|
+
assert_equal("Row 1 Col1",table[1][1].text.strip)
|
83
|
+
assert_equal("Row 3 Col2",table[3][2].text.strip)
|
84
|
+
assert_equal(2,table.column_count)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_simple_table_buttons
|
88
|
+
$ie.goto($htmlRoot + "simple_table_buttons.html")
|
89
|
+
|
90
|
+
table = $ie.table(:index,1)
|
91
|
+
|
92
|
+
table[1][1].button(:index,1).click
|
93
|
+
assert($ie.textField(:name,"confirmtext").verify_contains(/CLICK1/i))
|
94
|
+
table[2][1].button(:index,1).click
|
95
|
+
assert($ie.textField(:name,"confirmtext").verify_contains(/CLICK2/i))
|
96
|
+
|
97
|
+
table[1][1].button(:id,'b1').click
|
98
|
+
assert($ie.textField(:name,"confirmtext").verify_contains(/CLICK1/i))
|
99
|
+
|
100
|
+
assert_raises(UnknownObjectException ) { table[1][1].button(:id,'b_missing').click }
|
101
|
+
|
102
|
+
table[3][1].button(:index,2).click
|
103
|
+
assert($ie.textField(:name,"confirmtext").verify_contains(/TOO/i))
|
104
|
+
|
105
|
+
table[3][1].button(:value ,"Click too").click
|
106
|
+
assert($ie.textField(:name,"confirmtext").verify_contains(/TOO/i))
|
107
|
+
|
108
|
+
$ie.table(:index,1)[4][1].text_field(:index,1).set("123")
|
109
|
+
assert($ie.text_field(:index,2).verify_contains("123"))
|
110
|
+
|
111
|
+
# check when a cell contains 2 objects
|
112
|
+
|
113
|
+
# if there were 2 different html objects in the same cell, some weird things happened ( button caption could change for example)
|
114
|
+
assert_equal( 'Click ->' , $ie.table(:index,1)[5][1].text_field(:index,1).value )
|
115
|
+
$ie.table(:index,1)[5][1].text_field(:index,1).click
|
116
|
+
assert_equal( 'Click ->' , $ie.table(:index,1)[5][1].text_field(:index,1).value )
|
117
|
+
|
118
|
+
$ie.table(:index,1)[5][1].button(:index,1).click
|
119
|
+
assert_equal( '' , $ie.table(:index,1)[5][1].text_field(:index,1).value )
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_simple_table_gif
|
123
|
+
$ie.goto($htmlRoot + "simple_table_buttons.html")
|
124
|
+
|
125
|
+
table = $ie.table(:index,2)
|
126
|
+
|
127
|
+
assert_match( /1\.gif/ , table[1][1].image( :index,1).src )
|
128
|
+
assert_match( /2\.gif/ , table[1][2].image( :index ,1).src )
|
129
|
+
assert_match( /3\.gif/ , table[1][3].image( :index ,1).src )
|
130
|
+
|
131
|
+
assert_match( /1\.gif/ , table[3][1].image( :index ,1).src )
|
132
|
+
assert_match( /2\.gif/ , table[3][2].image( :index ,1).src )
|
133
|
+
assert_match( /3\.gif/ , table[3][3].image( :index ,1).src )
|
134
|
+
|
135
|
+
table = $ie.table(:index,3)
|
136
|
+
assert_match( /1\.gif/ , table[1][1].image( :index ,1).src )
|
137
|
+
assert_match( /2\.gif/ , table[1][1].image( :index ,2).src )
|
138
|
+
assert_match( /3\.gif/ , table[1][1].image( :index ,3).src )
|
139
|
+
|
140
|
+
assert_match( /1\.gif/ , table[3][1].image( :index ,1).src )
|
141
|
+
assert_match( /2\.gif/ , table[3][1].image( :index ,2).src )
|
142
|
+
assert_match( /3\.gif/ , table[3][1].image( :index ,3).src )
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_table_with_hidden_or_visible_rows
|
146
|
+
$ie.goto($htmlRoot + "simple_table_buttons.html")
|
147
|
+
t = $ie.table(:id , 'show_hide')
|
148
|
+
|
149
|
+
# expand the table
|
150
|
+
t.each do |r|
|
151
|
+
r[1].image(:src, /plus/).click if r[1].image(:src, /plus/).exists?
|
152
|
+
end
|
153
|
+
|
154
|
+
# shrink rows 1,2,3
|
155
|
+
count=1
|
156
|
+
t.each do |r|
|
157
|
+
r[1].image(:src, /minus/).click if r[1].image(:src, /minus/).exists? and (1..3) === count
|
158
|
+
count=2
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_links_and_images_in_table
|
163
|
+
table = $ie.table(:id, 'pic_table')
|
164
|
+
image = table[1][2].image(:index,1)
|
165
|
+
assert_equal("106", image.width)
|
166
|
+
|
167
|
+
link = table[1][4].link(:index,1)
|
168
|
+
assert_equal("Google", link.innerText)
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_table_from_element
|
172
|
+
$ie.goto($htmlRoot + "simple_table_buttons.html")
|
173
|
+
|
174
|
+
button = $ie.button(:id,"b1")
|
175
|
+
table = Table.create_from_element($ie,button)
|
176
|
+
|
177
|
+
table[2][1].button(:index,1).click
|
178
|
+
assert($ie.textField(:name,"confirmtext").verify_contains(/CLICK2/i))
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_complex_table_access
|
182
|
+
$ie.goto($htmlRoot + "complex_table.html")
|
183
|
+
|
184
|
+
table = $ie.table(:index,1)
|
185
|
+
|
186
|
+
assert_equal("subtable1 Row 1 Col1",table[1][1].table(:index,1)[1][1].text.strip)
|
187
|
+
assert_equal("subtable1 Row 1 Col2",table[1][1].table(:index,1)[1][2].text.strip)
|
188
|
+
assert_equal("subtable2 Row 1 Col2",table[2][1].table(:index,1)[1][2].text.strip)
|
189
|
+
assert_equal("subtable2 Row 1 Col1",table[2][1].table(:index,1)[1][1].text.strip)
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_cell_directly
|
193
|
+
|
194
|
+
assert( $ie.cell(:id, 'cell1').exists? )
|
195
|
+
assert_false( $ie.cell(:id, 'no_exist').exists? )
|
196
|
+
assert_equal( "Row 1 Col1", $ie.cell(:id, 'cell1').to_s.strip )
|
197
|
+
|
198
|
+
# not really cell directly, but just to show another way of geting the cell
|
199
|
+
assert_equal( "Row 1 Col1", $ie.table(:index,1)[1][1].to_s.strip )
|
200
|
+
end
|
201
|
+
|
202
|
+
def test_row_directly
|
203
|
+
assert( $ie.row(:id, 'row1').exists? )
|
204
|
+
assert_false( $ie.row(:id, 'no_exist').exists? )
|
205
|
+
|
206
|
+
assert_equal('Row 2 Col1' , $ie.row(:id, 'row1')[1].to_s.strip )
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_row_iterator
|
210
|
+
t = $ie.table(:index,1)
|
211
|
+
count =1
|
212
|
+
t.each do |row|
|
213
|
+
if count==1
|
214
|
+
assert( "Row 1 Col1" , row[1].text )
|
215
|
+
assert( "Row 1 Col2" , row[2].text )
|
216
|
+
elsif count==2
|
217
|
+
assert( "Row 2 Col1" , row[1].text )
|
218
|
+
assert( "Row 2 Col2" , row[2].text )
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
def test_table_body
|
224
|
+
assert_equal( 1, $ie.table(:index,1).bodies.length )
|
225
|
+
assert_equal( 3, $ie.table(:id, 'body_test' ).bodies.length )
|
226
|
+
|
227
|
+
count = 1
|
228
|
+
$ie.table(:id, 'body_test' ).bodies.each do |n|
|
229
|
+
|
230
|
+
# do something better here!
|
231
|
+
# n.flash # this line commented out to speed up the test
|
232
|
+
|
233
|
+
case count
|
234
|
+
when 1
|
235
|
+
compare_text = "This text is in the FRST TBODY."
|
236
|
+
when 2
|
237
|
+
compare_text = "This text is in the SECOND TBODY."
|
238
|
+
when 3
|
239
|
+
compare_text = "This text is in the THIRD TBODY."
|
240
|
+
end
|
241
|
+
|
242
|
+
assert_equal( compare_text , n[1][1].to_s.strip ) # this is the 1st cell of the first row of this particular body
|
243
|
+
|
244
|
+
count +=1
|
245
|
+
end
|
246
|
+
assert_equal( count-1, $ie.table(:id, 'body_test' ).bodies.length )
|
247
|
+
|
248
|
+
assert_equal( "This text is in the THIRD TBODY." ,$ie.table(:id, 'body_test' ).body(:index,3)[1][1].to_s.strip )
|
249
|
+
|
250
|
+
# iterate through all the rows in a table body
|
251
|
+
count = 1
|
252
|
+
$ie.table(:id, 'body_test' ).body(:index,2).each do | row |
|
253
|
+
# row.flash # this line commented out, to speed up the tests
|
254
|
+
if count == 1
|
255
|
+
assert_equal('This text is in the SECOND TBODY.' , row[1].text.strip )
|
256
|
+
elsif count == 1
|
257
|
+
assert_equal('This text is also in the SECOND TBODY.' , row[1].text.strip )
|
258
|
+
end
|
259
|
+
count+=1
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def test_get_columnvalues_single_column
|
264
|
+
$ie.goto($htmlRoot + "simple_table_columns.html")
|
265
|
+
assert_equal(["R1C1", "R2C1", "R3C1"], $ie.table(:index, 1).column_values(1))
|
266
|
+
end
|
267
|
+
|
268
|
+
def test_colspan
|
269
|
+
$ie.goto($htmlRoot + "simple_table_columns.html")
|
270
|
+
assert_equal(2, $ie.table(:index, 3)[2][1].colspan)
|
271
|
+
assert_equal(1, $ie.table(:index, 3)[1][1].colspan)
|
272
|
+
assert_equal(3, $ie.table(:index, 3)[4][1].colspan)
|
273
|
+
|
274
|
+
end
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
def test_get_columnvalues_multiple_column
|
280
|
+
$ie.goto($htmlRoot + "simple_table_columns.html")
|
281
|
+
assert_equal(["R1C1", "R2C1", "R3C1"], $ie.table(:index, 2).column_values(1))
|
282
|
+
assert_equal(["R1C3", "R2C3", "R3C3"], $ie.table(:index, 2).column_values(3))
|
283
|
+
end
|
284
|
+
|
285
|
+
def test_get_columnvalues_with_colspan
|
286
|
+
$ie.goto($htmlRoot + "simple_table_columns.html")
|
287
|
+
assert_equal(["R1C1", "R2C1", "R3C1", "R4C1", "R5C1", "R6C2"], $ie.table(:index, 3).column_values(1))
|
288
|
+
(2..4).each{|x|assert_raises(UnknownCellException){$ie.table(:index, 3).column_values(x)}}
|
289
|
+
end
|
290
|
+
|
291
|
+
def test_get_rowvalues_full_row
|
292
|
+
$ie.goto($htmlRoot + "simple_table_columns.html")
|
293
|
+
assert_equal(["R1C1", "R1C2", "R1C3"], $ie.table(:index, 3).row_values(1))
|
294
|
+
end
|
295
|
+
|
296
|
+
def test_get_rowvalues_with_colspan
|
297
|
+
$ie.goto($htmlRoot + "simple_table_columns.html")
|
298
|
+
assert_equal(["R2C1", "R2C2"], $ie.table(:index, 3).row_values(2))
|
299
|
+
end
|
300
|
+
|
301
|
+
def test_getrowvalues_with_rowspan
|
302
|
+
$ie.goto($htmlRoot + "simple_table_columns.html")
|
303
|
+
assert_equal(["R5C1", "R5C2", "R5C3"], $ie.table(:index, 3).row_values(5))
|
304
|
+
assert_equal(["R6C2", "R6C3"], $ie.table(:index, 3).row_values(6))
|
305
|
+
end
|
306
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# feature tests for TextArea Fields
|
2
|
+
# revision: $Revision: 1.10 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_TextArea < Test::Unit::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def gotoPage()
|
11
|
+
$ie.goto($htmlRoot + "textArea.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_textarea_field_exists
|
15
|
+
gotoPage()
|
16
|
+
#test for existance of 4 text area
|
17
|
+
assert($ie.text_field(:name,"txtMultiLine1").exists?)
|
18
|
+
assert($ie.text_field(:name,"txtMultiLine2").exists?)
|
19
|
+
assert($ie.text_field(:name,"txtMultiLine3").exists?)
|
20
|
+
assert($ie.text_field(:name,"txtReadOnly").exists?)
|
21
|
+
|
22
|
+
assert($ie.text_field(:id,"txtMultiLine1").exists?)
|
23
|
+
assert($ie.text_field(:id,"txtMultiLine2").exists?)
|
24
|
+
assert($ie.text_field(:id,"txtMultiLine3").exists?)
|
25
|
+
assert($ie.text_field(:id,"txtReadOnly").exists?)
|
26
|
+
#test for missing
|
27
|
+
assert_false($ie.text_field(:name, "missing").exists?)
|
28
|
+
assert_false($ie.text_field(:name,"txtMultiLine4").exists?)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_textarea_to_s
|
32
|
+
# bug reported by Zeljko Filipin
|
33
|
+
assert_nothing_raised() { $ie.text_field(:id,"txtMultiLine3").to_s }
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_textarea_field
|
37
|
+
gotoPage()
|
38
|
+
|
39
|
+
# test for read only method
|
40
|
+
assert_false($ie.text_field(:name, "txtMultiLine1").readonly? )
|
41
|
+
assert($ie.text_field(:name,"txtReadOnly").readonly?)
|
42
|
+
|
43
|
+
# test for enabled? method
|
44
|
+
assert_false($ie.text_field(:name, "txtDisabled").enabled? )
|
45
|
+
assert($ie.text_field(:id, "txtMultiLine1").enabled? )
|
46
|
+
|
47
|
+
|
48
|
+
t1 = $ie.text_field(:name, "txtMultiLine1")
|
49
|
+
assert(t1.verify_contains("Hello World") )
|
50
|
+
assert(t1.verify_contains(/el/) )
|
51
|
+
t2 = $ie.text_field(:name, "txtMultiLine2")
|
52
|
+
assert(t2.verify_contains(/IE/))
|
53
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.text_field(:name, "NoName").verify_contains("No field to get a value of") }
|
54
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.text_field(:id, "noID").verify_contains("No field to get a value of") }
|
55
|
+
|
56
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:name, "txtNone").append("Some Text") }
|
57
|
+
|
58
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:id, "txtReadOnly").append("Some Text") }
|
59
|
+
assert_raises(ObjectDisabledException , "ObjectDisabledException was supposed to be thrown" ) { $ie.text_field(:name, "txtDisabled").append("Some Text") }
|
60
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.text_field(:name, "missing_field").append("Some Text") }
|
61
|
+
|
62
|
+
$ie.text_field(:name, "txtMultiLine1").append(" Some Text")
|
63
|
+
assert_equal( "Hello World Some Text" , $ie.text_field(:name, "txtMultiLine1").getContents )
|
64
|
+
|
65
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:id, "txtReadOnly").append("Some Text") }
|
66
|
+
assert_raises(ObjectDisabledException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:name, "txtDisabled").append("Some Text") }
|
67
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:name, "missing_field").append("Some Text") }
|
68
|
+
|
69
|
+
$ie.text_field(:name, "txtMultiLine1").set("watir IE Controller")
|
70
|
+
assert_equal( "watir IE Controller" , $ie.text_field(:name, "txtMultiLine1").getContents )
|
71
|
+
|
72
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:id, "txtReadOnly").append("Some Text") }
|
73
|
+
assert_raises(ObjectDisabledException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:name, "txtDisabled").append("Some Text") }
|
74
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { $ie.text_field(:name, "missing_field").append("Some Text") }
|
75
|
+
|
76
|
+
$ie.text_field(:name, "txtMultiLine2").clear()
|
77
|
+
assert_equal( "" , $ie.text_field(:name, "txtMultiLine2").getContents )
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|