mk_firewatir 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 +41 -0
- data/lib/firewatir/container.rb +491 -0
- data/lib/firewatir/document.rb +239 -0
- data/lib/firewatir/element.rb +1369 -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 -0
- data/lib/firewatir/firefox.rb +984 -0
- data/lib/firewatir/jssh_socket.rb +101 -0
- data/lib/firewatir/version.rb +5 -0
- data/lib/firewatir/winClicker.rb +122 -0
- data/lib/firewatir/x11.rb +192 -0
- data/unittests/attach_to_new_window_test.rb +49 -0
- data/unittests/bug_fixes_test.rb +195 -0
- data/unittests/buttons_xpath_test.rb +88 -0
- data/unittests/checkbox_test.rb +158 -0
- data/unittests/checkbox_xpath_test.rb +107 -0
- data/unittests/div_test.rb +275 -0
- data/unittests/ff_test.rb +47 -0
- data/unittests/filefield_test.rb +49 -0
- data/unittests/filefield_xpath_test.rb +35 -0
- data/unittests/form_test.rb +296 -0
- data/unittests/frame_test.rb +159 -0
- data/unittests/hidden_test.rb +85 -0
- data/unittests/hidden_xpath_test.rb +72 -0
- data/unittests/html/JavascriptClick.html +42 -0
- data/unittests/html/blankpage.html +12 -0
- data/unittests/html/buttons1.html +61 -0
- data/unittests/html/checkboxes1.html +71 -0
- data/unittests/html/complex_table.html +36 -0
- data/unittests/html/cssTest.html +42 -0
- data/unittests/html/div.html +72 -0
- data/unittests/html/div_xml.html +21 -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 +15 -0
- data/unittests/html/iframeTest1.html +14 -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 +67 -0
- data/unittests/html/javascriptevents.html +35 -0
- data/unittests/html/link_pass.html +11 -0
- data/unittests/html/links1.html +42 -0
- data/unittests/html/links2.html +11 -0
- data/unittests/html/modal_dialog.html +8 -0
- data/unittests/html/modal_dialog_launcher.html +12 -0
- data/unittests/html/nestedFrames.html +6 -0
- data/unittests/html/new_browser.html +18 -0
- data/unittests/html/new_browser_popup.html +8 -0
- data/unittests/html/pass.html +10 -0
- data/unittests/html/popups1.html +60 -0
- data/unittests/html/pre.html +28 -0
- data/unittests/html/radioButtons1.html +71 -0
- data/unittests/html/redirect.html +10 -0
- data/unittests/html/redirect1.html +9 -0
- data/unittests/html/redirect2.html +9 -0
- data/unittests/html/redirect3.html +9 -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 +74 -0
- data/unittests/html/table1.html +165 -0
- data/unittests/html/tableCell_using_xpath.html +19 -0
- data/unittests/html/textarea.html +30 -0
- data/unittests/html/textfields1.html +62 -0
- data/unittests/html/textsearch.html +44 -0
- data/unittests/images_test.rb +198 -0
- data/unittests/images_xpath_test.rb +118 -0
- data/unittests/javascript_test.rb +75 -0
- data/unittests/links_test.rb +231 -0
- data/unittests/links_xpath_test.rb +79 -0
- data/unittests/mozilla_all_tests.rb +7 -0
- data/unittests/pre_test.rb +75 -0
- data/unittests/radios_test.rb +166 -0
- data/unittests/radios_xpath_test.rb +101 -0
- data/unittests/redirect_test.rb +41 -0
- data/unittests/selectbox_test.rb +142 -0
- data/unittests/selectbox_xpath_test.rb +129 -0
- data/unittests/setup.rb +29 -0
- data/unittests/table_test.rb +385 -0
- data/unittests/table_xpath_test.rb +185 -0
- data/unittests/textfields_test.rb +234 -0
- data/unittests/textfields_xpath_test.rb +113 -0
- metadata +208 -0
@@ -0,0 +1,166 @@
|
|
1
|
+
# feature tests for Radio Buttons
|
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_Radios < Test::Unit::TestCase
|
8
|
+
|
9
|
+
|
10
|
+
def setup()
|
11
|
+
goto_page("radioButtons1.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_Radio_Exists
|
15
|
+
assert(browser.radio(:name, "box1").exists?)
|
16
|
+
assert(browser.radio(:id, "box5").exists?)
|
17
|
+
|
18
|
+
assert_false(browser.radio(:name, "missingname").exists?)
|
19
|
+
assert_false(browser.radio(:id, "missingid").exists?)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_radio_class
|
23
|
+
assert_raises(UnknownObjectException) { browser.radio(:name, "noName").class_name }
|
24
|
+
assert_equal("radio_style" , browser.radio(:name, "box1").class_name)
|
25
|
+
assert_equal("" , browser.radio(:id, "box5").class_name)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_Radio_Enabled
|
29
|
+
assert_raises(UnknownObjectException) { browser.radio(:name, "noName").enabled? }
|
30
|
+
assert_raises(UnknownObjectException) { browser.radio(:id, "noName").enabled? }
|
31
|
+
assert_raises(UnknownObjectException) { browser.radio(:name, "box4" , 6).enabled? }
|
32
|
+
|
33
|
+
assert_false(browser.radio(:name, "box2").enabled?)
|
34
|
+
assert(browser.radio(:id, "box5").enabled?)
|
35
|
+
assert(browser.radio(:name, "box1").enabled?)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_little
|
39
|
+
assert_false(browser.button(:value , "foo").enabled?)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_onClick
|
43
|
+
|
44
|
+
assert_false(browser.radio(:name, "box5").isSet?)
|
45
|
+
assert_false(browser.button(:value , "foo").enabled?)
|
46
|
+
|
47
|
+
# first click the button is enabled and the radio is set
|
48
|
+
browser.radio(:name, "box5" , 1).click
|
49
|
+
assert(browser.radio(:name, "box5",1).isSet?)
|
50
|
+
#assert(browser.button(:value , "foo").enabled?)
|
51
|
+
|
52
|
+
# second click the button is disabled and the radio is still set
|
53
|
+
browser.radio(:name, "box5", 1).click
|
54
|
+
assert(browser.radio(:name, "box5",1).isSet?)
|
55
|
+
assert_false(browser.button(:value , "foo").enabled?)
|
56
|
+
|
57
|
+
# third click the button is enabled and the radio is still set
|
58
|
+
browser.radio(:name, "box5", 1).click
|
59
|
+
assert(browser.radio(:name, "box5",1 ).isSet?)
|
60
|
+
assert(browser.button(:value , "foo").enabled?)
|
61
|
+
|
62
|
+
# click the radio with a value of 2 , button is disabled and the radio is still set
|
63
|
+
browser.radio(:name, "box5", 2).click
|
64
|
+
assert_false(browser.radio(:name, "box5" ,1).isSet?)
|
65
|
+
assert(browser.radio(:name, "box5" ,2).isSet?)
|
66
|
+
assert_false(browser.button(:value , "foo").enabled?)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_Radio_isSet
|
70
|
+
assert_raises(UnknownObjectException) { browser.radio(:name, "noName").isSet? }
|
71
|
+
|
72
|
+
assert_false(browser.radio(:name, "box1").isSet?)
|
73
|
+
assert( browser.radio(:name, "box3").isSet?)
|
74
|
+
assert_false(browser.radio(:name, "box2").isSet?)
|
75
|
+
assert( browser.radio(:name, "box4" , 1 ).isSet?)
|
76
|
+
assert_false(browser.radio(:name, "box4" , 2 ).isSet?)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_radio_clear
|
80
|
+
assert_raises(UnknownObjectException) { browser.radio(:name, "noName").clear }
|
81
|
+
|
82
|
+
browser.radio(:name, "box1").clear
|
83
|
+
assert_false(browser.radio(:name, "box1").isSet?)
|
84
|
+
|
85
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:name, "box2").clear }
|
86
|
+
assert_false(browser.radio(:name, "box2").isSet?)
|
87
|
+
|
88
|
+
browser.radio(:name, "box3").clear
|
89
|
+
assert_false(browser.radio(:name, "box3").isSet?)
|
90
|
+
|
91
|
+
browser.radio(:name, "box4" , 1).clear
|
92
|
+
assert_false(browser.radio(:name, "box4" , 1).isSet?)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_radio_getState
|
96
|
+
assert_raises(UnknownObjectException) { browser.radio(:name, "noName").getState }
|
97
|
+
|
98
|
+
assert_equal( false , browser.radio(:name, "box1").getState )
|
99
|
+
assert_equal( true , browser.radio(:name, "box3").getState)
|
100
|
+
|
101
|
+
# radioes that have the same name but different values
|
102
|
+
assert_equal( false , browser.radio(:name, "box4" , 2).getState )
|
103
|
+
assert_equal( true , browser.radio(:name, "box4" , 1).getState)
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_radio_set
|
107
|
+
assert_raises(UnknownObjectException) { browser.radio(:name, "noName").set }
|
108
|
+
browser.radio(:name, "box1").set
|
109
|
+
assert(browser.radio(:name, "box1").isSet?)
|
110
|
+
|
111
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:name, "box2").set }
|
112
|
+
|
113
|
+
browser.radio(:name, "box3").set
|
114
|
+
assert(browser.radio(:name, "box3").isSet?)
|
115
|
+
|
116
|
+
# radioes that have the same name but different values
|
117
|
+
browser.radio(:name, "box4" , 3).set
|
118
|
+
assert(browser.radio(:name, "box4" , 3).isSet?)
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_radio_properties
|
122
|
+
|
123
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).value}
|
124
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).name }
|
125
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).id }
|
126
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).disabled }
|
127
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.radio(:index, 199).type }
|
128
|
+
|
129
|
+
assert_equal("on" , browser.radio(:index, 1).value)
|
130
|
+
assert_equal("box1" , browser.radio(:index, 1).name )
|
131
|
+
assert_equal("" , browser.radio(:index, 1).id )
|
132
|
+
assert_equal("radio", browser.radio(:index, 1).type )
|
133
|
+
|
134
|
+
assert_equal( false, browser.radio(:index, 1).disabled )
|
135
|
+
assert_equal( true, browser.radio(:index, 3).disabled )
|
136
|
+
|
137
|
+
assert_equal("box5" , browser.radio(:index, 2).id )
|
138
|
+
assert_equal("" , browser.radio(:index, 2).name )
|
139
|
+
|
140
|
+
assert_equal("box4-value5", browser.radio(:name , "box4" , 5 ).title )
|
141
|
+
assert_equal("", browser.radio(:name , "box4" , 4 ).title )
|
142
|
+
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_radio_iterators
|
147
|
+
|
148
|
+
assert_equal(11, browser.radios.length)
|
149
|
+
assert_equal("box5" , browser.radios[2].id )
|
150
|
+
assert_equal(true , browser.radios[3].disabled )
|
151
|
+
assert_equal(false , browser.radios[1].disabled )
|
152
|
+
index = 1
|
153
|
+
browser.radios.each do |r|
|
154
|
+
assert_equal( browser.radio(:index, index).name , r.name )
|
155
|
+
assert_equal( browser.radio(:index, index).id , r.id )
|
156
|
+
assert_equal( browser.radio(:index, index).value, r.value)
|
157
|
+
assert_equal( browser.radio(:index, index).disabled , r.disabled )
|
158
|
+
assert_equal( browser.radio(:index, index).isSet? , r.isSet? )
|
159
|
+
index+=1
|
160
|
+
end
|
161
|
+
assert_equal(index -1, browser.radios.length)
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
end
|
166
|
+
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# feature tests for Radio Buttons
|
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_Radios_XPath < Test::Unit::TestCase
|
8
|
+
|
9
|
+
|
10
|
+
def setup()
|
11
|
+
goto_page("radioButtons1.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_Radio_Exists
|
15
|
+
assert(browser.radio(:xpath, "//input[@name='box1']").exists?)
|
16
|
+
assert(browser.radio(:xpath, "//input[@id='box5']").exists?)
|
17
|
+
|
18
|
+
assert_false(browser.radio(:xpath, "//input[@name='missingname']").exists?)
|
19
|
+
assert_false(browser.radio(:xpath, "//input[@id='missingid']").exists?)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_Radio_Enabled
|
23
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']").enabled? }
|
24
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@id='noName']").enabled? }
|
25
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='box4' and @value='6']").enabled? }
|
26
|
+
|
27
|
+
assert_false(browser.radio(:xpath, "//input[@name='box2']").enabled?)
|
28
|
+
assert(browser.radio(:xpath, "//input[@id='box5']").enabled?)
|
29
|
+
assert(browser.radio(:xpath, "//input[@name='box1']").enabled?)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_little
|
33
|
+
assert_false(browser.button(:xpath,"//input[@name='foo']").enabled?)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_onClick
|
37
|
+
assert_false(browser.button(:xpath,"//input[@name='foo']").enabled?)
|
38
|
+
browser.radio(:xpath, "//input[@name='box5' and @value='1']").set
|
39
|
+
assert(browser.button(:xpath,"//input[@name='foo']").enabled?)
|
40
|
+
|
41
|
+
browser.radio(:xpath, "//input[@name='box5' and @value='2']").set
|
42
|
+
assert_false(browser.button(:xpath,"//input[@name='foo']").enabled?)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_Radio_isSet
|
46
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']").isSet? }
|
47
|
+
|
48
|
+
puts "radio 1 is set : #{ browser.radio(:xpath, "//input[@name='box1']").isSet? } "
|
49
|
+
assert_false(browser.radio(:xpath, "//input[@name='box1']").isSet?)
|
50
|
+
|
51
|
+
assert(browser.radio(:xpath, "//input[@name='box3']").isSet?)
|
52
|
+
assert_false(browser.radio(:xpath, "//input[@name='box2']").isSet?)
|
53
|
+
|
54
|
+
assert( browser.radio(:xpath, "//input[@name='box4' and @value='1']").isSet?)
|
55
|
+
assert_false(browser.radio(:xpath, "//input[@name='box4' and @value='2']").isSet?)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_radio_clear
|
59
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']").clear }
|
60
|
+
|
61
|
+
browser.radio(:xpath, "//input[@name='box1']").clear
|
62
|
+
assert_false(browser.radio(:xpath, "//input[@name='box1']").isSet?)
|
63
|
+
|
64
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:xpath, "//input[@name='box2']").clear }
|
65
|
+
assert_false(browser.radio(:xpath, "//input[@name='box2']").isSet?)
|
66
|
+
|
67
|
+
browser.radio(:xpath, "//input[@name='box3']").clear
|
68
|
+
assert_false(browser.radio(:xpath, "//input[@name='box3']").isSet?)
|
69
|
+
|
70
|
+
browser.radio(:xpath, "//input[@name='box4' and @value='1']").clear
|
71
|
+
assert_false(browser.radio(:xpath, "//input[@name='box4' and @value='1']").isSet?)
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_radio_getState
|
75
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']").getState }
|
76
|
+
|
77
|
+
assert_equal( false , browser.radio(:xpath, "//input[@name='box1']").getState )
|
78
|
+
assert_equal( true , browser.radio(:xpath, "//input[@name='box3']").getState)
|
79
|
+
|
80
|
+
# radioes that have the same name but different values
|
81
|
+
assert_equal( false , browser.radio(:xpath, "//input[@name='box4' and @value='2']").getState )
|
82
|
+
assert_equal( true , browser.radio(:xpath, "//input[@name='box4' and @value='1']").getState)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_radio_set
|
86
|
+
assert_raises(UnknownObjectException) { browser.radio(:xpath, "//input[@name='noName']").set }
|
87
|
+
browser.radio(:xpath, "//input[@name='box1']").set
|
88
|
+
assert(browser.radio(:xpath, "//input[@name='box1']").isSet?)
|
89
|
+
|
90
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { browser.radio(:xpath, "//input[@name='box2']").set }
|
91
|
+
|
92
|
+
browser.radio(:xpath, "//input[@name='box3']").set
|
93
|
+
assert(browser.radio(:xpath, "//input[@name='box3']").isSet?)
|
94
|
+
|
95
|
+
# radioes that have the same name but different values
|
96
|
+
browser.radio(:xpath, "//input[@name='box4' and @value='3']").set
|
97
|
+
assert(browser.radio(:xpath, "//input[@name='box4' and @value='3']").isSet?)
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# feature tests for Javascript redirect
|
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_Redirect < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
goto_page("redirect.html")
|
11
|
+
end
|
12
|
+
|
13
|
+
def goto_multiple_redirect
|
14
|
+
goto_page("redirect1.html")
|
15
|
+
end
|
16
|
+
|
17
|
+
tag_method :test_single_redirect, :fails_on_ie
|
18
|
+
def test_single_redirect
|
19
|
+
assert_raises(UnknownObjectException) {browser.div(:id , "div77").click }
|
20
|
+
assert_raises(UnknownObjectException) {browser.div(:title , "div77").click }
|
21
|
+
|
22
|
+
assert(browser.text_field(:name, "text1").verify_contains("0") )
|
23
|
+
browser.div(:id , "div3").click
|
24
|
+
assert(browser.text_field(:name, "text1").verify_contains("1") )
|
25
|
+
browser.div(:id , "div4").click
|
26
|
+
assert(browser.text_field(:name, "text1").verify_contains("0") )
|
27
|
+
end
|
28
|
+
|
29
|
+
tag_method :test_multiple_redirect, :fails_on_ie
|
30
|
+
def test_multiple_redirect
|
31
|
+
goto_multiple_redirect()
|
32
|
+
assert_raises(UnknownObjectException) {browser.div(:id , "div77").click }
|
33
|
+
assert_raises(UnknownObjectException) {browser.div(:title , "div77").click }
|
34
|
+
|
35
|
+
assert(browser.text_field(:name, "text1").verify_contains("0") )
|
36
|
+
browser.div(:id , "div3").click
|
37
|
+
assert(browser.text_field(:name, "text1").verify_contains("1") )
|
38
|
+
browser.div(:id , "div4").click
|
39
|
+
assert(browser.text_field(:name, "text1").verify_contains("0") )
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
# feature tests for Select Boxes
|
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_SelectList < Test::Unit::TestCase
|
8
|
+
|
9
|
+
|
10
|
+
def setup()
|
11
|
+
goto_page("selectboxes1.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_textBox_Exists
|
15
|
+
assert(browser.select_list(:name, "sel1").exists?)
|
16
|
+
assert_false(browser.select_list(:name, "missing").exists?)
|
17
|
+
assert_false(browser.select_list(:id, "missing").exists?)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_select_list_enabled
|
21
|
+
assert(browser.select_list(:name, "sel1").enabled?)
|
22
|
+
assert_raises(UnknownObjectException) { browser.select_list(:name, "NoName").enabled? }
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_select_list_getAllContents
|
26
|
+
assert_raises(UnknownObjectException) { browser.select_list(:name, "NoName").getAllContents }
|
27
|
+
assert_equal( ["Option 1" ,"Option 2" , "Option 3" , "Option 4"] ,
|
28
|
+
browser.select_list(:name, "sel1").getAllContents)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_Option_text_select
|
32
|
+
assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, "missing item").select }
|
33
|
+
assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, /missing/).select }
|
34
|
+
assert_raises(MissingWayOfFindingObjectException) { browser.select_list(:name, "sel1").option(:missing, "Option 1").select }
|
35
|
+
|
36
|
+
# the select method keeps any currently selected items - use the clear selection method first
|
37
|
+
browser.select_list( :name , "sel1").clearSelection
|
38
|
+
browser.select_list( :name , "sel1").option(:text, "Option 1").select
|
39
|
+
assert_equal( ["Option 1" ] , browser.select_list(:name, "sel1").getSelectedItems)
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
tag_method :test_option_class_name, :fails_on_ie
|
44
|
+
def test_option_class_name
|
45
|
+
|
46
|
+
# the option object doesnt inherit from element, so this doesnt work
|
47
|
+
assert_raises(UnknownObjectException) { browser.select_list(:name, "sel1").option(:text, "missing item").class_name }
|
48
|
+
assert_equal("option_style" , browser.select_list(:name, "sel2").option(:value , 'o2').class_name)
|
49
|
+
assert_equal("" , browser.select_list(:name, "sel2").option(:value , 'o1').class_name)
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_selectBox_select_using_value
|
54
|
+
assert_raises(UnknownObjectException) { browser.select_list(:name, "NoName").getSelectedItems }
|
55
|
+
assert_raises(NoValueFoundException) { browser.select_list(:name, "sel1").select_value("missing item") }
|
56
|
+
assert_raises(NoValueFoundException) { browser.select_list(:name, "sel1").select_value(/missing/) }
|
57
|
+
|
58
|
+
# the select method keeps any currently selected items - use the clear selectcion method first
|
59
|
+
browser.select_list( :name , "sel1").clearSelection
|
60
|
+
browser.select_list( :name , "sel1").select_value("o1")
|
61
|
+
assert_equal( ["Option 1" ] , browser.select_list(:name, "sel1").getSelectedItems)
|
62
|
+
|
63
|
+
browser.select_list( :name , "sel1").clearSelection
|
64
|
+
browser.select_list( :name , "sel1").select_value(/2/)
|
65
|
+
assert_equal( ["Option 2" ] , browser.select_list(:name, "sel1").getSelectedItems)
|
66
|
+
|
67
|
+
browser.select_list( :name , "sel2").clearSelection
|
68
|
+
browser.select_list( :name , "sel2").select_value(/4/)
|
69
|
+
browser.select_list( :name , "sel2").select_value(/2/)
|
70
|
+
assert_equal( ["Option 2" , "Option 4" ] ,
|
71
|
+
browser.select_list(:name, "sel2").getSelectedItems)
|
72
|
+
|
73
|
+
# these are to test the onchange event
|
74
|
+
# the event shouldnt get fired, as this is the selected item
|
75
|
+
browser.select_list( :name , "sel3").select_value( /3/ )
|
76
|
+
assert_false(browser.text.include?("Pass") )
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_select_list_select_using_value2
|
80
|
+
# the event should get fired
|
81
|
+
browser.select_list( :name , "sel3").select_value( /2/ )
|
82
|
+
assert(browser.text.include?("PASS") )
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_select_list_properties
|
86
|
+
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).value }
|
87
|
+
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).name }
|
88
|
+
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).id }
|
89
|
+
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).disabled }
|
90
|
+
assert_raises(UnknownObjectException) { browser.select_list(:index, 199).type }
|
91
|
+
|
92
|
+
assert_equal("o3" , browser.select_list(:index, 1).value)
|
93
|
+
assert_equal("sel1" , browser.select_list(:index, 1).name )
|
94
|
+
assert_equal("" , browser.select_list(:index, 1).id )
|
95
|
+
assert_equal("select-one", browser.select_list(:index, 1).type )
|
96
|
+
assert_equal("select-multiple", browser.select_list(:index, 2).type )
|
97
|
+
|
98
|
+
browser.select_list(:index,1).select(/1/)
|
99
|
+
assert_equal("o1" , browser.select_list(:index, 1).value)
|
100
|
+
|
101
|
+
assert_false( browser.select_list(:index, 1).disabled )
|
102
|
+
assert( browser.select_list(:index, 4).disabled )
|
103
|
+
assert( browser.select_list(:id, 'selectbox_4').disabled )
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_select_list_iterator
|
107
|
+
assert_equal(5, browser.select_lists.length)
|
108
|
+
assert_equal("o3" , browser.select_lists[1].value)
|
109
|
+
assert_equal("sel1" , browser.select_lists[1].name )
|
110
|
+
assert_equal("select-one", browser.select_lists[1].type )
|
111
|
+
assert_equal("select-multiple" , browser.select_lists[2].type )
|
112
|
+
|
113
|
+
index=1
|
114
|
+
browser.select_lists.each do |l|
|
115
|
+
assert_equal( browser.select_list(:index, index).name , l.name )
|
116
|
+
assert_equal( browser.select_list(:index, index).id , l.id )
|
117
|
+
assert_equal( browser.select_list(:index, index).type , l.type )
|
118
|
+
assert_equal( browser.select_list(:index, index).value , l.value )
|
119
|
+
index+=1
|
120
|
+
end
|
121
|
+
assert_equal( index-1, browser.select_lists.length)
|
122
|
+
# Bug Fix 25
|
123
|
+
browser.select_lists.each { |list| puts list.getAllContents() }
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
class TC_Select_Options < Test::Unit::TestCase
|
128
|
+
tags :fails_on_ie
|
129
|
+
|
130
|
+
def setup()
|
131
|
+
goto_page("select_tealeaf.html")
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_options_text
|
135
|
+
browser.select_list(:name, 'op_numhits').option(:text, '>=').select
|
136
|
+
assert(browser.select_list(:name, 'op_numhits').option(:text, '>=').selected)
|
137
|
+
assert_equal( [">=" ] , browser.select_list(:name, "op_numhits").getSelectedItems)
|
138
|
+
assert_equal( "=" , browser.select_list(:name, "op_numhits")[1].text)
|
139
|
+
assert_equal( "0" , browser.select_list(:name, "op_numhits")[1].value)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|