watir 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,44 @@
|
|
1
|
+
# feature tests for javascript PopUps
|
2
|
+
# revision: $Revision: 1.13 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_PopUps < Test::Unit::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def setup
|
11
|
+
$ie.goto("file://#{$myDir}/html/popups1.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def startClicker( button , waitTime = 0.5)
|
15
|
+
w = WinClicker.new
|
16
|
+
longName = $ie.dir.gsub("/" , "\\" )
|
17
|
+
shortName = w.getShortFileName(longName)
|
18
|
+
c = "start rubyw #{shortName }\\watir\\clickJSDialog.rb #{button } #{ waitTime} "
|
19
|
+
puts "Starting #{c}"
|
20
|
+
w.winsystem(c )
|
21
|
+
w=nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_simple
|
25
|
+
startClicker("OK")
|
26
|
+
$ie.button("Alert").click
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_confirm
|
30
|
+
startClicker("OK")
|
31
|
+
$ie.button("Confirm").click
|
32
|
+
assert( $ie.text_field(:name , "confirmtext").verify_contains("OK") )
|
33
|
+
|
34
|
+
startClicker("Cancel")
|
35
|
+
$ie.button("Confirm").click
|
36
|
+
assert( $ie.text_field(:name , "confirmtext").verify_contains("Cancel") )
|
37
|
+
end
|
38
|
+
|
39
|
+
def xtest_Prompt
|
40
|
+
startClicker("OK")
|
41
|
+
$ie.button("Prompt").click
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,164 @@
|
|
1
|
+
# feature tests for Radio Buttons
|
2
|
+
# revision: $Revision: 1.25 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_Radios < Test::Unit::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def setup()
|
11
|
+
$ie.goto($htmlRoot + "radioButtons1.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_Radio_Exists
|
15
|
+
assert($ie.radio(:name, "box1").exists?)
|
16
|
+
assert($ie.radio(:id, "box5").exists?)
|
17
|
+
|
18
|
+
assert_false($ie.radio(:name, "missingname").exists?)
|
19
|
+
assert_false($ie.radio(:id, "missingid").exists?)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_Radio_Enabled
|
23
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").enabled? }
|
24
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:id, "noName").enabled? }
|
25
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "box4" , 6).enabled? }
|
26
|
+
|
27
|
+
assert_false($ie.radio(:name, "box2").enabled?)
|
28
|
+
assert($ie.radio(:id, "box5").enabled?)
|
29
|
+
assert($ie.radio(:name, "box1").enabled?)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_little
|
33
|
+
assert_false($ie.button(:value , "foo").enabled?)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_onClick
|
37
|
+
|
38
|
+
assert_false($ie.radio(:name, "box5").isSet?)
|
39
|
+
assert_false($ie.button(:value , "foo").enabled?)
|
40
|
+
|
41
|
+
# first click the button is enabled and the radio is set
|
42
|
+
$ie.radio(:name, "box5" , 1).set
|
43
|
+
assert($ie.radio(:name, "box5",1).isSet?)
|
44
|
+
assert($ie.button(:value , "foo").enabled?)
|
45
|
+
|
46
|
+
# second click the button is disabled and the radio is still set
|
47
|
+
$ie.radio(:name, "box5", 1).set
|
48
|
+
assert($ie.radio(:name, "box5",1).isSet?)
|
49
|
+
assert_false($ie.button(:value , "foo").enabled?)
|
50
|
+
|
51
|
+
# third click the button is enabled and the radio is still set
|
52
|
+
$ie.radio(:name, "box5", 1).set
|
53
|
+
assert($ie.radio(:name, "box5",1 ).isSet?)
|
54
|
+
assert($ie.button(:value , "foo").enabled?)
|
55
|
+
|
56
|
+
# click the radio with a value of 2 , button is disabled and the radio is still set
|
57
|
+
$ie.radio(:name, "box5", 2).set
|
58
|
+
assert_false($ie.radio(:name, "box5" ,1).isSet?)
|
59
|
+
assert($ie.radio(:name, "box5" ,2).isSet?)
|
60
|
+
assert_false($ie.button(:value , "foo").enabled?)
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_Radio_isSet
|
68
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").isSet? }
|
69
|
+
|
70
|
+
assert_false($ie.radio(:name, "box1").isSet?)
|
71
|
+
assert( $ie.radio(:name, "box3").isSet?)
|
72
|
+
assert_false($ie.radio(:name, "box2").isSet?)
|
73
|
+
assert( $ie.radio(:name, "box4" , 1 ).isSet?)
|
74
|
+
assert_false($ie.radio(:name, "box4" , 2 ).isSet?)
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_radio_clear
|
78
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").clear }
|
79
|
+
|
80
|
+
$ie.radio(:name, "box1").clear
|
81
|
+
assert_false($ie.radio(:name, "box1").isSet?)
|
82
|
+
|
83
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ie.radio(:name, "box2").clear }
|
84
|
+
assert_false($ie.radio(:name, "box2").isSet?)
|
85
|
+
|
86
|
+
$ie.radio(:name, "box3").clear
|
87
|
+
assert_false($ie.radio(:name, "box3").isSet?)
|
88
|
+
|
89
|
+
$ie.radio(:name, "box4" , 1).clear
|
90
|
+
assert_false($ie.radio(:name, "box4" , 1).isSet?)
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_radio_getState
|
94
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").getState }
|
95
|
+
|
96
|
+
assert_equal( false , $ie.radio(:name, "box1").getState )
|
97
|
+
assert_equal( true , $ie.radio(:name, "box3").getState)
|
98
|
+
|
99
|
+
# radioes that have the same name but different values
|
100
|
+
assert_equal( false , $ie.radio(:name, "box4" , 2).getState )
|
101
|
+
assert_equal( true , $ie.radio(:name, "box4" , 1).getState)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_radio_set
|
105
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:name, "noName").set }
|
106
|
+
$ie.radio(:name, "box1").set
|
107
|
+
assert($ie.radio(:name, "box1").isSet?)
|
108
|
+
|
109
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ie.radio(:name, "box2").set }
|
110
|
+
|
111
|
+
$ie.radio(:name, "box3").set
|
112
|
+
assert($ie.radio(:name, "box3").isSet?)
|
113
|
+
|
114
|
+
# radioes that have the same name but different values
|
115
|
+
$ie.radio(:name, "box4" , 3).set
|
116
|
+
assert($ie.radio(:name, "box4" , 3).isSet?)
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_radio_properties
|
120
|
+
|
121
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).value}
|
122
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).name }
|
123
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).id }
|
124
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).disabled }
|
125
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ie.radio(:index, 199).type }
|
126
|
+
|
127
|
+
assert_equal("on" , $ie.radio(:index, 1).value)
|
128
|
+
assert_equal("box1" , $ie.radio(:index, 1).name )
|
129
|
+
assert_equal("" , $ie.radio(:index, 1).id )
|
130
|
+
assert_equal("radio", $ie.radio(:index, 1).type )
|
131
|
+
|
132
|
+
assert_equal( false, $ie.radio(:index, 1).disabled )
|
133
|
+
assert_equal( true, $ie.radio(:index, 3).disabled )
|
134
|
+
|
135
|
+
assert_equal("box5" , $ie.radio(:index, 2).id )
|
136
|
+
assert_equal("" , $ie.radio(:index, 2).name )
|
137
|
+
|
138
|
+
assert_equal("box4-value5", $ie.radio(:name , "box4" , 5 ).title )
|
139
|
+
assert_equal("", $ie.radio(:name , "box4" , 4 ).title )
|
140
|
+
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_radio_iterators
|
145
|
+
|
146
|
+
assert_equal(11, $ie.radios.length)
|
147
|
+
assert_equal("box5" , $ie.radios[2].id )
|
148
|
+
assert_equal(true , $ie.radios[3].disabled )
|
149
|
+
assert_equal(false , $ie.radios[1].disabled )
|
150
|
+
|
151
|
+
index = 1
|
152
|
+
$ie.radios.each do |r|
|
153
|
+
assert_equal( $ie.radio(:index, index).name , r.name )
|
154
|
+
assert_equal( $ie.radio(:index, index).id , r.id )
|
155
|
+
assert_equal( $ie.radio(:index, index).value, r.value)
|
156
|
+
assert_equal( $ie.radio(:index, index).disabled , r.disabled )
|
157
|
+
index+=1
|
158
|
+
end
|
159
|
+
assert_equal(index -1, $ie.radios.length)
|
160
|
+
end
|
161
|
+
|
162
|
+
|
163
|
+
end
|
164
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# feature tests for screen capture
|
2
|
+
# revision: $Revision: 1.4 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
require 'watir/screen_capture'
|
7
|
+
|
8
|
+
class TC_Capture< Test::Unit::TestCase
|
9
|
+
include Watir
|
10
|
+
include Watir::ScreenCapture
|
11
|
+
|
12
|
+
def setup
|
13
|
+
delete_captured_files( [ 'jpeg1.jpg' , 'jpeg2.jpg' , 'bmp1.bmp', 'bmp2.bmp' ] )
|
14
|
+
$ie.goto($htmlRoot + 'buttons1.html' )
|
15
|
+
@file_list = []
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
delete_captured_files
|
20
|
+
end
|
21
|
+
|
22
|
+
def delete_captured_files(files=nil )
|
23
|
+
files = @file_list unless files
|
24
|
+
files.each do |f|
|
25
|
+
File.delete( f) if FileTest.exists?( f)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_jpeg
|
30
|
+
file_name= 'jpeg1.jpg'
|
31
|
+
@file_list << file_name
|
32
|
+
screen_capture( file_name )
|
33
|
+
assert(FileTest.exist?( file_name) )
|
34
|
+
|
35
|
+
file_name= 'jpeg2.jpg'
|
36
|
+
@file_list << file_name
|
37
|
+
screen_capture( file_name , true ) # just the active window
|
38
|
+
assert(FileTest.exist?( file_name) )
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_bmp
|
42
|
+
file_name= 'bmp1.bmp'
|
43
|
+
@file_list << file_name
|
44
|
+
screen_capture( file_name , false, true )
|
45
|
+
assert(FileTest.exist?( file_name ) )
|
46
|
+
|
47
|
+
file_name= 'bmp2.bmp'
|
48
|
+
@file_list << file_name
|
49
|
+
screen_capture( file_name , true , true ) # just the active window
|
50
|
+
assert(FileTest.exist?( file_name) )
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,197 @@
|
|
1
|
+
# feature tests for Select Boxes
|
2
|
+
# revision: $Revision: 1.28 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_SelectList < Test::Unit::TestCase
|
8
|
+
include Watir
|
9
|
+
|
10
|
+
def setup()
|
11
|
+
$ie.goto($htmlRoot + "selectboxes1.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_SelectList_exists
|
15
|
+
assert($ie.select_list(:name, "sel1").exists?)
|
16
|
+
assert_false($ie.select_list(:name, "missing").exists?)
|
17
|
+
assert_false($ie.select_list(:id, "missing").exists?)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_SelectList_enabled
|
21
|
+
assert($ie.select_list(:name, "sel1").enabled?)
|
22
|
+
assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").enabled? }
|
23
|
+
assert_false($ie.select_list(:id, 'selectbox_4').enabled?)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_Option_text_select
|
27
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:name, "sel1").option(:text, "missing item").select }
|
28
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:name, "sel1").option(:text, /missing/).select }
|
29
|
+
assert_raises(MissingWayOfFindingObjectException) { $ie.select_list(:name, "sel1").option(:missing, "Option 1").select }
|
30
|
+
|
31
|
+
# the select method keeps any currently selected items - use the clear selection method first
|
32
|
+
$ie.select_list( :name , "sel1").clearSelection
|
33
|
+
$ie.select_list( :name , "sel1").option(:text, "Option 1").select
|
34
|
+
assert_arrayEquals( ["Option 1" ] , $ie.select_list(:name, "sel1").getSelectedItems)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Tests for the old interface
|
39
|
+
class TC_Selectbox < Test::Unit::TestCase
|
40
|
+
include Watir
|
41
|
+
|
42
|
+
def setup()
|
43
|
+
$ie.goto($htmlRoot + "selectboxes1.html")
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_selectBox_Exists
|
47
|
+
assert($ie.selectBox(:name, "sel1").exists?)
|
48
|
+
assert_false($ie.selectBox(:name, "missing").exists?)
|
49
|
+
assert_false($ie.selectBox(:id, "missing").exists?)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_selectBox_enabled
|
53
|
+
assert($ie.selectBox(:name, "sel1").enabled?)
|
54
|
+
assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").enabled? }
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_selectBox_getAllContents
|
58
|
+
assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").getAllContents }
|
59
|
+
assert_arrayEquals( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
|
60
|
+
$ie.selectBox(:name, "sel1").getAllContents)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_selectBox_getSelectedItems
|
64
|
+
assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").getSelectedItems }
|
65
|
+
assert_arrayEquals( ["Option 3" ] ,
|
66
|
+
$ie.selectBox(:name, "sel1").getSelectedItems)
|
67
|
+
assert_arrayEquals( ["Option 3" , "Option 6" ] ,
|
68
|
+
$ie.selectBox(:name, "sel2").getSelectedItems)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_clearSelection
|
72
|
+
assert_raises(UnknownObjectException) { $ie.selectBox(:name, "NoName").clearSelection }
|
73
|
+
$ie.selectBox( :name , "sel1").clearSelection
|
74
|
+
|
75
|
+
# the box sel1 has no ability to have a de-selected item
|
76
|
+
assert_arrayEquals( ["Option 3" ] , $ie.selectBox(:name, "sel1").getSelectedItems)
|
77
|
+
|
78
|
+
$ie.selectBox( :name , "sel2").clearSelection
|
79
|
+
assert_arrayEquals( [ ] , $ie.selectBox(:name, "sel2").getSelectedItems)
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_selectBox_select
|
83
|
+
assert_raises(NoValueFoundException) { $ie.selectBox(:name, "sel1").select("missing item") }
|
84
|
+
assert_raises(NoValueFoundException) { $ie.selectBox(:name, "sel1").select(/missing/) }
|
85
|
+
|
86
|
+
# the select method keeps any currently selected items - use the clear selectcion method first
|
87
|
+
$ie.selectBox( :name , "sel1").clearSelection
|
88
|
+
$ie.selectBox( :name , "sel1").select("Option 1")
|
89
|
+
assert_arrayEquals( ["Option 1" ] , $ie.selectBox(:name, "sel1").getSelectedItems)
|
90
|
+
|
91
|
+
$ie.selectBox( :name , "sel1").clearSelection
|
92
|
+
$ie.selectBox( :name , "sel1").select(/2/)
|
93
|
+
assert_arrayEquals( ["Option 2" ] , $ie.selectBox(:name, "sel1").getSelectedItems)
|
94
|
+
|
95
|
+
$ie.selectBox( :name , "sel2").clearSelection
|
96
|
+
$ie.selectBox( :name , "sel2").select(/2/)
|
97
|
+
$ie.selectBox( :name , "sel2").select(/4/)
|
98
|
+
assert_arrayEquals( ["Option 2" , "Option 4" ] ,
|
99
|
+
$ie.selectBox(:name, "sel2").getSelectedItems)
|
100
|
+
|
101
|
+
# these are to test the onchange event
|
102
|
+
# the event shouldnt get fired, as this is the selected item
|
103
|
+
$ie.selectBox( :name , "sel3").select( /3/ )
|
104
|
+
assert_false($ie.contains_text("Pass") )
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_selectBox_select2
|
108
|
+
# the event should get fired
|
109
|
+
$ie.selectBox( :name , "sel3").select( /2/ )
|
110
|
+
assert($ie.contains_text("PASS") )
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_selectBox_select_using_value
|
114
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:name, "NoName").getSelectedItems }
|
115
|
+
assert_raises(NoValueFoundException) { $ie.select_list(:name, "sel1").select_value("missing item") }
|
116
|
+
assert_raises(NoValueFoundException) { $ie.select_list(:name, "sel1").select_value(/missing/) }
|
117
|
+
|
118
|
+
# the select method keeps any currently selected items - use the clear selectcion method first
|
119
|
+
$ie.select_list( :name , "sel1").clearSelection
|
120
|
+
$ie.select_list( :name , "sel1").select_value("o1")
|
121
|
+
assert_arrayEquals( ["Option 1" ] , $ie.select_list(:name, "sel1").getSelectedItems)
|
122
|
+
|
123
|
+
$ie.select_list( :name , "sel1").clearSelection
|
124
|
+
$ie.select_list( :name , "sel1").select_value(/2/)
|
125
|
+
assert_arrayEquals( ["Option 2" ] , $ie.select_list(:name, "sel1").getSelectedItems)
|
126
|
+
|
127
|
+
$ie.select_list( :name , "sel2").clearSelection
|
128
|
+
$ie.select_list( :name , "sel2").select_value(/4/)
|
129
|
+
$ie.select_list( :name , "sel2").select_value(/2/)
|
130
|
+
assert_arrayEquals( ["Option 2" , "Option 4" ] ,
|
131
|
+
$ie.select_list(:name, "sel2").getSelectedItems)
|
132
|
+
|
133
|
+
# these are to test the onchange event
|
134
|
+
# the event shouldnt get fired, as this is the selected item
|
135
|
+
$ie.select_list( :name , "sel3").select_value( /3/ )
|
136
|
+
assert_false($ie.contains_text("Pass") )
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_select_list_select_using_value2
|
140
|
+
# the event should get fired
|
141
|
+
$ie.select_list( :name , "sel3").select_value( /2/ )
|
142
|
+
assert($ie.contains_text("PASS") )
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_select_list_properties
|
146
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).value }
|
147
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).name }
|
148
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).id }
|
149
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).disabled }
|
150
|
+
assert_raises(UnknownObjectException) { $ie.select_list(:index, 199).type }
|
151
|
+
|
152
|
+
assert_equal("o3" , $ie.select_list(:index, 1).value)
|
153
|
+
assert_equal("sel1" , $ie.select_list(:index, 1).name )
|
154
|
+
assert_equal("" , $ie.select_list(:index, 1).id )
|
155
|
+
assert_equal("select-one", $ie.select_list(:index, 1).type )
|
156
|
+
assert_equal("select-multiple", $ie.select_list(:index, 2).type )
|
157
|
+
|
158
|
+
$ie.select_list(:index,1).select(/1/)
|
159
|
+
assert_equal("o1" , $ie.select_list(:index, 1).value)
|
160
|
+
|
161
|
+
assert_false( $ie.select_list(:index, 1).disabled )
|
162
|
+
assert( $ie.select_list(:index, 4).disabled )
|
163
|
+
assert( $ie.select_list(:id, 'selectbox_4').disabled )
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_select_list_iterator
|
167
|
+
assert_equal(4, $ie.select_lists.length)
|
168
|
+
assert_equal("o3" , $ie.select_lists[1].value)
|
169
|
+
assert_equal("sel1" , $ie.select_lists[1].name )
|
170
|
+
assert_equal("select-one", $ie.select_lists[1].type )
|
171
|
+
assert_equal("select-multiple" , $ie.select_lists[2].type )
|
172
|
+
|
173
|
+
index=1
|
174
|
+
$ie.select_lists.each do |l|
|
175
|
+
assert_equal( $ie.select_list(:index, index).name , l.name )
|
176
|
+
assert_equal( $ie.select_list(:index, index).id , l.id )
|
177
|
+
assert_equal( $ie.select_list(:index, index).type , l.type )
|
178
|
+
assert_equal( $ie.select_list(:index, index).value , l.value )
|
179
|
+
index+=1
|
180
|
+
end
|
181
|
+
assert_equal( index-1, $ie.select_lists.length)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
class TC_Select_Options < Test::Unit::TestCase
|
186
|
+
include Watir
|
187
|
+
|
188
|
+
def setup()
|
189
|
+
$ie.goto($htmlRoot + "select_tealeaf.html")
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_options_text
|
193
|
+
$ie.select_list(:name, 'op_numhits').option(:text, '>=').select
|
194
|
+
assert($ie.select_list(:name, 'op_numhits').option(:text, '>=').selected)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|