firewatir 1.2.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/firewatir.rb +50 -0
- data/lib/firewatir/MozillaBaseElement.rb +1863 -0
- data/lib/firewatir/container.rb +534 -0
- data/lib/firewatir/exceptions.rb +10 -0
- data/lib/firewatir/firefox.rb +1127 -0
- data/lib/firewatir/htmlelements.rb +1911 -0
- data/lib/firewatir/version.rb +5 -0
- data/{firewatir → lib/firewatir}/winClicker.rb +0 -0
- data/{firewatir → lib/firewatir}/x11.rb +0 -0
- data/unittests/attach_to_new_window_test.rb +20 -12
- data/unittests/bug_fixes_test.rb +79 -69
- data/unittests/buttons_xpath_test.rb +45 -44
- data/unittests/checkbox_test.rb +86 -85
- data/unittests/checkbox_xpath_test.rb +58 -58
- data/unittests/div_test.rb +117 -115
- data/unittests/filefield_test.rb +12 -12
- data/unittests/filefield_xpath_test.rb +11 -11
- data/unittests/form_test.rb +134 -133
- data/unittests/frame_test.rb +42 -41
- data/unittests/hidden_test.rb +40 -40
- data/unittests/hidden_xpath_test.rb +32 -32
- data/unittests/images_test.rb +85 -84
- data/unittests/images_xpath_test.rb +57 -56
- data/unittests/iostring_test.rb +1 -1
- data/unittests/javascript_test.rb +42 -38
- data/unittests/links_test.rb +88 -86
- data/unittests/links_xpath_test.rb +38 -38
- data/unittests/mozilla_all_tests.rb +2 -14
- data/unittests/pre_test.rb +27 -25
- data/unittests/radios_test.rb +86 -86
- data/unittests/radios_xpath_test.rb +48 -48
- data/unittests/redirect_test.rb +20 -19
- data/unittests/selectbox_test.rb +72 -71
- data/unittests/selectbox_xpath_test.rb +58 -56
- data/unittests/setup.rb +22 -27
- data/unittests/table_test.rb +89 -88
- data/unittests/table_xpath_test.rb +37 -36
- data/unittests/textfields_test.rb +105 -102
- data/unittests/textfields_xpath_test.rb +53 -52
- metadata +37 -18
- data/MozillaBaseElement.rb +0 -1780
- data/container.rb +0 -900
- data/firewatir.rb +0 -1195
- data/firewatir/exceptions.rb +0 -44
- data/firewatir/testUnitAddons.rb +0 -8
- data/htmlelements.rb +0 -2281
- data/unittests/buttons_test.rb +0 -215
@@ -1,117 +1,118 @@
|
|
1
1
|
# feature tests for Images
|
2
2
|
# revision: $Revision: 1.0 $
|
3
3
|
|
4
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..')
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
5
|
require 'unittests/setup'
|
6
6
|
require 'ftools'
|
7
7
|
require 'webrick'
|
8
8
|
|
9
9
|
class TC_Images_XPath < Test::Unit::TestCase
|
10
|
-
|
10
|
+
|
11
11
|
|
12
12
|
def setup
|
13
13
|
gotoImagePage
|
14
14
|
end
|
15
15
|
|
16
16
|
def gotoImagePage()
|
17
|
-
|
17
|
+
goto_page("images1.html")
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_imageExists
|
21
|
-
assert_false(
|
22
|
-
assert(
|
23
|
-
assert(
|
21
|
+
assert_false( browser.image(:xpath , "//img[@name='missing_name']").exists? )
|
22
|
+
assert( browser.image(:xpath , "//img[@name='circle']").exists? )
|
23
|
+
assert( browser.image(:xpath , "//img[contains(@name , 'circ')]" ).exists? )
|
24
24
|
|
25
|
-
assert_false(
|
26
|
-
assert(
|
27
|
-
assert(
|
25
|
+
assert_false( browser.image(:xpath , "//img[@id='missing_id']").exists? )
|
26
|
+
assert( browser.image(:xpath , "//img[@id='square']").exists? )
|
27
|
+
assert( browser.image(:xpath , "//img[contains(@id, 'squ')]" ).exists? )
|
28
28
|
|
29
|
-
assert_false(
|
29
|
+
assert_false( browser.image(:xpath , "//img[@src='missingsrc.gif']").exists? )
|
30
30
|
|
31
31
|
# BP -- This fails for me but not for Paul. It doesn't make sense to me that it should pass.
|
32
|
-
# assert(
|
33
|
-
assert(
|
32
|
+
# assert( browser.image(:src , "file:///#{$myDir}/html/images/triangle.jpg").exists? )
|
33
|
+
assert( browser.image(:xpath , "//img[contains(@src , 'triangle')]" ).exists? )
|
34
34
|
|
35
|
-
assert(
|
36
|
-
assert(
|
35
|
+
assert( browser.image(:alt , "circle" ).exists? )
|
36
|
+
assert( browser.image(:xpath , "//img[contains(@alt , 'cir')]" ).exists? )
|
37
37
|
|
38
|
-
assert_false(
|
39
|
-
assert_false(
|
38
|
+
assert_false( browser.image(:alt , "triangle" ).exists? )
|
39
|
+
assert_false( browser.image(:xpath , "//img[contains(@alt , 'tri')]" ).exists? )
|
40
40
|
end
|
41
41
|
|
42
|
+
tag_method :test_element_by_xpath_class, :fails_on_ie
|
42
43
|
def test_element_by_xpath_class
|
43
44
|
# FIXME getting HTMLAnchorElement instead of HTMLImageElement
|
44
45
|
# TODO: This should return null if object is not there.
|
45
|
-
#element =
|
46
|
+
#element = browser.element_by_xpath("//img[@name='missing_name']")
|
46
47
|
#assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
|
47
|
-
element =
|
48
|
-
|
49
|
-
element =
|
50
|
-
|
48
|
+
element = browser.element_by_xpath("//img[@name='circle']")
|
49
|
+
assert_class(element, 'Image')
|
50
|
+
element = browser.element_by_xpath("//img[contains(@name , 'circ')]")
|
51
|
+
assert_class(element, 'Image')
|
51
52
|
# TODO: This should return null if object is not there.
|
52
|
-
#element =
|
53
|
+
#element = browser.element_by_xpath("//img[@id='missing_id']")
|
53
54
|
#assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
|
54
|
-
element =
|
55
|
-
|
56
|
-
element =
|
57
|
-
|
58
|
-
element =
|
59
|
-
|
60
|
-
element =
|
61
|
-
|
55
|
+
element = browser.element_by_xpath("//img[@id='square']")
|
56
|
+
assert_class(element, 'Image')
|
57
|
+
element = browser.element_by_xpath("//img[contains(@id, 'squ')]")
|
58
|
+
assert_class(element, 'Image')
|
59
|
+
element = browser.element_by_xpath("//img[contains(@src , 'triangle')]")
|
60
|
+
assert_class(element, 'Image')
|
61
|
+
element = browser.element_by_xpath("//img[contains(@alt , 'cir')]")
|
62
|
+
assert_class(element, 'Image')
|
62
63
|
# TODO: This should return null if object is not there.
|
63
|
-
#element =
|
64
|
+
#element = browser.element_by_xpath("//img[contains(@alt , 'tri')]")
|
64
65
|
#assert(element.instance_of?(Image),"element class should be #{Image}; got #{element.class}")
|
65
66
|
end
|
66
67
|
|
67
68
|
def test_image_click
|
68
|
-
assert_raises(UnknownObjectException ) {
|
69
|
-
assert_raises(UnknownObjectException ) {
|
70
|
-
assert_raises(UnknownObjectException ) {
|
71
|
-
assert_raises(UnknownObjectException ) {
|
69
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']").click }
|
70
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']").click }
|
71
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']").click}
|
72
|
+
assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@alt='no_image_with_this']").click}
|
72
73
|
|
73
74
|
# test for bug 1882
|
74
|
-
|
75
|
-
|
76
|
-
assert_equal('clicked' ,
|
75
|
+
browser.text_field(:name , "text1").clear
|
76
|
+
browser.button(:value , /Pos/ ).click
|
77
|
+
assert_equal('clicked' , browser.text_field(:name , "text1" ).value )
|
77
78
|
|
78
79
|
|
79
80
|
# test for disabled button. Click the button to make it disabled
|
80
|
-
|
81
|
-
assert(
|
81
|
+
browser.button(:name , 'disable_img').click
|
82
|
+
assert( browser.image(:name , 'disabler_test').disabled )
|
82
83
|
|
83
84
|
# Click button again to make it enabled.
|
84
|
-
|
85
|
-
assert( !
|
85
|
+
browser.button(:name , 'disable_img').click
|
86
|
+
assert( ! browser.image(:name , 'disabler_test').disabled )
|
86
87
|
|
87
|
-
|
88
|
-
assert(
|
88
|
+
browser.image(:src, /button/).click
|
89
|
+
assert(browser.text.include?("PASS") )
|
89
90
|
|
90
91
|
end
|
91
92
|
|
92
93
|
|
93
94
|
# TODO: Need to see alternative for this in Mozilla
|
94
95
|
#def test_imageHasLoaded
|
95
|
-
# assert_raises(UnknownObjectException ) {
|
96
|
-
# assert_raises(UnknownObjectException ) {
|
97
|
-
# assert_raises(UnknownObjectException ) {
|
98
|
-
# assert_raises(UnknownObjectException ) {
|
96
|
+
# assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']").hasLoaded? }
|
97
|
+
# assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']").hasLoaded? }
|
98
|
+
# assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']").hasLoaded? }
|
99
|
+
# assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@alt='no_image_with_this']").hasLoaded? }
|
99
100
|
#
|
100
|
-
# assert_false(
|
101
|
-
# assert(
|
101
|
+
# assert_false( browser.image(:xpath , "//img[@name='themissingimage']").hasLoaded? )
|
102
|
+
# assert( browser.image(:xpath , "//img[@name='circle']").hasLoaded? )
|
102
103
|
#
|
103
|
-
# assert(
|
104
|
-
# # assert(
|
104
|
+
# assert( browser.image(:xpath , "//img[@alt='circle']").hasLoaded? )
|
105
|
+
# # assert( browser.image(:alt, /cir/ ).hasLoaded? )
|
105
106
|
#end
|
106
107
|
|
107
108
|
def test_image_properties
|
108
109
|
# TODO: Need to see alternative for this in Mozilla
|
109
|
-
#assert_raises(UnknownObjectException ) {
|
110
|
-
#assert_raises(UnknownObjectException ) {
|
111
|
-
#assert_raises(UnknownObjectException ) {
|
110
|
+
#assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@name='no_image_with_this']").hasLoaded? }
|
111
|
+
#assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@id='no_image_with_this']").hasLoaded? }
|
112
|
+
#assert_raises(UnknownObjectException ) { browser.image(:xpath , "//img[@src='no_image_with_this']").hasLoaded? }
|
112
113
|
|
113
114
|
# to string tests -- output should be verified!
|
114
|
-
puts
|
115
|
+
puts browser.image(:xpath , "//img[@name='circle']").to_s
|
115
116
|
end
|
116
117
|
|
117
118
|
end
|
data/unittests/iostring_test.rb
CHANGED
@@ -1,71 +1,75 @@
|
|
1
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..')
|
1
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
2
2
|
require 'unittests/setup'
|
3
3
|
|
4
4
|
class TC_JavaScript_Test < Test::Unit::TestCase
|
5
|
-
|
5
|
+
|
6
6
|
# include FireWatir::Dialog
|
7
7
|
|
8
8
|
def setup
|
9
|
-
|
9
|
+
goto_page 'JavascriptClick.html'
|
10
10
|
end
|
11
11
|
|
12
|
+
tag_method :test_alert, :fails_on_ie
|
12
13
|
def test_alert
|
13
|
-
|
14
|
+
#browser.button(:id, "btnAlert").click_no_wait()
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
#browser.click_jspopup_button("OK")
|
17
|
+
browser.startClicker("ok", 1, '', "Press OK")
|
18
|
+
browser.button(:id, "btnAlert").click
|
18
19
|
|
19
|
-
assert_equal(
|
20
|
-
assert_equal("Press OK",
|
20
|
+
assert_equal(browser.text_field(:id, "testResult").value , "You pressed the Alert button!")
|
21
|
+
assert_equal("Press OK", browser.get_popup_text)
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
browser.startClicker("ok")
|
24
|
+
browser.button(:id, "btnAlert").click
|
24
25
|
|
25
|
-
assert_equal(
|
26
|
-
assert_equal("Press OK",
|
26
|
+
assert_equal(browser.text_field(:id, "testResult").value , "You pressed the Alert button!")
|
27
|
+
assert_equal("Press OK", browser.get_popup_text)
|
27
28
|
end
|
28
29
|
|
30
|
+
tag_method :test_confirm_ok, :fails_on_ie
|
29
31
|
def test_confirm_ok
|
30
|
-
|
32
|
+
#browser.button(:id, "btnConfirm").click_no_wait()
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
#browser.click_jspopup_button("OK")
|
35
|
+
browser.startClicker("ok", 1, '', "Press a button")
|
36
|
+
browser.button(:id, "btnConfirm").click
|
35
37
|
|
36
|
-
assert_equal(
|
37
|
-
assert_equal("Press a button",
|
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)
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
+
browser.startClicker("ok")
|
42
|
+
browser.button(:id, "btnConfirm").click
|
41
43
|
|
42
|
-
assert_equal(
|
43
|
-
assert_equal("Press a button",
|
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)
|
44
46
|
end
|
45
47
|
|
48
|
+
tag_method :test_confirm_cancel, :fails_on_ie
|
46
49
|
def test_confirm_cancel
|
47
|
-
|
50
|
+
#browser.button(:id, "btnConfirm").click_no_wait()
|
48
51
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
+
#browser.click_jspopup_button("Cancel")
|
53
|
+
browser.startClicker("cancel", 1, '', "Press a button")
|
54
|
+
browser.button(:id, "btnConfirm").click
|
52
55
|
|
53
|
-
assert_equal(
|
54
|
-
assert_equal("Press a button",
|
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)
|
55
58
|
|
56
|
-
|
57
|
-
|
59
|
+
browser.startClicker("cancel")
|
60
|
+
browser.button(:id, "btnConfirm").click
|
58
61
|
|
59
|
-
assert_equal(
|
60
|
-
assert_equal("Press a button",
|
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)
|
61
64
|
end
|
62
65
|
|
66
|
+
tag_method :test_ok_selectbox, :fails_on_ie
|
63
67
|
def test_ok_selectbox
|
64
|
-
|
65
|
-
|
66
|
-
|
68
|
+
goto_page("selectboxes1.html")
|
69
|
+
browser.startClicker("ok")
|
70
|
+
browser.select_list(:id , "selectbox_5").select_value(/2/)
|
67
71
|
|
68
|
-
assert_equal(
|
69
|
-
assert_equal("Press OK",
|
72
|
+
assert_equal(browser.text_field(:id, "txtAlert").value , "You pressed OK button")
|
73
|
+
assert_equal("Press OK", browser.get_popup_text)
|
70
74
|
end
|
71
75
|
end
|
data/unittests/links_test.rb
CHANGED
@@ -1,169 +1,170 @@
|
|
1
1
|
# feature tests for Links
|
2
2
|
# revision: $Revision: 1.0 $
|
3
3
|
|
4
|
-
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..')
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
|
5
5
|
require 'unittests/setup'
|
6
6
|
|
7
7
|
class TC_Links < Test::Unit::TestCase
|
8
|
-
|
8
|
+
|
9
9
|
|
10
10
|
def setup()
|
11
|
-
|
11
|
+
goto_page("links1.html")
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_new_link_exists
|
15
|
-
assert(
|
16
|
-
assert(
|
15
|
+
assert(browser.link(:text, "test1").exists?)
|
16
|
+
assert(browser.link(:text, /TEST/i).exists?)
|
17
17
|
end
|
18
18
|
|
19
19
|
# In current implementation, method_missing catches all the methods that are not defined
|
20
20
|
# for the element. So there is no way to find out about missinwayoffindingobject exp.
|
21
|
+
tag_method :test_bad_attribute, :fails_on_ie
|
21
22
|
def test_bad_attribute
|
22
|
-
assert_raises(UnknownObjectException) {
|
23
|
+
assert_raises(UnknownObjectException) { browser.link(:bad_attribute, 199).click }
|
23
24
|
begin
|
24
|
-
|
25
|
+
browser.link(:bad_attribute, 199).click
|
25
26
|
rescue UnknownObjectException => e
|
26
|
-
assert_equal "Unable to locate
|
27
|
+
assert_equal "Unable to locate element, using :bad_attribute, 199", e.to_s
|
27
28
|
end
|
28
29
|
end
|
29
30
|
|
30
31
|
def test_missing_links_dont_exist
|
31
|
-
assert_false(
|
32
|
-
assert_false(
|
32
|
+
assert_false(browser.link(:text, "missing").exists?)
|
33
|
+
assert_false(browser.link(:text, /miss/).exists?)
|
33
34
|
end
|
34
35
|
|
35
36
|
def test_link_Exists
|
36
|
-
assert(
|
37
|
-
assert(
|
38
|
-
assert_false(
|
39
|
-
assert_false(
|
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?)
|
40
41
|
|
41
42
|
# this assert we have to build up the path
|
42
43
|
# this is what it looks like if you do a to_s on the link file:///C:/watir_bonus/unitTests/html/links1.HTML
|
43
44
|
# but what we get back from $htmlRoot is a mixed case, so its almost impossible for use to test this correctly
|
44
|
-
# assert(
|
45
|
+
# assert(browser.link(:url,'file:///C:/watir_bonus/unitTests/html/links1.HTML' ).exists?)
|
45
46
|
|
46
|
-
assert(
|
47
|
-
assert_false(
|
47
|
+
assert(browser.link(:url, /link_pass.html/).exists?)
|
48
|
+
assert_false(browser.link(:url, "alsomissing.html").exists?)
|
48
49
|
|
49
|
-
assert(
|
50
|
-
assert_false(
|
50
|
+
assert(browser.link(:id, "link_id").exists?)
|
51
|
+
assert_false(browser.link(:id, "alsomissing").exists?)
|
51
52
|
|
52
|
-
assert(
|
53
|
-
assert_false(
|
53
|
+
assert(browser.link(:id, /_id/).exists?)
|
54
|
+
assert_false(browser.link(:id, /alsomissing/).exists?)
|
54
55
|
|
55
|
-
assert(
|
56
|
-
assert_false(
|
56
|
+
assert(browser.link(:name, "link_name").exists?)
|
57
|
+
assert_false(browser.link(:name, "alsomissing").exists?)
|
57
58
|
|
58
|
-
assert(
|
59
|
-
assert_false(
|
59
|
+
assert(browser.link(:name, /_n/).exists?)
|
60
|
+
assert_false(browser.link(:name, /missing/).exists?)
|
60
61
|
|
61
|
-
assert(
|
62
|
-
assert(
|
62
|
+
assert(browser.link(:title, /ti/).exists?)
|
63
|
+
assert(browser.link(:title, "link_title").exists?)
|
63
64
|
|
64
|
-
assert_false(
|
65
|
+
assert_false(browser.link(:title, /missing/).exists?)
|
65
66
|
|
66
|
-
assert(
|
67
|
-
assert_false(
|
67
|
+
assert(browser.link(:url, /_pass/).exists?)
|
68
|
+
assert_false(browser.link(:url, /dont_exist/).exists?)
|
68
69
|
end
|
69
70
|
|
70
71
|
def test_link_click
|
71
|
-
|
72
|
-
assert(
|
72
|
+
browser.link(:text, "test1").click
|
73
|
+
assert( browser.text.include?("Links2-Pass") )
|
73
74
|
end
|
74
75
|
def test_link2_click
|
75
|
-
|
76
|
-
assert(
|
76
|
+
browser.link(:url, /link_pass.html/).click
|
77
|
+
assert( browser.text.include?("Links3-Pass") )
|
77
78
|
end
|
78
79
|
def test_link3_click
|
79
|
-
|
80
|
-
assert(
|
80
|
+
browser.link(:index, 1).click
|
81
|
+
assert( browser.text.include?("Links2-Pass") )
|
81
82
|
end
|
82
83
|
def test_link4_click
|
83
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) {
|
84
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.link(:index, 199).click }
|
84
85
|
end
|
85
86
|
|
86
87
|
def test_link_properties
|
87
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) {
|
88
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) {
|
89
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) {
|
90
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) {
|
91
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) {
|
92
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) {
|
93
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) {
|
94
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) {
|
95
|
-
|
96
|
-
assert_match( /links2/
|
97
|
-
assert_equal( "" ,
|
98
|
-
assert_equal( "test1" ,
|
99
|
-
assert_equal( "" ,
|
100
|
-
assert_equal( "" ,
|
101
|
-
|
102
|
-
assert_equal( "" ,
|
103
|
-
assert_equal( "link_class_1" ,
|
104
|
-
|
105
|
-
assert_equal( "link_id" ,
|
106
|
-
assert_equal( "link_name" ,
|
107
|
-
|
108
|
-
assert_equal( "" ,
|
109
|
-
|
110
|
-
assert_equal( "link_title" ,
|
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)
|
111
112
|
end
|
112
113
|
|
113
114
|
def test_text_attribute
|
114
|
-
arr1 =
|
115
|
-
arr2 =
|
115
|
+
arr1 = browser.link(:text, "nameDelet").to_s
|
116
|
+
arr2 = browser.link(:text, /Delet/).to_s
|
116
117
|
assert_equal(arr1, arr2)
|
117
118
|
|
118
119
|
end
|
119
120
|
|
120
121
|
def test_link_iterator
|
121
|
-
assert_equal(11,
|
122
|
-
assert_equal("Link Using a name" ,
|
122
|
+
assert_equal(11, browser.links.length )
|
123
|
+
assert_equal("Link Using a name" , browser.links[7].text)
|
123
124
|
|
124
125
|
index = 1
|
125
|
-
|
126
|
-
assert_equal(
|
127
|
-
assert_equal(
|
128
|
-
assert_equal(
|
129
|
-
assert_equal(
|
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 )
|
130
131
|
index+=1
|
131
132
|
end
|
132
133
|
end
|
133
134
|
|
134
135
|
def test_div_xml_bug
|
135
|
-
|
136
|
-
assert_nothing_raised {
|
136
|
+
goto_page("div_xml.html")
|
137
|
+
assert_nothing_raised {browser.link(:text, 'Create').exists? }
|
137
138
|
end
|
138
139
|
def test_link_to_s
|
139
|
-
puts
|
140
|
+
puts browser.link(:id,"linktos").to_s
|
140
141
|
end
|
141
142
|
end
|
142
143
|
|
143
144
|
class TC_Frame_Links < Test::Unit::TestCase
|
144
|
-
|
145
|
+
|
145
146
|
|
146
147
|
def setup()
|
147
|
-
|
148
|
+
goto_page("frame_links.html")
|
148
149
|
end
|
149
150
|
|
150
151
|
def test_new_frame_link_exists
|
151
|
-
assert(
|
152
|
+
assert(browser.frame("buttonFrame").link(:text, "test1").exists?)
|
152
153
|
end
|
153
154
|
def test_missing_frame_links_dont_exist
|
154
|
-
assert_false(
|
155
|
-
assert_raise(UnknownFrameException, "UnknownFrameException was supposed to be thrown"){
|
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?}
|
156
157
|
end
|
157
158
|
|
158
159
|
def test_links_in_frames
|
159
|
-
assert(
|
160
|
-
assert_false(
|
160
|
+
assert(browser.frame("buttonFrame").link(:text, "test1").exists?)
|
161
|
+
assert_false(browser.frame("buttonFrame").link(:text, "missing").exists?)
|
161
162
|
|
162
|
-
assert_raises(UnknownObjectException, "UnknownObjectException was supposed to be thrown" ) {
|
163
|
-
assert_match(/links2/,
|
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)
|
164
165
|
|
165
166
|
count =0
|
166
|
-
|
167
|
+
browser.frame("buttonFrame").links.each do |l|
|
167
168
|
count+=1
|
168
169
|
end
|
169
170
|
|
@@ -172,13 +173,14 @@ class TC_Frame_Links < Test::Unit::TestCase
|
|
172
173
|
end
|
173
174
|
|
174
175
|
class TC_Links_Display < Test::Unit::TestCase
|
175
|
-
|
176
|
+
|
176
177
|
include MockStdoutTestCase
|
177
178
|
|
179
|
+
tag_method :test_showLinks, :fails_on_ie
|
178
180
|
def test_showLinks
|
179
|
-
|
181
|
+
goto_page("links1.html")
|
180
182
|
$stdout = @mockout
|
181
|
-
|
183
|
+
browser.showLinks
|
182
184
|
assert_equal(<<END_OF_MESSAGE, @mockout)
|
183
185
|
There are 11 links
|
184
186
|
link: name:
|