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,75 @@
|
|
1
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
2
|
+
require 'unittests/setup'
|
3
|
+
|
4
|
+
class TC_JavaScript_Test < Test::Unit::TestCase
|
5
|
+
|
6
|
+
# include FireWatir::Dialog
|
7
|
+
|
8
|
+
def setup
|
9
|
+
goto_page 'JavascriptClick.html'
|
10
|
+
end
|
11
|
+
|
12
|
+
tag_method :test_alert, :fails_on_ie
|
13
|
+
def test_alert
|
14
|
+
#browser.button(:id, "btnAlert").click_no_wait()
|
15
|
+
|
16
|
+
#browser.click_jspopup_button("OK")
|
17
|
+
browser.startClicker("ok", 1, '', "Press OK")
|
18
|
+
browser.button(:id, "btnAlert").click
|
19
|
+
|
20
|
+
assert_equal(browser.text_field(:id, "testResult").value , "You pressed the Alert button!")
|
21
|
+
assert_equal("Press OK", browser.get_popup_text)
|
22
|
+
|
23
|
+
browser.startClicker("ok")
|
24
|
+
browser.button(:id, "btnAlert").click
|
25
|
+
|
26
|
+
assert_equal(browser.text_field(:id, "testResult").value , "You pressed the Alert button!")
|
27
|
+
assert_equal("Press OK", browser.get_popup_text)
|
28
|
+
end
|
29
|
+
|
30
|
+
tag_method :test_confirm_ok, :fails_on_ie
|
31
|
+
def test_confirm_ok
|
32
|
+
#browser.button(:id, "btnConfirm").click_no_wait()
|
33
|
+
|
34
|
+
#browser.click_jspopup_button("OK")
|
35
|
+
browser.startClicker("ok", 1, '', "Press a button")
|
36
|
+
browser.button(:id, "btnConfirm").click
|
37
|
+
|
38
|
+
assert_equal(browser.text_field(:id, "testResult").value , "You pressed the Confirm and OK button!")
|
39
|
+
assert_equal("Press a button", browser.get_popup_text)
|
40
|
+
|
41
|
+
browser.startClicker("ok")
|
42
|
+
browser.button(:id, "btnConfirm").click
|
43
|
+
|
44
|
+
assert_equal(browser.text_field(:id, "testResult").value , "You pressed the Confirm and OK button!")
|
45
|
+
assert_equal("Press a button", browser.get_popup_text)
|
46
|
+
end
|
47
|
+
|
48
|
+
tag_method :test_confirm_cancel, :fails_on_ie
|
49
|
+
def test_confirm_cancel
|
50
|
+
#browser.button(:id, "btnConfirm").click_no_wait()
|
51
|
+
|
52
|
+
#browser.click_jspopup_button("Cancel")
|
53
|
+
browser.startClicker("cancel", 1, '', "Press a button")
|
54
|
+
browser.button(:id, "btnConfirm").click
|
55
|
+
|
56
|
+
assert_equal(browser.text_field(:id, "testResult").value, "You pressed the Confirm and Cancel button!")
|
57
|
+
assert_equal("Press a button", browser.get_popup_text)
|
58
|
+
|
59
|
+
browser.startClicker("cancel")
|
60
|
+
browser.button(:id, "btnConfirm").click
|
61
|
+
|
62
|
+
assert_equal(browser.text_field(:id, "testResult").value, "You pressed the Confirm and Cancel button!")
|
63
|
+
assert_equal("Press a button", browser.get_popup_text)
|
64
|
+
end
|
65
|
+
|
66
|
+
tag_method :test_ok_selectbox, :fails_on_ie
|
67
|
+
def test_ok_selectbox
|
68
|
+
goto_page("selectboxes1.html")
|
69
|
+
browser.startClicker("ok")
|
70
|
+
browser.select_list(:id , "selectbox_5").select_value(/2/)
|
71
|
+
|
72
|
+
assert_equal(browser.text_field(:id, "txtAlert").value , "You pressed OK button")
|
73
|
+
assert_equal("Press OK", browser.get_popup_text)
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,231 @@
|
|
1
|
+
# feature tests for Links
|
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_Links < Test::Unit::TestCase
|
8
|
+
|
9
|
+
|
10
|
+
def setup()
|
11
|
+
goto_page("links1.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_new_link_exists
|
15
|
+
assert(browser.link(:text, "test1").exists?)
|
16
|
+
assert(browser.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
|
+
tag_method :test_bad_attribute, :fails_on_ie
|
22
|
+
def test_bad_attribute
|
23
|
+
assert_raises(UnknownObjectException) { browser.link(:bad_attribute, 199).click }
|
24
|
+
begin
|
25
|
+
browser.link(:bad_attribute, 199).click
|
26
|
+
rescue UnknownObjectException => e
|
27
|
+
assert_equal "Unable to locate element, using :bad_attribute, 199", e.to_s
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_missing_links_dont_exist
|
32
|
+
assert_false(browser.link(:text, "missing").exists?)
|
33
|
+
assert_false(browser.link(:text, /miss/).exists?)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_link_Exists
|
37
|
+
assert(browser.link(:text, "test1").exists?)
|
38
|
+
assert(browser.link(:text, /TEST/i).exists?)
|
39
|
+
assert_false(browser.link(:text, "missing").exists?)
|
40
|
+
assert_false(browser.link(:text, /miss/).exists?)
|
41
|
+
|
42
|
+
# this assert we have to build up the path
|
43
|
+
# this is what it looks like if you do a to_s on the link file:///C:/watir_bonus/unitTests/html/links1.HTML
|
44
|
+
# but what we get back from $htmlRoot is a mixed case, so its almost impossible for use to test this correctly
|
45
|
+
# assert(browser.link(:url,'file:///C:/watir_bonus/unitTests/html/links1.HTML' ).exists?)
|
46
|
+
|
47
|
+
assert(browser.link(:url, /link_pass.html/).exists?)
|
48
|
+
assert_false(browser.link(:url, "alsomissing.html").exists?)
|
49
|
+
|
50
|
+
assert(browser.link(:id, "link_id").exists?)
|
51
|
+
assert_false(browser.link(:id, "alsomissing").exists?)
|
52
|
+
|
53
|
+
assert(browser.link(:id, /_id/).exists?)
|
54
|
+
assert_false(browser.link(:id, /alsomissing/).exists?)
|
55
|
+
|
56
|
+
assert(browser.link(:name, "link_name").exists?)
|
57
|
+
assert_false(browser.link(:name, "alsomissing").exists?)
|
58
|
+
|
59
|
+
assert(browser.link(:name, /_n/).exists?)
|
60
|
+
assert_false(browser.link(:name, /missing/).exists?)
|
61
|
+
|
62
|
+
assert(browser.link(:title, /ti/).exists?)
|
63
|
+
assert(browser.link(:title, "link_title").exists?)
|
64
|
+
|
65
|
+
assert_false(browser.link(:title, /missing/).exists?)
|
66
|
+
|
67
|
+
assert(browser.link(:url, /_pass/).exists?)
|
68
|
+
assert_false(browser.link(:url, /dont_exist/).exists?)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_link_click
|
72
|
+
browser.link(:text, "test1").click
|
73
|
+
assert( browser.text.include?("Links2-Pass") )
|
74
|
+
end
|
75
|
+
def test_link2_click
|
76
|
+
browser.link(:url, /link_pass.html/).click
|
77
|
+
assert( browser.text.include?("Links3-Pass") )
|
78
|
+
end
|
79
|
+
def test_link3_click
|
80
|
+
browser.link(:index, 1).click
|
81
|
+
assert( browser.text.include?("Links2-Pass") )
|
82
|
+
end
|
83
|
+
def test_link4_click
|
84
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).click }
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_link_properties
|
88
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).href }
|
89
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).value}
|
90
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).text }
|
91
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).name }
|
92
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).id }
|
93
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).disabled }
|
94
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).type }
|
95
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).class_name }
|
96
|
+
|
97
|
+
assert_match( /links2/ ,browser.link(:index, 1).href )
|
98
|
+
assert_equal( "" , browser.link(:index, 1).value)
|
99
|
+
assert_equal( "test1" , browser.link(:index, 1).text )
|
100
|
+
assert_equal( "" , browser.link(:index, 1).name )
|
101
|
+
assert_equal( "" , browser.link(:index, 1).id )
|
102
|
+
assert_equal( false , browser.link(:index, 1).disabled )
|
103
|
+
assert_equal( "" , browser.link(:index, 1).class_name)
|
104
|
+
assert_equal( "link_class_1" , browser.link(:index, 2).class_name)
|
105
|
+
|
106
|
+
assert_equal( "link_id" , browser.link(:index, 6).id )
|
107
|
+
assert_equal( "link_name" , browser.link(:index, 7).name )
|
108
|
+
|
109
|
+
assert_equal( "" , browser.link(:index, 7).title)
|
110
|
+
|
111
|
+
assert_equal( "link_title" , browser.link(:index, 8).title)
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_text_attribute
|
115
|
+
arr1 = browser.link(:text, "nameDelet").to_s
|
116
|
+
arr2 = browser.link(:text, /Delet/).to_s
|
117
|
+
assert_equal(arr1, arr2)
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_link_iterator
|
122
|
+
assert_equal(11, browser.links.length )
|
123
|
+
assert_equal("Link Using a name" , browser.links[7].text)
|
124
|
+
|
125
|
+
index = 1
|
126
|
+
browser.links.each do |link|
|
127
|
+
assert_equal( browser.link(:index, index).href , link.href )
|
128
|
+
assert_equal( browser.link(:index, index).id , link.id )
|
129
|
+
assert_equal( browser.link(:index, index).name , link.name )
|
130
|
+
assert_equal( browser.link(:index, index).innerText , link.text )
|
131
|
+
index+=1
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_div_xml_bug
|
136
|
+
goto_page("div_xml.html")
|
137
|
+
assert_nothing_raised {browser.link(:text, 'Create').exists? }
|
138
|
+
end
|
139
|
+
def test_link_to_s
|
140
|
+
puts browser.link(:id,"linktos").to_s
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
class TC_Frame_Links < Test::Unit::TestCase
|
145
|
+
|
146
|
+
|
147
|
+
def setup()
|
148
|
+
goto_page("frame_links.html")
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_new_frame_link_exists
|
152
|
+
assert(browser.frame("buttonFrame").link(:text, "test1").exists?)
|
153
|
+
end
|
154
|
+
def test_missing_frame_links_dont_exist
|
155
|
+
assert_false(browser.frame("buttonFrame").link(:text, "missing").exists?)
|
156
|
+
assert_raise(UnknownFrameException, "UnknownFrameException was supposed to be thrown"){browser.frame("missing").link(:text, "test1").exists?}
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_links_in_frames
|
160
|
+
assert(browser.frame("buttonFrame").link(:text, "test1").exists?)
|
161
|
+
assert_false(browser.frame("buttonFrame").link(:text, "missing").exists?)
|
162
|
+
|
163
|
+
assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) { browser.frame("buttonFrame").link(:index, 199).href }
|
164
|
+
assert_match(/links2/, browser.frame("buttonFrame").link(:index, 1).href)
|
165
|
+
|
166
|
+
count =0
|
167
|
+
browser.frame("buttonFrame").links.each do |l|
|
168
|
+
count+=1
|
169
|
+
end
|
170
|
+
|
171
|
+
assert_equal(11 , count)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
class TC_Links_Display < Test::Unit::TestCase
|
176
|
+
|
177
|
+
include CaptureIOHelper
|
178
|
+
|
179
|
+
tag_method :test_showLinks, :fails_on_ie
|
180
|
+
def test_showLinks
|
181
|
+
goto_page("links1.html")
|
182
|
+
actual = capture_stdout { browser.showLinks }
|
183
|
+
assert_equal(<<END_OF_MESSAGE, actual)
|
184
|
+
There are 11 links
|
185
|
+
link: name:
|
186
|
+
id:
|
187
|
+
href: links2.html
|
188
|
+
index: 1
|
189
|
+
link: name:
|
190
|
+
id:
|
191
|
+
href: link_pass.html
|
192
|
+
index: 2
|
193
|
+
link: name:
|
194
|
+
id:
|
195
|
+
href: pass3.html
|
196
|
+
index: 3
|
197
|
+
link: name:
|
198
|
+
id:
|
199
|
+
href: textarea.html
|
200
|
+
index: 4
|
201
|
+
link: name:
|
202
|
+
id:
|
203
|
+
href: textarea.html
|
204
|
+
index: 5
|
205
|
+
link: name:
|
206
|
+
id: link_id
|
207
|
+
href: links1.HTML
|
208
|
+
index: 6
|
209
|
+
link: name: link_name
|
210
|
+
id:
|
211
|
+
href: links1.HTML
|
212
|
+
index: 7
|
213
|
+
link: name:
|
214
|
+
id:
|
215
|
+
href: links1.HTML
|
216
|
+
index: 8
|
217
|
+
link: name:
|
218
|
+
id:
|
219
|
+
href: pass.html
|
220
|
+
index: 9
|
221
|
+
link: name:
|
222
|
+
id: linktos
|
223
|
+
href: link_pass.html
|
224
|
+
index: 10
|
225
|
+
link: name: test_link
|
226
|
+
id:
|
227
|
+
href: link1.html
|
228
|
+
index: 11
|
229
|
+
END_OF_MESSAGE
|
230
|
+
end
|
231
|
+
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__), '..') unless $SETUP_LOADED
|
5
|
+
require 'unittests/setup'
|
6
|
+
|
7
|
+
class TC_Links_XPath < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup()
|
10
|
+
goto_page("links1.html")
|
11
|
+
end
|
12
|
+
|
13
|
+
def xtest_new_link_exists
|
14
|
+
assert(exists?{browser.link(:xpath , "//a[contains(.,'test1')]")})
|
15
|
+
assert(exists?{browser.link(:xpath, "//a[contains(., /TEST/i)]")})
|
16
|
+
assert_false(exists?{browser.link(:xpath , "//a[contains(.,'missing')]")})
|
17
|
+
assert_false(exists?{browser.link(:xpath, "//a[contains(., /miss/)]")})
|
18
|
+
end
|
19
|
+
|
20
|
+
tag_method :test_element_by_xpath_class, :fails_on_ie
|
21
|
+
def test_element_by_xpath_class
|
22
|
+
# TODO: If element is not present this should return null
|
23
|
+
#element = browser.element_by_xpath("//a[contains(., /miss/)]")
|
24
|
+
#assert(element.instance_of?(Link),"element class should be #{Link}; got #{element.class}")
|
25
|
+
#element = browser.element_by_xpath("//a[contains(.,'missing')]")
|
26
|
+
#assert(element.instance_of?(Link),"element class should be #{Link}; got #{element.class}")
|
27
|
+
element = browser.element_by_xpath("//a[contains(., /TEST/i)]")
|
28
|
+
assert_class(element, 'Link')
|
29
|
+
element = browser.element_by_xpath("//a[contains(.,'test1')]")
|
30
|
+
assert_class(element, 'Link')
|
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 browser.link
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_Link_Exists
|
40
|
+
assert(browser.link(:xpath , "//a[contains(.,'test1')]").exists?)
|
41
|
+
assert(browser.link(:xpath, "//a[contains(., /TEST/i)]").exists?)
|
42
|
+
assert_false(browser.link(:xpath , "//a[contains(.,'missing')]").exists?)
|
43
|
+
|
44
|
+
assert_false(browser.link(:xpath , "//a[@url='alsomissing.html']").exists?)
|
45
|
+
|
46
|
+
assert(browser.link(:xpath , "//a[@id='link_id']").exists?)
|
47
|
+
assert_false(browser.link(:xpath , "//a[@id='alsomissing']").exists?)
|
48
|
+
|
49
|
+
assert(browser.link(:xpath , "//a[@name='link_name']").exists?)
|
50
|
+
assert_false(browser.link(:xpath , "//a[@name='alsomissing']").exists?)
|
51
|
+
assert(browser.link(:xpath , "//a[@title='link_title']").exists?)
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_Link_click
|
56
|
+
browser.link(:xpath , "//a[contains(.,'test1')]").click
|
57
|
+
assert( browser.text.include?("Links2-Pass") )
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_link_properties
|
61
|
+
|
62
|
+
assert_match( /links2/ ,browser.link(:xpath , "//a[contains(.,'test1')]").href )
|
63
|
+
assert_equal( "" , browser.link(:xpath , "//a[contains(.,'test1')]").value)
|
64
|
+
assert_equal( "test1" , browser.link(:xpath , "//a[contains(.,'test1')]").text )
|
65
|
+
assert_equal( "" , browser.link(:xpath , "//a[contains(.,'test1')]").name )
|
66
|
+
assert_equal( "" , browser.link(:xpath , "//a[contains(.,'test1')]").id )
|
67
|
+
assert_equal( false , browser.link(:xpath , "//a[contains(.,'test1')]").disabled )
|
68
|
+
assert_equal( "" , browser.link(:xpath , "//a[contains(.,'test1')]").class_name)
|
69
|
+
assert_equal( "link_class_1" , browser.link(:xpath , "//a[@class='link_class_1']").class_name)
|
70
|
+
|
71
|
+
assert_equal( "link_id" , browser.link(:xpath , "//a[@id='link_id']").id )
|
72
|
+
assert_equal( "link_name" , browser.link(:xpath , "//a[@name='link_name']").name )
|
73
|
+
|
74
|
+
assert_equal( "" , browser.link(:xpath , "//a[@name='link_name']").title)
|
75
|
+
|
76
|
+
assert_equal( "link_title" , browser.link(:xpath , "//a[@title='link_title']").title)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# feature tests for Pre
|
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_Pre < Test::Unit::TestCase
|
8
|
+
|
9
|
+
|
10
|
+
def setup
|
11
|
+
goto_page("pre.html")
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_Pre_Count
|
15
|
+
assert( browser.pres.length == 3 )
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_Pre_Exists
|
19
|
+
assert_false( browser.pre( :id, 'missingPre' ).exists? )
|
20
|
+
assert_false( browser.pre( :index, 33 ).exists? )
|
21
|
+
|
22
|
+
assert( browser.pre( :id, '1' ).exists? )
|
23
|
+
assert( browser.pre( :id, /[3-9]/ ).exists? )
|
24
|
+
|
25
|
+
assert_false( browser.pre( :id, /missing_pre/ ).exists? )
|
26
|
+
|
27
|
+
assert( browser.pre( :index, 1 ).exists? )
|
28
|
+
assert( browser.pre( :index, 2 ).exists? )
|
29
|
+
assert( browser.pre( :index, 3 ).exists? )
|
30
|
+
|
31
|
+
assert( browser.pre( :name, '3' ).exists? )
|
32
|
+
assert_false( browser.pre( :name, "name_missing" ).exists? )
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_simple_access
|
36
|
+
pre = browser.pre( :index, 1 )
|
37
|
+
assert( pre.text.include?( "simple pre space" ) )
|
38
|
+
assert_false( pre.text.include?( "A second block" ) )
|
39
|
+
|
40
|
+
pre = browser.pre( :index, 2 )
|
41
|
+
assert( pre.text.include?( "A second block" ) )
|
42
|
+
assert_false( pre.text.include?( "this is the last block" ) )
|
43
|
+
end
|
44
|
+
|
45
|
+
tag_method :test_embedded_spaces, :fails_on_firefox # http://jira.openqa.org/browse/WTR-267
|
46
|
+
def test_embedded_spaces
|
47
|
+
pre = browser.pre( :index, 3 )
|
48
|
+
assert( pre.text.include?( "continue to work" ) )
|
49
|
+
assert_false( pre.text.include?( "Pre Tag Test" ) )
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
class TC_Pres_Display < Test::Unit::TestCase
|
56
|
+
include CaptureIOHelper
|
57
|
+
|
58
|
+
tag_method :test_showPres, :fails_on_ie
|
59
|
+
def test_showPres
|
60
|
+
goto_page("pre.html")
|
61
|
+
actual = capture_stdout { browser.showPres }
|
62
|
+
assert_equal(<<END_OF_MESSAGE, actual)
|
63
|
+
There are 3 pres
|
64
|
+
pre: id: 1
|
65
|
+
name: 1
|
66
|
+
index: 1
|
67
|
+
pre: id: 2
|
68
|
+
name: 2
|
69
|
+
index: 2
|
70
|
+
pre: id: 3
|
71
|
+
name: 3
|
72
|
+
index: 3
|
73
|
+
END_OF_MESSAGE
|
74
|
+
end
|
75
|
+
end
|