firewatir 1.6.5 → 1.6.6.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +461 -0
- data/LICENSE +31 -31
- data/README.rdoc +112 -0
- data/VERSION +1 -0
- data/lib/firewatir.rb +41 -40
- data/lib/firewatir/container.rb +491 -491
- data/lib/firewatir/document.rb +239 -239
- data/lib/firewatir/element.rb +1364 -1364
- data/lib/firewatir/element_collections.rb +314 -314
- data/lib/firewatir/elements/button.rb +15 -15
- data/lib/firewatir/elements/file_field.rb +29 -29
- data/lib/firewatir/elements/form.rb +40 -40
- data/lib/firewatir/elements/frame.rb +55 -55
- data/lib/firewatir/elements/hidden.rb +56 -56
- data/lib/firewatir/elements/image.rb +139 -139
- data/lib/firewatir/elements/input_element.rb +44 -44
- data/lib/firewatir/elements/link.rb +76 -76
- data/lib/firewatir/elements/non_control_element.rb +53 -53
- data/lib/firewatir/elements/non_control_elements.rb +108 -108
- data/lib/firewatir/elements/not_used.rb +278 -278
- data/lib/firewatir/elements/option.rb +130 -130
- data/lib/firewatir/elements/radio_check_common.rb +163 -163
- data/lib/firewatir/elements/select_list.rb +188 -188
- data/lib/firewatir/elements/table.rb +218 -218
- data/lib/firewatir/elements/table_cell.rb +54 -54
- data/lib/firewatir/elements/table_row.rb +100 -100
- data/lib/firewatir/elements/text_field.rb +218 -218
- data/lib/firewatir/exceptions.rb +10 -10
- data/lib/firewatir/firefox.rb +984 -1040
- data/lib/firewatir/jssh_socket.rb +100 -100
- data/lib/firewatir/winClicker.rb +122 -122
- data/lib/firewatir/x11.rb +192 -192
- data/rakefile.rb +15 -0
- data/unittests/attach_to_new_window_test.rb +49 -49
- data/unittests/bug_fixes_test.rb +195 -195
- data/unittests/buttons_xpath_test.rb +88 -88
- data/unittests/checkbox_test.rb +158 -158
- data/unittests/checkbox_xpath_test.rb +107 -107
- data/unittests/div_test.rb +275 -275
- data/unittests/ff_test.rb +47 -0
- data/unittests/filefield_test.rb +49 -49
- data/unittests/filefield_xpath_test.rb +35 -35
- data/unittests/form_test.rb +296 -296
- data/unittests/frame_test.rb +159 -159
- data/unittests/hidden_test.rb +85 -85
- data/unittests/hidden_xpath_test.rb +72 -72
- data/unittests/html/JavascriptClick.html +42 -42
- data/unittests/html/blankpage.html +11 -11
- data/unittests/html/buttons1.html +61 -61
- data/unittests/html/checkboxes1.html +70 -70
- data/unittests/html/complex_table.html +36 -36
- data/unittests/html/cssTest.html +42 -42
- data/unittests/html/div.html +72 -72
- data/unittests/html/div_xml.html +20 -20
- data/unittests/html/fileupload.html +45 -45
- data/unittests/html/formTest1.html +38 -38
- data/unittests/html/forms2.html +45 -45
- data/unittests/html/forms3.html +132 -132
- data/unittests/html/forms4.html +27 -27
- data/unittests/html/frame_buttons.html +3 -3
- data/unittests/html/frame_links.html +3 -3
- data/unittests/html/frame_multi.html +4 -4
- data/unittests/html/iframeTest.html +14 -14
- data/unittests/html/iframeTest1.html +13 -13
- data/unittests/html/iframeTest2.html +5 -5
- data/unittests/html/images1.html +66 -66
- data/unittests/html/javascriptevents.html +35 -35
- data/unittests/html/link_pass.html +10 -10
- data/unittests/html/links1.html +42 -42
- data/unittests/html/links2.html +10 -10
- data/unittests/html/modal_dialog.html +8 -8
- data/unittests/html/modal_dialog_launcher.html +11 -11
- data/unittests/html/nestedFrames.html +6 -6
- data/unittests/html/new_browser.html +17 -17
- data/unittests/html/new_browser_popup.html +7 -7
- data/unittests/html/pass.html +9 -9
- data/unittests/html/popups1.html +60 -60
- data/unittests/html/pre.html +27 -27
- data/unittests/html/radioButtons1.html +70 -70
- data/unittests/html/redirect.html +10 -10
- data/unittests/html/redirect1.html +8 -8
- data/unittests/html/redirect2.html +8 -8
- data/unittests/html/redirect3.html +8 -8
- data/unittests/html/select_tealeaf.html +54 -54
- data/unittests/html/selectboxes1.html +55 -55
- data/unittests/html/simple_table.html +26 -26
- data/unittests/html/simple_table_buttons.html +104 -104
- data/unittests/html/simple_table_columns.html +74 -74
- data/unittests/html/table1.html +165 -165
- data/unittests/html/tableCell_using_xpath.html +19 -19
- data/unittests/html/textarea.html +30 -30
- data/unittests/html/textfields1.html +62 -62
- data/unittests/html/textsearch.html +44 -44
- data/unittests/images_test.rb +198 -198
- data/unittests/images_xpath_test.rb +118 -118
- data/unittests/javascript_test.rb +75 -75
- data/unittests/links_test.rb +231 -231
- data/unittests/links_xpath_test.rb +79 -79
- data/unittests/mozilla_all_tests.rb +7 -7
- data/unittests/pre_test.rb +75 -75
- data/unittests/radios_test.rb +166 -166
- data/unittests/radios_xpath_test.rb +101 -101
- data/unittests/redirect_test.rb +41 -41
- data/unittests/selectbox_test.rb +142 -142
- data/unittests/selectbox_xpath_test.rb +129 -129
- data/unittests/setup.rb +29 -29
- data/unittests/table_test.rb +385 -385
- data/unittests/table_xpath_test.rb +185 -185
- data/unittests/textfields_test.rb +234 -234
- data/unittests/textfields_xpath_test.rb +113 -113
- metadata +51 -19
- data/lib/firewatir/version.rb +0 -5
@@ -1,118 +1,118 @@
|
|
1
|
-
# feature tests for Images
|
2
|
-
# revision: $Revision: 1.0 $
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
|
-
require 'unittests/setup'
|
6
|
-
require 'webrick'
|
7
|
-
|
8
|
-
class TC_Images_XPath < Test::Unit::TestCase
|
9
|
-
|
10
|
-
|
11
|
-
def setup
|
12
|
-
gotoImagePage
|
13
|
-
end
|
14
|
-
|
15
|
-
def gotoImagePage()
|
16
|
-
goto_page("images1.html")
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_imageExists
|
20
|
-
assert_false( browser.image(:xpath , "//img[@name='missing_name']").exists? )
|
21
|
-
assert( browser.image(:xpath , "//img[@name='circle']").exists? )
|
22
|
-
assert( browser.image(:xpath , "//img[contains(@name , 'circ')]" ).exists? )
|
23
|
-
|
24
|
-
assert_false( browser.image(:xpath , "//img[@id='missing_id']").exists? )
|
25
|
-
assert( browser.image(:xpath , "//img[@id='square']").exists? )
|
26
|
-
assert( browser.image(:xpath , "//img[contains(@id, 'squ')]" ).exists? )
|
27
|
-
|
28
|
-
assert_false( browser.image(:xpath , "//img[@src='missingsrc.gif']").exists? )
|
29
|
-
|
30
|
-
# BP -- This fails for me but not for Paul. It doesn't make sense to me that it should pass.
|
31
|
-
# assert( browser.image(:src , "file:///#{$myDir}/html/images/triangle.jpg").exists? )
|
32
|
-
assert( browser.image(:xpath , "//img[contains(@src , 'triangle')]" ).exists? )
|
33
|
-
|
34
|
-
assert( browser.image(:alt , "circle" ).exists? )
|
35
|
-
assert( browser.image(:xpath , "//img[contains(@alt , 'cir')]" ).exists? )
|
36
|
-
|
37
|
-
assert_false( browser.image(:alt , "triangle" ).exists? )
|
38
|
-
assert_false( browser.image(:xpath , "//img[contains(@alt , 'tri')]" ).exists? )
|
39
|
-
end
|
40
|
-
|
41
|
-
tag_method :test_element_by_xpath_class, :fails_on_ie
|
42
|
-
def test_element_by_xpath_class
|
43
|
-
# FIXME getting HTMLAnchorElement instead of HTMLImageElement
|
44
|
-
# TODO: This should return null if object is not there.
|
45
|
-
#element = browser.element_by_xpath("//img[@name='missing_name']")
|
46
|
-
#assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
|
47
|
-
element = browser.element_by_xpath("//img[@name='circle']")
|
48
|
-
assert_class(element, 'Image')
|
49
|
-
element = browser.element_by_xpath("//img[contains(@name , 'circ')]")
|
50
|
-
assert_class(element, 'Image')
|
51
|
-
# TODO: This should return null if object is not there.
|
52
|
-
#element = browser.element_by_xpath("//img[@id='missing_id']")
|
53
|
-
#assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
|
54
|
-
element = browser.element_by_xpath("//img[@id='square']")
|
55
|
-
assert_class(element, 'Image')
|
56
|
-
element = browser.element_by_xpath("//img[contains(@id, 'squ')]")
|
57
|
-
assert_class(element, 'Image')
|
58
|
-
element = browser.element_by_xpath("//img[contains(@src , 'triangle')]")
|
59
|
-
assert_class(element, 'Image')
|
60
|
-
element = browser.element_by_xpath("//img[contains(@alt , 'cir')]")
|
61
|
-
assert_class(element, 'Image')
|
62
|
-
# TODO: This should return null if object is not there.
|
63
|
-
#element = browser.element_by_xpath("//img[contains(@alt , 'tri')]")
|
64
|
-
#assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_image_click
|
68
|
-
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']").click }
|
69
|
-
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']").click }
|
70
|
-
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']").click}
|
71
|
-
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@alt='no_image_with_this']").click}
|
72
|
-
|
73
|
-
# test for bug 1882
|
74
|
-
browser.text_field(:name , "text1").clear
|
75
|
-
browser.button(:value , /Pos/ ).click
|
76
|
-
assert_equal('clicked' , browser.text_field(:name , "text1" ).value )
|
77
|
-
|
78
|
-
|
79
|
-
# test for disabled button. Click the button to make it disabled
|
80
|
-
browser.button(:name , 'disable_img').click
|
81
|
-
assert( browser.image(:name , 'disabler_test').disabled )
|
82
|
-
|
83
|
-
# Click button again to make it enabled.
|
84
|
-
browser.button(:name , 'disable_img').click
|
85
|
-
assert( ! browser.image(:name , 'disabler_test').disabled )
|
86
|
-
|
87
|
-
browser.image(:src, /button/).click
|
88
|
-
assert(browser.text.include?("PASS") )
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
|
-
|
93
|
-
# TODO: Need to see alternative for this in Mozilla
|
94
|
-
#def test_imageHasLoaded
|
95
|
-
# assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']").hasLoaded? }
|
96
|
-
# assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']").hasLoaded? }
|
97
|
-
# assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']").hasLoaded? }
|
98
|
-
# assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@alt='no_image_with_this']").hasLoaded? }
|
99
|
-
#
|
100
|
-
# assert_false( browser.image(:xpath , "//img[@name='themissingimage']").hasLoaded? )
|
101
|
-
# assert( browser.image(:xpath , "//img[@name='circle']").hasLoaded? )
|
102
|
-
#
|
103
|
-
# assert( browser.image(:xpath , "//img[@alt='circle']").hasLoaded? )
|
104
|
-
# # assert( browser.image(:alt, /cir/ ).hasLoaded? )
|
105
|
-
#end
|
106
|
-
|
107
|
-
def test_image_properties
|
108
|
-
# TODO: Need to see alternative for this in Mozilla
|
109
|
-
#assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']").hasLoaded? }
|
110
|
-
#assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']").hasLoaded? }
|
111
|
-
#assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']").hasLoaded? }
|
112
|
-
|
113
|
-
# to string tests -- output should be verified!
|
114
|
-
puts browser.image(:xpath , "//img[@name='circle']").to_s
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
118
|
-
|
1
|
+
# feature tests for Images
|
2
|
+
# revision: $Revision: 1.0 $
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
|
+
require 'unittests/setup'
|
6
|
+
require 'webrick'
|
7
|
+
|
8
|
+
class TC_Images_XPath < Test::Unit::TestCase
|
9
|
+
|
10
|
+
|
11
|
+
def setup
|
12
|
+
gotoImagePage
|
13
|
+
end
|
14
|
+
|
15
|
+
def gotoImagePage()
|
16
|
+
goto_page("images1.html")
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_imageExists
|
20
|
+
assert_false( browser.image(:xpath , "//img[@name='missing_name']").exists? )
|
21
|
+
assert( browser.image(:xpath , "//img[@name='circle']").exists? )
|
22
|
+
assert( browser.image(:xpath , "//img[contains(@name , 'circ')]" ).exists? )
|
23
|
+
|
24
|
+
assert_false( browser.image(:xpath , "//img[@id='missing_id']").exists? )
|
25
|
+
assert( browser.image(:xpath , "//img[@id='square']").exists? )
|
26
|
+
assert( browser.image(:xpath , "//img[contains(@id, 'squ')]" ).exists? )
|
27
|
+
|
28
|
+
assert_false( browser.image(:xpath , "//img[@src='missingsrc.gif']").exists? )
|
29
|
+
|
30
|
+
# BP -- This fails for me but not for Paul. It doesn't make sense to me that it should pass.
|
31
|
+
# assert( browser.image(:src , "file:///#{$myDir}/html/images/triangle.jpg").exists? )
|
32
|
+
assert( browser.image(:xpath , "//img[contains(@src , 'triangle')]" ).exists? )
|
33
|
+
|
34
|
+
assert( browser.image(:alt , "circle" ).exists? )
|
35
|
+
assert( browser.image(:xpath , "//img[contains(@alt , 'cir')]" ).exists? )
|
36
|
+
|
37
|
+
assert_false( browser.image(:alt , "triangle" ).exists? )
|
38
|
+
assert_false( browser.image(:xpath , "//img[contains(@alt , 'tri')]" ).exists? )
|
39
|
+
end
|
40
|
+
|
41
|
+
tag_method :test_element_by_xpath_class, :fails_on_ie
|
42
|
+
def test_element_by_xpath_class
|
43
|
+
# FIXME getting HTMLAnchorElement instead of HTMLImageElement
|
44
|
+
# TODO: This should return null if object is not there.
|
45
|
+
#element = browser.element_by_xpath("//img[@name='missing_name']")
|
46
|
+
#assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
|
47
|
+
element = browser.element_by_xpath("//img[@name='circle']")
|
48
|
+
assert_class(element, 'Image')
|
49
|
+
element = browser.element_by_xpath("//img[contains(@name , 'circ')]")
|
50
|
+
assert_class(element, 'Image')
|
51
|
+
# TODO: This should return null if object is not there.
|
52
|
+
#element = browser.element_by_xpath("//img[@id='missing_id']")
|
53
|
+
#assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
|
54
|
+
element = browser.element_by_xpath("//img[@id='square']")
|
55
|
+
assert_class(element, 'Image')
|
56
|
+
element = browser.element_by_xpath("//img[contains(@id, 'squ')]")
|
57
|
+
assert_class(element, 'Image')
|
58
|
+
element = browser.element_by_xpath("//img[contains(@src , 'triangle')]")
|
59
|
+
assert_class(element, 'Image')
|
60
|
+
element = browser.element_by_xpath("//img[contains(@alt , 'cir')]")
|
61
|
+
assert_class(element, 'Image')
|
62
|
+
# TODO: This should return null if object is not there.
|
63
|
+
#element = browser.element_by_xpath("//img[contains(@alt , 'tri')]")
|
64
|
+
#assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_image_click
|
68
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']").click }
|
69
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']").click }
|
70
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']").click}
|
71
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@alt='no_image_with_this']").click}
|
72
|
+
|
73
|
+
# test for bug 1882
|
74
|
+
browser.text_field(:name , "text1").clear
|
75
|
+
browser.button(:value , /Pos/ ).click
|
76
|
+
assert_equal('clicked' , browser.text_field(:name , "text1" ).value )
|
77
|
+
|
78
|
+
|
79
|
+
# test for disabled button. Click the button to make it disabled
|
80
|
+
browser.button(:name , 'disable_img').click
|
81
|
+
assert( browser.image(:name , 'disabler_test').disabled )
|
82
|
+
|
83
|
+
# Click button again to make it enabled.
|
84
|
+
browser.button(:name , 'disable_img').click
|
85
|
+
assert( ! browser.image(:name , 'disabler_test').disabled )
|
86
|
+
|
87
|
+
browser.image(:src, /button/).click
|
88
|
+
assert(browser.text.include?("PASS") )
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
# TODO: Need to see alternative for this in Mozilla
|
94
|
+
#def test_imageHasLoaded
|
95
|
+
# assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']").hasLoaded? }
|
96
|
+
# assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']").hasLoaded? }
|
97
|
+
# assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']").hasLoaded? }
|
98
|
+
# assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@alt='no_image_with_this']").hasLoaded? }
|
99
|
+
#
|
100
|
+
# assert_false( browser.image(:xpath , "//img[@name='themissingimage']").hasLoaded? )
|
101
|
+
# assert( browser.image(:xpath , "//img[@name='circle']").hasLoaded? )
|
102
|
+
#
|
103
|
+
# assert( browser.image(:xpath , "//img[@alt='circle']").hasLoaded? )
|
104
|
+
# # assert( browser.image(:alt, /cir/ ).hasLoaded? )
|
105
|
+
#end
|
106
|
+
|
107
|
+
def test_image_properties
|
108
|
+
# TODO: Need to see alternative for this in Mozilla
|
109
|
+
#assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']").hasLoaded? }
|
110
|
+
#assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']").hasLoaded? }
|
111
|
+
#assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']").hasLoaded? }
|
112
|
+
|
113
|
+
# to string tests -- output should be verified!
|
114
|
+
puts browser.image(:xpath , "//img[@name='circle']").to_s
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
@@ -1,75 +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
|
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
|
data/unittests/links_test.rb
CHANGED
@@ -1,231 +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
|
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
|