firewatir 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MozillaBaseElement.rb +1778 -0
- data/container.rb +889 -0
- data/firewatir/exceptions.rb +44 -0
- data/firewatir/testUnitAddons.rb +8 -0
- data/firewatir.rb +1130 -0
- data/htmlelements.rb +2277 -0
- data/unittests/attach_to_new_window_test.rb +34 -0
- data/unittests/bug_fixes_test.rb +188 -0
- data/unittests/buttons_test.rb +215 -0
- data/unittests/buttons_xpath_test.rb +87 -0
- data/unittests/checkbox_test.rb +154 -0
- data/unittests/checkbox_xpath_test.rb +107 -0
- data/unittests/div_test.rb +274 -0
- data/unittests/filefield_test.rb +45 -0
- data/unittests/filefield_xpath_test.rb +35 -0
- data/unittests/form_test.rb +307 -0
- data/unittests/frame_test.rb +151 -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 +17 -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 +204 -0
- data/unittests/images_xpath_test.rb +118 -0
- data/unittests/iostring.rb +30 -0
- data/unittests/iostring_test.rb +48 -0
- data/unittests/javascript_test.rb +71 -0
- data/unittests/links_test.rb +230 -0
- data/unittests/links_xpath_test.rb +79 -0
- data/unittests/mozilla_all_tests.rb +18 -0
- data/unittests/pre_test.rb +74 -0
- data/unittests/radios_test.rb +166 -0
- data/unittests/radios_xpath_test.rb +101 -0
- data/unittests/redirect_test.rb +40 -0
- data/unittests/selectbox_test.rb +141 -0
- data/unittests/selectbox_xpath_test.rb +127 -0
- data/unittests/setup.rb +35 -0
- data/unittests/table_test.rb +372 -0
- data/unittests/table_xpath_test.rb +184 -0
- data/unittests/textfields_test.rb +230 -0
- data/unittests/textfields_xpath_test.rb +112 -0
- metadata +144 -0
@@ -0,0 +1,230 @@
|
|
1
|
+
# feature tests for Links
|
2
|
+
# revision: $Revision: 1.0 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_Links < Test::Unit::TestCase
|
8
|
+
include FireWatir
|
9
|
+
|
10
|
+
def setup()
|
11
|
+
$ff.goto($htmlRoot + "links1.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_new_link_exists
|
15
|
+
assert($ff.link(:text, "test1").exists?)
|
16
|
+
assert($ff.link(:text, /TEST/i).exists?)
|
17
|
+
end
|
18
|
+
|
19
|
+
# In current implementation, method_missing catches all the methods that are not defined
|
20
|
+
# for the element. So there is no way to find out about missinwayoffindingobject exp.
|
21
|
+
def test_bad_attribute
|
22
|
+
assert_raises(UnknownObjectException) { $ff.link(:bad_attribute, 199).click }
|
23
|
+
begin
|
24
|
+
$ff.link(:bad_attribute, 199).click
|
25
|
+
rescue UnknownObjectException => e
|
26
|
+
assert_equal "Unable to locate object, using bad_attribute and 199", e.to_s
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_missing_links_dont_exist
|
31
|
+
assert_false($ff.link(:text, "missing").exists?)
|
32
|
+
assert_false($ff.link(:text, /miss/).exists?)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_link_Exists
|
36
|
+
assert($ff.link(:text, "test1").exists?)
|
37
|
+
assert($ff.link(:text, /TEST/i).exists?)
|
38
|
+
assert_false($ff.link(:text, "missing").exists?)
|
39
|
+
assert_false($ff.link(:text, /miss/).exists?)
|
40
|
+
|
41
|
+
# this assert we have to build up the path
|
42
|
+
# this is what it looks like if you do a to_s on the link file:///C:/watir_bonus/unitTests/html/links1.HTML
|
43
|
+
# but what we get back from $htmlRoot is a mixed case, so its almost impossible for use to test this correctly
|
44
|
+
# assert($ff.link(:url,'file:///C:/watir_bonus/unitTests/html/links1.HTML' ).exists?)
|
45
|
+
|
46
|
+
assert($ff.link(:url, /link_pass.html/).exists?)
|
47
|
+
assert_false($ff.link(:url, "alsomissing.html").exists?)
|
48
|
+
|
49
|
+
assert($ff.link(:id, "link_id").exists?)
|
50
|
+
assert_false($ff.link(:id, "alsomissing").exists?)
|
51
|
+
|
52
|
+
assert($ff.link(:id, /_id/).exists?)
|
53
|
+
assert_false($ff.link(:id, /alsomissing/).exists?)
|
54
|
+
|
55
|
+
assert($ff.link(:name, "link_name").exists?)
|
56
|
+
assert_false($ff.link(:name, "alsomissing").exists?)
|
57
|
+
|
58
|
+
assert($ff.link(:name, /_n/).exists?)
|
59
|
+
assert_false($ff.link(:name, /missing/).exists?)
|
60
|
+
|
61
|
+
assert($ff.link(:title, /ti/).exists?)
|
62
|
+
assert($ff.link(:title, "link_title").exists?)
|
63
|
+
|
64
|
+
assert_false($ff.link(:title, /missing/).exists?)
|
65
|
+
|
66
|
+
assert($ff.link(:url, /_pass/).exists?)
|
67
|
+
assert_false($ff.link(:url, /dont_exist/).exists?)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_link_click
|
71
|
+
$ff.link(:text, "test1").click
|
72
|
+
assert( $ff.text.include?("Links2-Pass") )
|
73
|
+
end
|
74
|
+
def test_link2_click
|
75
|
+
$ff.link(:url, /link_pass.html/).click
|
76
|
+
assert( $ff.text.include?("Links3-Pass") )
|
77
|
+
end
|
78
|
+
def test_link3_click
|
79
|
+
$ff.link(:index, 1).click
|
80
|
+
assert( $ff.text.include?("Links2-Pass") )
|
81
|
+
end
|
82
|
+
def test_link4_click
|
83
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).click }
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_link_properties
|
87
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).href }
|
88
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).value}
|
89
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).text }
|
90
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).name }
|
91
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).id }
|
92
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).disabled }
|
93
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).type }
|
94
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.link(:index, 199).class_name }
|
95
|
+
|
96
|
+
assert_match( /links2/ ,$ff.link(:index, 1).href )
|
97
|
+
assert_equal( "" , $ff.link(:index, 1).value)
|
98
|
+
assert_equal( "test1" , $ff.link(:index, 1).text )
|
99
|
+
assert_equal( "" , $ff.link(:index, 1).name )
|
100
|
+
assert_equal( "" , $ff.link(:index, 1).id )
|
101
|
+
#assert_equal( false , $ff.link(:index, 1).disabled )
|
102
|
+
assert_equal( "" , $ff.link(:index, 1).class_name)
|
103
|
+
assert_equal( "link_class_1" , $ff.link(:index, 2).class_name)
|
104
|
+
|
105
|
+
assert_equal( "link_id" , $ff.link(:index, 6).id )
|
106
|
+
assert_equal( "link_name" , $ff.link(:index, 7).name )
|
107
|
+
|
108
|
+
assert_equal( "" , $ff.link(:index, 7).title)
|
109
|
+
|
110
|
+
assert_equal( "link_title" , $ff.link(:index, 8).title)
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_text_attribute
|
114
|
+
arr1 = $ff.link(:text, "nameDelet").to_s
|
115
|
+
arr2 = $ff.link(:text, /Delet/).to_s
|
116
|
+
assert_equal(arr1, arr2)
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_link_iterator
|
121
|
+
assert_equal(11, $ff.links.length )
|
122
|
+
assert_equal("Link Using a name" , $ff.links[7].text)
|
123
|
+
|
124
|
+
index = 1
|
125
|
+
$ff.links.each do |link|
|
126
|
+
assert_equal( $ff.link(:index, index).href , link.href )
|
127
|
+
assert_equal( $ff.link(:index, index).id , link.id )
|
128
|
+
assert_equal( $ff.link(:index, index).name , link.name )
|
129
|
+
assert_equal( $ff.link(:index, index).innerText , link.text )
|
130
|
+
index+=1
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_div_xml_bug
|
135
|
+
$ff.goto($htmlRoot + "div_xml.html")
|
136
|
+
assert_nothing_raised {$ff.link(:text, 'Create').exists? }
|
137
|
+
end
|
138
|
+
def test_link_to_s
|
139
|
+
puts $ff.link(:id,"linktos").to_s
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
class TC_Frame_Links < Test::Unit::TestCase
|
144
|
+
include FireWatir
|
145
|
+
|
146
|
+
def setup()
|
147
|
+
$ff.goto($htmlRoot + "frame_links.html")
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_new_frame_link_exists
|
151
|
+
assert($ff.frame("buttonFrame").link(:text, "test1").exists?)
|
152
|
+
end
|
153
|
+
def test_missing_frame_links_dont_exist
|
154
|
+
assert_false($ff.frame("buttonFrame").link(:text, "missing").exists?)
|
155
|
+
assert_raise(UnknownFrameException, "UnknownFrameException was supposed to be thrown"){$ff.frame("missing").link(:text, "test1").exists?}
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_links_in_frames
|
159
|
+
assert($ff.frame("buttonFrame").link(:text, "test1").exists?)
|
160
|
+
assert_false($ff.frame("buttonFrame").link(:text, "missing").exists?)
|
161
|
+
|
162
|
+
assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { $ff.frame("buttonFrame").link(:index, 199).href }
|
163
|
+
assert_match(/links2/, $ff.frame("buttonFrame").link(:index, 1).href)
|
164
|
+
|
165
|
+
count =0
|
166
|
+
$ff.frame("buttonFrame").links.each do |l|
|
167
|
+
count+=1
|
168
|
+
end
|
169
|
+
|
170
|
+
assert_equal(11 , count)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
class TC_Links_Display < Test::Unit::TestCase
|
175
|
+
include FireWatir
|
176
|
+
include MockStdoutTestCase
|
177
|
+
|
178
|
+
def test_showLinks
|
179
|
+
$ff.goto($htmlRoot + "links1.html")
|
180
|
+
$stdout = @mockout
|
181
|
+
$ff.showLinks
|
182
|
+
assert_equal(<<END_OF_MESSAGE, @mockout)
|
183
|
+
There are 11 links
|
184
|
+
link: name:
|
185
|
+
id:
|
186
|
+
href: links2.html
|
187
|
+
index: 1
|
188
|
+
link: name:
|
189
|
+
id:
|
190
|
+
href: link_pass.html
|
191
|
+
index: 2
|
192
|
+
link: name:
|
193
|
+
id:
|
194
|
+
href: pass3.html
|
195
|
+
index: 3
|
196
|
+
link: name:
|
197
|
+
id:
|
198
|
+
href: textarea.html
|
199
|
+
index: 4
|
200
|
+
link: name:
|
201
|
+
id:
|
202
|
+
href: textarea.html
|
203
|
+
index: 5
|
204
|
+
link: name:
|
205
|
+
id: link_id
|
206
|
+
href: links1.HTML
|
207
|
+
index: 6
|
208
|
+
link: name: link_name
|
209
|
+
id:
|
210
|
+
href: links1.HTML
|
211
|
+
index: 7
|
212
|
+
link: name:
|
213
|
+
id:
|
214
|
+
href: links1.HTML
|
215
|
+
index: 8
|
216
|
+
link: name:
|
217
|
+
id:
|
218
|
+
href: pass.html
|
219
|
+
index: 9
|
220
|
+
link: name:
|
221
|
+
id: linktos
|
222
|
+
href: link_pass.html
|
223
|
+
index: 10
|
224
|
+
link: name: test_link
|
225
|
+
id:
|
226
|
+
href: link1.html
|
227
|
+
index: 11
|
228
|
+
END_OF_MESSAGE
|
229
|
+
end
|
230
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# feature tests for Links
|
2
|
+
# revision: $Revision: 1.0 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_Links_XPath < Test::Unit::TestCase
|
8
|
+
include FireWatir
|
9
|
+
|
10
|
+
def setup()
|
11
|
+
$ff.goto($htmlRoot + "links1.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def xtest_new_link_exists
|
15
|
+
assert(exists?{$ff.link(:xpath , "//a[contains(.,'test1')]")})
|
16
|
+
assert(exists?{$ff.link(:xpath, "//a[contains(., /TEST/i)]")})
|
17
|
+
assert_false(exists?{$ff.link(:xpath , "//a[contains(.,'missing')]")})
|
18
|
+
assert_false(exists?{$ff.link(:xpath, "//a[contains(., /miss/)]")})
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_element_by_xpath_class
|
22
|
+
# TODO: If element is not present this should return null
|
23
|
+
#element = $ff.element_by_xpath("//a[contains(., /miss/)]")
|
24
|
+
#assert(element.instance_of?(Link),"element class should be #{Link}; got #{element.class}")
|
25
|
+
#element = $ff.element_by_xpath("//a[contains(.,'missing')]")
|
26
|
+
#assert(element.instance_of?(Link),"element class should be #{Link}; got #{element.class}")
|
27
|
+
element = $ff.element_by_xpath("//a[contains(., /TEST/i)]")
|
28
|
+
assert(element.instance_of?(Link),"element class should be #{Link}; got #{element.class}")
|
29
|
+
element = $ff.element_by_xpath("//a[contains(.,'test1')]")
|
30
|
+
assert(element.instance_of?(Link),"element class should be #{Link}; got #{element.class}")
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_element_by_xpath_behavior
|
34
|
+
# TODO implement this, acquiring objects through element_by_xpath and
|
35
|
+
# then testing their properties to see if they behave normally, as if
|
36
|
+
# they had been created with $ff.link
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_Link_Exists
|
40
|
+
assert($ff.link(:xpath , "//a[contains(.,'test1')]").exists?)
|
41
|
+
assert($ff.link(:xpath, "//a[contains(., /TEST/i)]").exists?)
|
42
|
+
assert_false($ff.link(:xpath , "//a[contains(.,'missing')]").exists?)
|
43
|
+
|
44
|
+
assert_false($ff.link(:xpath , "//a[@url='alsomissing.html']").exists?)
|
45
|
+
|
46
|
+
assert($ff.link(:xpath , "//a[@id='link_id']").exists?)
|
47
|
+
assert_false($ff.link(:xpath , "//a[@id='alsomissing']").exists?)
|
48
|
+
|
49
|
+
assert($ff.link(:xpath , "//a[@name='link_name']").exists?)
|
50
|
+
assert_false($ff.link(:xpath , "//a[@name='alsomissing']").exists?)
|
51
|
+
assert($ff.link(:xpath , "//a[@title='link_title']").exists?)
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_Link_click
|
56
|
+
$ff.link(:xpath , "//a[contains(.,'test1')]").click
|
57
|
+
assert( $ff.text.include?("Links2-Pass") )
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_link_properties
|
61
|
+
|
62
|
+
assert_match( /links2/ ,$ff.link(:xpath , "//a[contains(.,'test1')]").href )
|
63
|
+
assert_equal( "" , $ff.link(:xpath , "//a[contains(.,'test1')]").value)
|
64
|
+
assert_equal( "test1" , $ff.link(:xpath , "//a[contains(.,'test1')]").text )
|
65
|
+
assert_equal( "" , $ff.link(:xpath , "//a[contains(.,'test1')]").name )
|
66
|
+
assert_equal( "" , $ff.link(:xpath , "//a[contains(.,'test1')]").id )
|
67
|
+
#assert_equal( false , $ff.link(:xpath , "//a[contains(.,'test1')]").disabled )
|
68
|
+
assert_equal( "" , $ff.link(:xpath , "//a[contains(.,'test1')]").class_name)
|
69
|
+
assert_equal( "link_class_1" , $ff.link(:xpath , "//a[@class='link_class_1']").class_name)
|
70
|
+
|
71
|
+
assert_equal( "link_id" , $ff.link(:xpath , "//a[@id='link_id']").id )
|
72
|
+
assert_equal( "link_name" , $ff.link(:xpath , "//a[@name='link_name']").name )
|
73
|
+
|
74
|
+
assert_equal( "" , $ff.link(:xpath , "//a[@name='link_name']").title)
|
75
|
+
|
76
|
+
assert_equal( "link_title" , $ff.link(:xpath , "//a[@title='link_title']").title)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# these are the tests that run reliably and invisibly
|
2
|
+
|
3
|
+
TOPDIR = File.join(File.dirname(__FILE__), '..')
|
4
|
+
$LOAD_PATH.unshift TOPDIR
|
5
|
+
|
6
|
+
require 'unittests/setup.rb'
|
7
|
+
|
8
|
+
Dir.chdir TOPDIR
|
9
|
+
|
10
|
+
#tests = ["unittests/test.rb",
|
11
|
+
# "unittests/test_xpath.rb"
|
12
|
+
# ]
|
13
|
+
|
14
|
+
#tests.each { |x| require x }
|
15
|
+
$core_tests.each {|x| require x }
|
16
|
+
|
17
|
+
#$HIDE_IE = true
|
18
|
+
#$ff.visible = false
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# feature tests for Pre
|
2
|
+
# revision: $Revision: 1.0 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_Pre < Test::Unit::TestCase
|
8
|
+
include FireWatir
|
9
|
+
|
10
|
+
def setup
|
11
|
+
$ff.goto($htmlRoot + "pre.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_Pre_Count
|
15
|
+
assert( $ff.pres.length == 3 )
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_Pre_Exists
|
19
|
+
assert(! $ff.pre( :id, 'missingPre' ).exists? )
|
20
|
+
assert(! $ff.pre( :index, 33 ).exists? )
|
21
|
+
|
22
|
+
assert( $ff.pre( :id, '1' ).exists? )
|
23
|
+
assert( $ff.pre( :id, /[3-9]/ ).exists? )
|
24
|
+
|
25
|
+
assert(! $ff.pre( :id, /missing_pre/ ).exists? )
|
26
|
+
|
27
|
+
assert( $ff.pre( :index, 1 ).exists? )
|
28
|
+
assert( $ff.pre( :index, 2 ).exists? )
|
29
|
+
assert( $ff.pre( :index, 3 ).exists? )
|
30
|
+
|
31
|
+
assert( $ff.pre( :name, '3' ).exists? )
|
32
|
+
assert(! $ff.pre( :name, "name_missing" ).exists? )
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_simple_access
|
36
|
+
pre = $ff.pre( :index, 1 )
|
37
|
+
assert( pre.text.include?( "simple pre space" ) )
|
38
|
+
assert(! pre.text.include?( "A second block" ) )
|
39
|
+
|
40
|
+
pre = $ff.pre( :index, 2 )
|
41
|
+
assert( pre.text.include?( "A second block" ) )
|
42
|
+
assert(! pre.text.include?( "this is the last block" ) )
|
43
|
+
|
44
|
+
pre = $ff.pre( :index, 3 )
|
45
|
+
assert( pre.text.include?( "continue to work" ) )
|
46
|
+
assert(! pre.text.include?( "Pre Tag Test" ) )
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
class TC_Pres_Display < Test::Unit::TestCase
|
54
|
+
include FireWatir
|
55
|
+
include MockStdoutTestCase
|
56
|
+
|
57
|
+
def test_showPres
|
58
|
+
$ff.goto($htmlRoot + "pre.html")
|
59
|
+
$stdout = @mockout
|
60
|
+
$ff.showPres
|
61
|
+
assert_equal(<<END_OF_MESSAGE, @mockout)
|
62
|
+
There are 3 pres
|
63
|
+
pre: id: 1
|
64
|
+
name: 1
|
65
|
+
index: 1
|
66
|
+
pre: id: 2
|
67
|
+
name: 2
|
68
|
+
index: 2
|
69
|
+
pre: id: 3
|
70
|
+
name: 3
|
71
|
+
index: 3
|
72
|
+
END_OF_MESSAGE
|
73
|
+
end
|
74
|
+
end
|
@@ -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__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_Radios < Test::Unit::TestCase
|
8
|
+
include FireWatir
|
9
|
+
|
10
|
+
def setup()
|
11
|
+
$ff.goto($htmlRoot + "radioButtons1.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_Radio_Exists
|
15
|
+
assert($ff.radio(:name, "box1").exists?)
|
16
|
+
assert($ff.radio(:id, "box5").exists?)
|
17
|
+
|
18
|
+
assert_false($ff.radio(:name, "missingname").exists?)
|
19
|
+
assert_false($ff.radio(:id, "missingid").exists?)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_radio_class
|
23
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:name, "noName").class_name }
|
24
|
+
assert_equal("radio_style" , $ff.radio(:name, "box1").class_name)
|
25
|
+
assert_equal("" , $ff.radio(:id, "box5").class_name)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_Radio_Enabled
|
29
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:name, "noName").enabled? }
|
30
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:id, "noName").enabled? }
|
31
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:name, "box4" , 6).enabled? }
|
32
|
+
|
33
|
+
assert_false($ff.radio(:name, "box2").enabled?)
|
34
|
+
assert($ff.radio(:id, "box5").enabled?)
|
35
|
+
assert($ff.radio(:name, "box1").enabled?)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_little
|
39
|
+
assert_false($ff.button(:value , "foo").enabled?)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_onClick
|
43
|
+
|
44
|
+
assert_false($ff.radio(:name, "box5").isSet?)
|
45
|
+
assert_false($ff.button(:value , "foo").enabled?)
|
46
|
+
|
47
|
+
# first click the button is enabled and the radio is set
|
48
|
+
$ff.radio(:name, "box5" , 1).click
|
49
|
+
assert($ff.radio(:name, "box5",1).isSet?)
|
50
|
+
#assert($ff.button(:value , "foo").enabled?)
|
51
|
+
|
52
|
+
# second click the button is disabled and the radio is still set
|
53
|
+
$ff.radio(:name, "box5", 1).click
|
54
|
+
assert($ff.radio(:name, "box5",1).isSet?)
|
55
|
+
assert_false($ff.button(:value , "foo").enabled?)
|
56
|
+
|
57
|
+
# third click the button is enabled and the radio is still set
|
58
|
+
$ff.radio(:name, "box5", 1).click
|
59
|
+
assert($ff.radio(:name, "box5",1 ).isSet?)
|
60
|
+
assert($ff.button(:value , "foo").enabled?)
|
61
|
+
|
62
|
+
# click the radio with a value of 2 , button is disabled and the radio is still set
|
63
|
+
$ff.radio(:name, "box5", 2).click
|
64
|
+
assert_false($ff.radio(:name, "box5" ,1).isSet?)
|
65
|
+
assert($ff.radio(:name, "box5" ,2).isSet?)
|
66
|
+
assert_false($ff.button(:value , "foo").enabled?)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_Radio_isSet
|
70
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:name, "noName").isSet? }
|
71
|
+
|
72
|
+
assert_false($ff.radio(:name, "box1").isSet?)
|
73
|
+
assert( $ff.radio(:name, "box3").isSet?)
|
74
|
+
assert_false($ff.radio(:name, "box2").isSet?)
|
75
|
+
assert( $ff.radio(:name, "box4" , 1 ).isSet?)
|
76
|
+
assert_false($ff.radio(:name, "box4" , 2 ).isSet?)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_radio_clear
|
80
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:name, "noName").clear }
|
81
|
+
|
82
|
+
$ff.radio(:name, "box1").clear
|
83
|
+
assert_false($ff.radio(:name, "box1").isSet?)
|
84
|
+
|
85
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ff.radio(:name, "box2").clear }
|
86
|
+
assert_false($ff.radio(:name, "box2").isSet?)
|
87
|
+
|
88
|
+
$ff.radio(:name, "box3").clear
|
89
|
+
assert_false($ff.radio(:name, "box3").isSet?)
|
90
|
+
|
91
|
+
$ff.radio(:name, "box4" , 1).clear
|
92
|
+
assert_false($ff.radio(:name, "box4" , 1).isSet?)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_radio_getState
|
96
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:name, "noName").getState }
|
97
|
+
|
98
|
+
assert_equal( false , $ff.radio(:name, "box1").getState )
|
99
|
+
assert_equal( true , $ff.radio(:name, "box3").getState)
|
100
|
+
|
101
|
+
# radioes that have the same name but different values
|
102
|
+
assert_equal( false , $ff.radio(:name, "box4" , 2).getState )
|
103
|
+
assert_equal( true , $ff.radio(:name, "box4" , 1).getState)
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_radio_set
|
107
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:name, "noName").set }
|
108
|
+
$ff.radio(:name, "box1").set
|
109
|
+
assert($ff.radio(:name, "box1").isSet?)
|
110
|
+
|
111
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ff.radio(:name, "box2").set }
|
112
|
+
|
113
|
+
$ff.radio(:name, "box3").set
|
114
|
+
assert($ff.radio(:name, "box3").isSet?)
|
115
|
+
|
116
|
+
# radioes that have the same name but different values
|
117
|
+
$ff.radio(:name, "box4" , 3).set
|
118
|
+
assert($ff.radio(:name, "box4" , 3).isSet?)
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_radio_properties
|
122
|
+
|
123
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:index, 199).value}
|
124
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:index, 199).name }
|
125
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:index, 199).id }
|
126
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:index, 199).disabled }
|
127
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:index, 199).type }
|
128
|
+
|
129
|
+
assert_equal("on" , $ff.radio(:index, 1).value)
|
130
|
+
assert_equal("box1" , $ff.radio(:index, 1).name )
|
131
|
+
assert_equal("" , $ff.radio(:index, 1).id )
|
132
|
+
assert_equal("radio", $ff.radio(:index, 1).type )
|
133
|
+
|
134
|
+
assert_equal( false, $ff.radio(:index, 1).disabled )
|
135
|
+
assert_equal( true, $ff.radio(:index, 3).disabled )
|
136
|
+
|
137
|
+
assert_equal("box5" , $ff.radio(:index, 2).id )
|
138
|
+
assert_equal("" , $ff.radio(:index, 2).name )
|
139
|
+
|
140
|
+
assert_equal("box4-value5", $ff.radio(:name , "box4" , 5 ).title )
|
141
|
+
assert_equal("", $ff.radio(:name , "box4" , 4 ).title )
|
142
|
+
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_radio_iterators
|
147
|
+
|
148
|
+
assert_equal(11, $ff.radios.length)
|
149
|
+
assert_equal("box5" , $ff.radios[2].id )
|
150
|
+
assert_equal(true , $ff.radios[3].disabled )
|
151
|
+
assert_equal(false , $ff.radios[1].disabled )
|
152
|
+
index = 1
|
153
|
+
$ff.radios.each do |r|
|
154
|
+
assert_equal( $ff.radio(:index, index).name , r.name )
|
155
|
+
assert_equal( $ff.radio(:index, index).id , r.id )
|
156
|
+
assert_equal( $ff.radio(:index, index).value, r.value)
|
157
|
+
assert_equal( $ff.radio(:index, index).disabled , r.disabled )
|
158
|
+
assert_equal( $ff.radio(:index, index).isSet? , r.isSet? )
|
159
|
+
index+=1
|
160
|
+
end
|
161
|
+
assert_equal(index -1, $ff.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__), '..') if $0 == __FILE__
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_Radios_XPath < Test::Unit::TestCase
|
8
|
+
include FireWatir
|
9
|
+
|
10
|
+
def setup()
|
11
|
+
$ff.goto($htmlRoot + "radioButtons1.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_Radio_Exists
|
15
|
+
assert($ff.radio(:xpath, "//input[@name='box1']").exists?)
|
16
|
+
assert($ff.radio(:xpath, "//input[@id='box5']").exists?)
|
17
|
+
|
18
|
+
assert_false($ff.radio(:xpath, "//input[@name='missingname']").exists?)
|
19
|
+
assert_false($ff.radio(:xpath, "//input[@id='missingid']").exists?)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_Radio_Enabled
|
23
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@name='noName']").enabled? }
|
24
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@id='noName']").enabled? }
|
25
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@name='box4' and @value='6']").enabled? }
|
26
|
+
|
27
|
+
assert_false($ff.radio(:xpath, "//input[@name='box2']").enabled?)
|
28
|
+
assert($ff.radio(:xpath, "//input[@id='box5']").enabled?)
|
29
|
+
assert($ff.radio(:xpath, "//input[@name='box1']").enabled?)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_little
|
33
|
+
assert_false($ff.button(:xpath,"//input[@name='foo']").enabled?)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_onClick
|
37
|
+
assert_false($ff.button(:xpath,"//input[@name='foo']").enabled?)
|
38
|
+
$ff.radio(:xpath, "//input[@name='box5' and @value='1']").set
|
39
|
+
assert($ff.button(:xpath,"//input[@name='foo']").enabled?)
|
40
|
+
|
41
|
+
$ff.radio(:xpath, "//input[@name='box5' and @value='2']").set
|
42
|
+
assert_false($ff.button(:xpath,"//input[@name='foo']").enabled?)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_Radio_isSet
|
46
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@name='noName']").isSet? }
|
47
|
+
|
48
|
+
puts "radio 1 is set : #{ $ff.radio(:xpath, "//input[@name='box1']").isSet? } "
|
49
|
+
assert_false($ff.radio(:xpath, "//input[@name='box1']").isSet?)
|
50
|
+
|
51
|
+
assert($ff.radio(:xpath, "//input[@name='box3']").isSet?)
|
52
|
+
assert_false($ff.radio(:xpath, "//input[@name='box2']").isSet?)
|
53
|
+
|
54
|
+
assert( $ff.radio(:xpath, "//input[@name='box4' and @value='1']").isSet?)
|
55
|
+
assert_false($ff.radio(:xpath, "//input[@name='box4' and @value='2']").isSet?)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_radio_clear
|
59
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@name='noName']").clear }
|
60
|
+
|
61
|
+
$ff.radio(:xpath, "//input[@name='box1']").clear
|
62
|
+
assert_false($ff.radio(:xpath, "//input[@name='box1']").isSet?)
|
63
|
+
|
64
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@name='box2']").clear }
|
65
|
+
assert_false($ff.radio(:xpath, "//input[@name='box2']").isSet?)
|
66
|
+
|
67
|
+
$ff.radio(:xpath, "//input[@name='box3']").clear
|
68
|
+
assert_false($ff.radio(:xpath, "//input[@name='box3']").isSet?)
|
69
|
+
|
70
|
+
$ff.radio(:xpath, "//input[@name='box4' and @value='1']").clear
|
71
|
+
assert_false($ff.radio(:xpath, "//input[@name='box4' and @value='1']").isSet?)
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_radio_getState
|
75
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@name='noName']").getState }
|
76
|
+
|
77
|
+
assert_equal( false , $ff.radio(:xpath, "//input[@name='box1']").getState )
|
78
|
+
assert_equal( true , $ff.radio(:xpath, "//input[@name='box3']").getState)
|
79
|
+
|
80
|
+
# radioes that have the same name but different values
|
81
|
+
assert_equal( false , $ff.radio(:xpath, "//input[@name='box4' and @value='2']").getState )
|
82
|
+
assert_equal( true , $ff.radio(:xpath, "//input[@name='box4' and @value='1']").getState)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_radio_set
|
86
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@name='noName']").set }
|
87
|
+
$ff.radio(:xpath, "//input[@name='box1']").set
|
88
|
+
assert($ff.radio(:xpath, "//input[@name='box1']").isSet?)
|
89
|
+
|
90
|
+
assert_raises(ObjectDisabledException, "ObjectDisabledException was supposed to be thrown" ) { $ff.radio(:xpath, "//input[@name='box2']").set }
|
91
|
+
|
92
|
+
$ff.radio(:xpath, "//input[@name='box3']").set
|
93
|
+
assert($ff.radio(:xpath, "//input[@name='box3']").isSet?)
|
94
|
+
|
95
|
+
# radioes that have the same name but different values
|
96
|
+
$ff.radio(:xpath, "//input[@name='box4' and @value='3']").set
|
97
|
+
assert($ff.radio(:xpath, "//input[@name='box4' and @value='3']").isSet?)
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|