firewatir 1.2.1 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/unittests/frame_test.rb
CHANGED
@@ -1,49 +1,49 @@
|
|
1
1
|
# feature tests for Frames
|
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_Frames < Test::Unit::TestCase
|
8
|
-
|
8
|
+
|
9
9
|
|
10
10
|
def setup
|
11
|
-
|
11
|
+
goto_page("frame_buttons.html")
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_frame_no_what
|
15
|
-
assert_raises(UnknownFrameException) {
|
16
|
-
assert_raises(UnknownObjectException) {
|
17
|
-
assert(
|
18
|
-
|
15
|
+
assert_raises(UnknownFrameException) { browser.frame("missingFrame").button(:id, "b2").enabled? }
|
16
|
+
assert_raises(UnknownObjectException) { browser.frame("buttonFrame2").button(:id, "b2").enabled? }
|
17
|
+
assert(browser.frame("buttonFrame").button(:id, "b2").enabled?)
|
18
|
+
assert_false(browser.frame("buttonFrame").button(:caption, "Disabled Button").enabled?)
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_frame_using_name
|
22
|
-
assert_raises(UnknownFrameException) {
|
23
|
-
assert_raises(UnknownObjectException) {
|
24
|
-
assert(
|
25
|
-
|
22
|
+
assert_raises(UnknownFrameException) { browser.frame(:name , "missingFrame").button(:id, "b2").enabled? }
|
23
|
+
assert_raises(UnknownObjectException) { browser.frame(:name, "buttonFrame2").button(:id, "b2").enabled? }
|
24
|
+
assert(browser.frame(:name, "buttonFrame").button(:id, "b2").enabled?)
|
25
|
+
assert_false(browser.frame(:name , "buttonFrame").button(:caption, "Disabled Button").enabled?)
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_frame_using_name_and_regexp
|
29
|
-
assert_raises(UnknownFrameException) {
|
30
|
-
assert(
|
29
|
+
assert_raises(UnknownFrameException) { browser.frame(:name , /missingFrame/).button(:id, "b2").enabled? }
|
30
|
+
assert(browser.frame(:name, /button/).button(:id, "b2").enabled?)
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_frame_using_index
|
34
|
-
assert_raises(UnknownFrameException) {
|
35
|
-
assert_raises(UnknownObjectException) {
|
36
|
-
assert(
|
37
|
-
|
34
|
+
assert_raises(UnknownFrameException) { browser.frame(:index, 8).button(:id, "b2").enabled? }
|
35
|
+
assert_raises(UnknownObjectException) { browser.frame(:index, 2).button(:id, "b2").enabled? }
|
36
|
+
assert(browser.frame(:index, 1 ).button(:id, "b2").enabled?)
|
37
|
+
assert_false(browser.frame(:index, 1).button(:caption, "Disabled Button").enabled?)
|
38
38
|
end
|
39
39
|
|
40
40
|
# def test_frame_with_invalid_attribute
|
41
|
-
# assert_raises(ArgumentError) {
|
41
|
+
# assert_raises(ArgumentError) { browser.frame(:blah, 'no_such_thing').button(:id, "b2").enabled? }
|
42
42
|
# end
|
43
43
|
|
44
44
|
def test_preset_frame
|
45
45
|
# with ruby's instance_eval, we are able to use the same frame for several actions
|
46
|
-
results =
|
46
|
+
results = browser.frame("buttonFrame").instance_eval do [
|
47
47
|
button(:id, "b2").enabled?,
|
48
48
|
button(:caption, "Disabled Button").enabled?
|
49
49
|
]
|
@@ -54,54 +54,54 @@ class TC_Frames < Test::Unit::TestCase
|
|
54
54
|
end
|
55
55
|
|
56
56
|
class TC_Frames2 < Test::Unit::TestCase
|
57
|
-
|
57
|
+
|
58
58
|
|
59
59
|
def setup
|
60
|
-
|
60
|
+
goto_page("frame_multi.html")
|
61
61
|
end
|
62
62
|
|
63
63
|
def test_frame_with_no_name
|
64
|
-
assert_raises(UnknownFrameException) {
|
64
|
+
assert_raises(UnknownFrameException) { browser.frame(:name , "missingFrame").button(:id, "b2").enabled? }
|
65
65
|
end
|
66
66
|
|
67
67
|
def test_frame_by_id
|
68
|
-
assert_raises(UnknownFrameException) {
|
69
|
-
assert(
|
70
|
-
assert(/.*Test page for buttons.*/ =~
|
68
|
+
assert_raises(UnknownFrameException) { browser.frame(:id , "missingFrame").button(:id, "b2").enabled? }
|
69
|
+
assert(browser.frame(:id, 'first_frame').button(:id, "b2").enabled?)
|
70
|
+
assert(/.*Test page for buttons.*/ =~ browser.frame(:id, 'first_frame').html)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
class TC_NestedFrames < Test::Unit::TestCase
|
75
|
-
|
75
|
+
|
76
76
|
|
77
77
|
def setup
|
78
|
-
|
78
|
+
goto_page("nestedFrames.html")
|
79
79
|
end
|
80
80
|
|
81
81
|
def test_frame
|
82
|
-
assert_raises(UnknownFrameException) {
|
83
|
-
assert_raises(UnknownFrameException) {
|
84
|
-
assert(
|
85
|
-
|
86
|
-
|
87
|
-
assert(
|
82
|
+
assert_raises(UnknownFrameException) { browser.frame("missingFrame").button(:id, "b2").enabled? }
|
83
|
+
assert_raises(UnknownFrameException) { browser.frame("nestedFrame").frame("subFrame").button(:id, "b2").enabled? }
|
84
|
+
assert(browser.frame("nestedFrame").frame("senderFrame").button(:name, "sendIt").enabled?)
|
85
|
+
browser.frame("nestedFrame").frame("senderFrame").text_field(:index, "1").set("Hello")
|
86
|
+
browser.frame("nestedFrame").frame("senderFrame").button(:name, "sendIt").click
|
87
|
+
assert(browser.frame("nestedFrame").frame("receiverFrame").text_field(:name, "receiverText").verify_contains("Hello"))
|
88
88
|
end
|
89
89
|
|
90
90
|
end
|
91
91
|
|
92
92
|
class TC_IFrames < Test::Unit::TestCase
|
93
|
-
|
93
|
+
|
94
94
|
|
95
95
|
def setup
|
96
|
-
|
96
|
+
goto_page("iframeTest.html")
|
97
97
|
end
|
98
98
|
|
99
99
|
def test_Iframe
|
100
|
-
f =
|
100
|
+
f = browser.frame("senderFrame")
|
101
101
|
f.text_field(:name, "textToSend").set("Hello World")
|
102
|
-
|
103
|
-
|
104
|
-
assert(
|
102
|
+
browser.frame("senderFrame").text_field(:name , "textToSend").set( "Hello World")
|
103
|
+
browser.frame("senderFrame").button(:index, 1).click
|
104
|
+
assert( browser.frame("receiverFrame").text_field(:name , "receiverText").verify_contains("Hello World") )
|
105
105
|
end
|
106
106
|
|
107
107
|
end
|
@@ -109,11 +109,12 @@ end
|
|
109
109
|
require 'unittests/iostring'
|
110
110
|
class TC_show_frames < Test::Unit::TestCase
|
111
111
|
include MockStdoutTestCase
|
112
|
+
tags :fails_on_ie
|
112
113
|
|
113
114
|
def capture_and_compare(page, expected)
|
114
|
-
|
115
|
+
goto_page(page)
|
115
116
|
$stdout = @mockout
|
116
|
-
|
117
|
+
browser.showFrames
|
117
118
|
assert_equal(expected, @mockout)
|
118
119
|
end
|
119
120
|
|
data/unittests/hidden_test.rb
CHANGED
@@ -1,73 +1,73 @@
|
|
1
1
|
# feature tests for Input Hidden elements
|
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_Hidden_Fields < Test::Unit::TestCase
|
8
8
|
def setup
|
9
|
-
|
9
|
+
goto_page("forms3.html")
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_hidden
|
13
13
|
|
14
14
|
# test using index
|
15
|
-
assert(
|
16
|
-
assert(
|
17
|
-
assert_false(
|
15
|
+
assert( browser.hidden(:index,1).exists? )
|
16
|
+
assert( browser.hidden(:index,2).exists? )
|
17
|
+
assert_false( browser.hidden(:index,3).exists? )
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
browser.hidden(:index,1).value = 44
|
20
|
+
browser.hidden(:index,2).value = 55
|
21
21
|
|
22
|
-
|
22
|
+
browser.button(:value , "Show Hidden").click
|
23
23
|
|
24
|
-
assert_equal("44" ,
|
25
|
-
assert_equal("55" ,
|
24
|
+
assert_equal("44" , browser.text_field(:name , "vis1").value )
|
25
|
+
assert_equal("55" , browser.text_field(:name , "vis2").value )
|
26
26
|
|
27
27
|
# test using name and ID
|
28
|
-
assert(
|
29
|
-
assert(
|
30
|
-
assert_false(
|
31
|
-
assert_false(
|
28
|
+
assert( browser.hidden(:name ,"hid1").exists? )
|
29
|
+
assert( browser.hidden(:id,"hidden_1").exists? )
|
30
|
+
assert_false( browser.hidden(:name,"hidden_44").exists? )
|
31
|
+
assert_false( browser.hidden(:id,"hidden_55").exists? )
|
32
32
|
|
33
|
-
|
34
|
-
|
33
|
+
browser.hidden(:name ,"hid1").value = 444
|
34
|
+
browser.hidden(:id,"hidden_1").value = 555
|
35
35
|
|
36
|
-
|
36
|
+
browser.button(:value , "Show Hidden").click
|
37
37
|
|
38
|
-
assert_equal("444" ,
|
39
|
-
assert_equal("555" ,
|
38
|
+
assert_equal("444" , browser.text_field(:name , "vis1").value )
|
39
|
+
assert_equal("555" , browser.text_field(:name ,"vis2").value )
|
40
40
|
|
41
41
|
# test the over-ridden append method
|
42
|
-
|
43
|
-
|
44
|
-
assert_equal("444a" ,
|
45
|
-
assert_equal("555" ,
|
42
|
+
browser.hidden(:name ,"hid1").append("a")
|
43
|
+
browser.button(:value , "Show Hidden").click
|
44
|
+
assert_equal("444a" , browser.text_field(:name , "vis1").value )
|
45
|
+
assert_equal("555" , browser.text_field(:name ,"vis2").value )
|
46
46
|
|
47
47
|
# test the over-ridden clear method
|
48
|
-
|
49
|
-
|
50
|
-
assert_equal("" ,
|
51
|
-
assert_equal("555" ,
|
48
|
+
browser.hidden(:name ,"hid1").clear
|
49
|
+
browser.button(:value , "Show Hidden").click
|
50
|
+
assert_equal("" , browser.text_field(:name , "vis1").value )
|
51
|
+
assert_equal("555" , browser.text_field(:name ,"vis2").value )
|
52
52
|
|
53
53
|
# test using a form
|
54
|
-
assert(
|
55
|
-
assert(
|
56
|
-
assert_false(
|
57
|
-
assert_false(
|
54
|
+
assert( browser.form(:name , "has_a_hidden").hidden(:name ,"hid1").exists? )
|
55
|
+
assert( browser.form(:name , "has_a_hidden").hidden(:id,"hidden_1").exists? )
|
56
|
+
assert_false( browser.form(:name , "has_a_hidden").hidden(:name,"hidden_44").exists? )
|
57
|
+
assert_false( browser.form(:name , "has_a_hidden").hidden(:id,"hidden_55").exists? )
|
58
58
|
|
59
|
-
|
60
|
-
|
59
|
+
browser.form(:name , "has_a_hidden").hidden(:name ,"hid1").value = 222
|
60
|
+
browser.form(:name , "has_a_hidden").hidden(:id,"hidden_1").value = 333
|
61
61
|
|
62
|
-
|
62
|
+
browser.button(:value , "Show Hidden").click
|
63
63
|
|
64
|
-
assert_equal("222" ,
|
65
|
-
assert_equal("333" ,
|
64
|
+
assert_equal("222" , browser.text_field(:name , "vis1").value )
|
65
|
+
assert_equal("333" , browser.text_field(:name ,"vis2").value )
|
66
66
|
|
67
67
|
# iterators
|
68
|
-
assert_equal(2,
|
68
|
+
assert_equal(2, browser.hiddens.length)
|
69
69
|
count =1
|
70
|
-
|
70
|
+
browser.hiddens.each do |h|
|
71
71
|
case count
|
72
72
|
when 1
|
73
73
|
assert_equal( "", h.id)
|
@@ -79,7 +79,7 @@ class TC_Hidden_Fields < Test::Unit::TestCase
|
|
79
79
|
count+=1
|
80
80
|
end
|
81
81
|
|
82
|
-
assert_equal("hid1" ,
|
83
|
-
assert_equal("hidden_1" ,
|
82
|
+
assert_equal("hid1" , browser.hiddens[1].name )
|
83
|
+
assert_equal("hidden_1" , browser.hiddens[2].id )
|
84
84
|
end
|
85
85
|
end
|
@@ -1,60 +1,60 @@
|
|
1
1
|
# feature tests for Input Hidden elements
|
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_Hidden_Fields_XPath < Test::Unit::TestCase
|
8
8
|
def setup
|
9
|
-
|
9
|
+
goto_page("forms3.html")
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_hidden
|
13
13
|
|
14
14
|
# test using name and ID
|
15
|
-
assert(
|
16
|
-
assert(
|
17
|
-
assert_false(
|
18
|
-
assert_false(
|
15
|
+
assert( browser.hidden(:xpath,"//input[@type='hidden' and @name='hid1']").exists? )
|
16
|
+
assert( browser.hidden(:xpath,"//input[@type='hidden' and @id='hidden_1']").exists? )
|
17
|
+
assert_false( browser.hidden(:xpath,"//input[@type='hidden' and @name='hidden_44']").exists? )
|
18
|
+
assert_false( browser.hidden(:xpath,"//input[@type='hidden' and @id='hidden_55']").exists? )
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
browser.hidden(:xpath,"//input[@type='hidden' and @name='hid1']").value = 444
|
21
|
+
browser.hidden(:xpath,"//input[@type='hidden' and @id='hidden_1']").value = 555
|
22
22
|
|
23
|
-
|
23
|
+
browser.button(:xpath , "//input[@type='button' and @value='Show Hidden']").click
|
24
24
|
|
25
|
-
assert_equal("444" ,
|
26
|
-
assert_equal("555" ,
|
25
|
+
assert_equal("444" , browser.text_field(:xpath , "//input[@name='vis1']").value )
|
26
|
+
assert_equal("555" , browser.text_field(:xpath ,"//input[@name='vis2']").value )
|
27
27
|
|
28
28
|
# test the over-ridden append method
|
29
|
-
|
30
|
-
|
31
|
-
assert_equal("444a" ,
|
32
|
-
assert_equal("555" ,
|
29
|
+
browser.hidden(:xpath,"//input[@type='hidden' and @name='hid1']").append("a")
|
30
|
+
browser.button(:xpath , "//input[@type='button' and @value='Show Hidden']").click
|
31
|
+
assert_equal("444a" , browser.text_field(:xpath , "//input[@name='vis1']").value )
|
32
|
+
assert_equal("555" , browser.text_field(:xpath ,"//input[@name='vis2']").value )
|
33
33
|
|
34
34
|
# test the over-ridden clear method
|
35
|
-
|
36
|
-
|
37
|
-
assert_equal("" ,
|
38
|
-
assert_equal("555" ,
|
35
|
+
browser.hidden(:xpath,"//input[@type='hidden' and @name='hid1']").clear
|
36
|
+
browser.button(:xpath , "//input[@type='button' and @value='Show Hidden']").click
|
37
|
+
assert_equal("" , browser.text_field(:xpath , "//input[@name='vis1']").value )
|
38
|
+
assert_equal("555" , browser.text_field(:xpath ,"//input[@name='vis2']").value )
|
39
39
|
|
40
40
|
# test using a form
|
41
|
-
#assert(
|
42
|
-
#assert(
|
43
|
-
#assert_false(
|
44
|
-
#assert_false(
|
41
|
+
#assert( browser.form(:name , "has_a_hidden").hidden(:name ,"hid1").exists? )
|
42
|
+
#assert( browser.form(:name , "has_a_hidden").hidden(:id,"hidden_1").exists? )
|
43
|
+
#assert_false( browser.form(:name , "has_a_hidden").hidden(:name,"hidden_44").exists? )
|
44
|
+
#assert_false( browser.form(:name , "has_a_hidden").hidden(:id,"hidden_55").exists? )
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
#browser.form(:name , "has_a_hidden").hidden(:name ,"hid1").value = 222
|
47
|
+
#browser.form(:name , "has_a_hidden").hidden(:id,"hidden_1").value = 333
|
48
48
|
|
49
|
-
|
49
|
+
#browser.button(:value , "Show Hidden").click
|
50
50
|
|
51
|
-
#assert_equal("222" ,
|
52
|
-
#assert_equal("333" ,
|
51
|
+
#assert_equal("222" , browser.text_field(:name , "vis1").value )
|
52
|
+
#assert_equal("333" , browser.text_field(:name ,"vis2").value )
|
53
53
|
|
54
54
|
# iterators
|
55
|
-
#assert_equal(2,
|
55
|
+
#assert_equal(2, browser.hiddens.length)
|
56
56
|
#count =1
|
57
|
-
|
57
|
+
#browser.hiddens.each do |h|
|
58
58
|
# case count
|
59
59
|
# when 1
|
60
60
|
# assert_equal( "", h.id)
|
@@ -66,7 +66,7 @@ class TC_Hidden_Fields_XPath < Test::Unit::TestCase
|
|
66
66
|
# count+=1
|
67
67
|
#end
|
68
68
|
|
69
|
-
#assert_equal("hid1" ,
|
70
|
-
#assert_equal("hidden_1" ,
|
69
|
+
#assert_equal("hid1" , browser.hiddens[1].name )
|
70
|
+
#assert_equal("hidden_1" , browser.hiddens[2].id )
|
71
71
|
end
|
72
72
|
end
|
data/unittests/images_test.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
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 < Test::Unit::TestCase
|
10
|
-
|
10
|
+
|
11
11
|
|
12
12
|
def setup
|
13
|
-
|
13
|
+
goto_page("images1.html")
|
14
14
|
@saved_img_path = build_path("sample.img.dat");
|
15
15
|
clean_saved_image
|
16
16
|
end
|
@@ -19,136 +19,136 @@ class TC_Images < Test::Unit::TestCase
|
|
19
19
|
clean_saved_image
|
20
20
|
end
|
21
21
|
# def test_show_all_objects
|
22
|
-
#
|
22
|
+
# browser.show_all_objects
|
23
23
|
# end
|
24
24
|
|
25
25
|
def test_imageExists
|
26
|
-
assert( !
|
27
|
-
assert(
|
28
|
-
assert(
|
26
|
+
assert( ! browser.image(:name , "missing_name").exists? )
|
27
|
+
assert( browser.image(:name , "circle").exists? )
|
28
|
+
assert( browser.image(:name , /circ/ ).exists? )
|
29
29
|
|
30
|
-
assert( !
|
31
|
-
assert(
|
32
|
-
assert(
|
30
|
+
assert( ! browser.image(:id , "missing_id").exists? )
|
31
|
+
assert( browser.image(:id , "square").exists? )
|
32
|
+
assert( browser.image(:id , /squ/ ).exists? )
|
33
33
|
|
34
|
-
assert( !
|
34
|
+
assert( ! browser.image(:src, "missingsrc.gif").exists? )
|
35
35
|
|
36
|
-
assert(
|
37
|
-
assert(
|
36
|
+
assert( browser.image(:src, /images\/triangle.jpg/).exists? )
|
37
|
+
assert( browser.image(:src , /triangle/ ).exists? )
|
38
38
|
|
39
|
-
assert(
|
40
|
-
assert(
|
39
|
+
assert( browser.image(:alt , "circle" ).exists? )
|
40
|
+
assert( browser.image(:alt , /cir/ ).exists? )
|
41
41
|
|
42
|
-
assert( !
|
43
|
-
assert( !
|
42
|
+
assert( ! browser.image(:alt , "triangle" ).exists? )
|
43
|
+
assert( ! browser.image(:alt , /tri/ ).exists? )
|
44
44
|
|
45
|
-
assert(
|
46
|
-
assert( !
|
45
|
+
assert( browser.image(:title, 'square_image').exists? )
|
46
|
+
assert( ! browser.image(:title, 'pentagram').exists? )
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_image_click
|
50
|
-
assert_raises(UnknownObjectException ) {
|
51
|
-
assert_raises(UnknownObjectException ) {
|
52
|
-
assert_raises(UnknownObjectException ) {
|
53
|
-
assert_raises(UnknownObjectException ) {
|
50
|
+
assert_raises(UnknownObjectException ) { browser.image(:name, "no_image_with_this").click }
|
51
|
+
assert_raises(UnknownObjectException ) { browser.image(:id, "no_image_with_this").click }
|
52
|
+
assert_raises(UnknownObjectException ) { browser.image(:src, "no_image_with_this").click}
|
53
|
+
assert_raises(UnknownObjectException ) { browser.image(:alt, "no_image_with_this").click}
|
54
54
|
|
55
55
|
# test for bug 1882
|
56
|
-
|
57
|
-
|
58
|
-
assert_equal('clicked' ,
|
56
|
+
browser.text_field(:name , "text1").clear
|
57
|
+
browser.button(:value , /Pos/ ).click
|
58
|
+
assert_equal('clicked' , browser.text_field(:name , "text1" ).value )
|
59
59
|
|
60
60
|
# test for disabled button. Click the button to make it disabled
|
61
|
-
|
62
|
-
assert(
|
61
|
+
browser.button(:name , 'disable_img').click
|
62
|
+
assert( browser.image(:name , 'disabler_test').disabled )
|
63
63
|
|
64
64
|
# Click button again to make it enabled.
|
65
|
-
|
66
|
-
assert( !
|
65
|
+
browser.button(:name , 'disable_img').click
|
66
|
+
assert( ! browser.image(:name , 'disabler_test').disabled )
|
67
67
|
|
68
68
|
|
69
|
-
|
70
|
-
#assert(
|
71
|
-
assert(
|
69
|
+
browser.image(:src, /button/).click
|
70
|
+
#assert(browser.text.include?("PASS") )
|
71
|
+
assert(browser.contains_text("PASS") )
|
72
72
|
end
|
73
73
|
|
74
74
|
# TODO: Need to see alternative for this in Mozilla
|
75
75
|
#def test_imageHasLoaded
|
76
|
-
# assert_raises(UnknownObjectException ) {
|
77
|
-
# assert_raises(UnknownObjectException ) {
|
78
|
-
# assert_raises(UnknownObjectException ) {
|
79
|
-
# assert_raises(UnknownObjectException ) {
|
76
|
+
# assert_raises(UnknownObjectException ) { browser.image(:name, "no_image_with_this").hasLoaded? }
|
77
|
+
# assert_raises(UnknownObjectException ) { browser.image(:id, "no_image_with_this").hasLoaded? }
|
78
|
+
# assert_raises(UnknownObjectException ) { browser.image(:src, "no_image_with_this").hasLoaded? }
|
79
|
+
# assert_raises(UnknownObjectException ) { browser.image(:alt, "no_image_with_this").hasLoaded? }
|
80
80
|
#
|
81
|
-
# assert( !
|
82
|
-
# assert(
|
81
|
+
# assert( ! browser.image(:name, "themissingimage").hasLoaded? )
|
82
|
+
# assert( browser.image(:name, "circle").hasLoaded? )
|
83
83
|
#
|
84
|
-
# assert(
|
85
|
-
# assert(
|
84
|
+
# assert( browser.image(:alt, "circle").hasLoaded? )
|
85
|
+
# assert( browser.image(:alt, /cir/ ).hasLoaded? )
|
86
86
|
#end
|
87
87
|
|
88
88
|
def test_image_properties
|
89
89
|
# TODO: Need to see alternative for this in Mozilla
|
90
|
-
#assert_raises(UnknownObjectException ) {
|
91
|
-
#assert_raises(UnknownObjectException ) {
|
92
|
-
#assert_raises(UnknownObjectException ) {
|
93
|
-
#assert_raises(UnknownObjectException ) {
|
90
|
+
#assert_raises(UnknownObjectException ) { browser.image(:name, "no_image_with_this").hasLoaded? }
|
91
|
+
#assert_raises(UnknownObjectException ) { browser.image(:id, "no_image_with_this").hasLoaded? }
|
92
|
+
#assert_raises(UnknownObjectException ) { browser.image(:src, "no_image_with_this").hasLoaded? }
|
93
|
+
#assert_raises(UnknownObjectException ) { browser.image(:index, 82).hasLoaded? }
|
94
94
|
|
95
|
-
assert_raises(UnknownObjectException ) {
|
96
|
-
assert_raises(UnknownObjectException ) {
|
97
|
-
assert_raises(UnknownObjectException ) {
|
98
|
-
assert_raises(UnknownObjectException ) {
|
99
|
-
assert_raises(UnknownObjectException ) {
|
100
|
-
assert_raises(UnknownObjectException ) {
|
95
|
+
assert_raises(UnknownObjectException ) { browser.image(:index, 82).name }
|
96
|
+
assert_raises(UnknownObjectException ) { browser.image(:index, 82).id }
|
97
|
+
assert_raises(UnknownObjectException ) { browser.image(:index, 82).src }
|
98
|
+
assert_raises(UnknownObjectException ) { browser.image(:index, 82).value }
|
99
|
+
assert_raises(UnknownObjectException ) { browser.image(:index, 82).height }
|
100
|
+
assert_raises(UnknownObjectException ) { browser.image(:index, 82).width }
|
101
101
|
|
102
102
|
# TODO: Need to see alternative for this in Mozilla
|
103
|
-
#assert_raises(UnknownObjectException ) {
|
104
|
-
#assert_raises(UnknownObjectException ) {
|
103
|
+
#assert_raises(UnknownObjectException ) { browser.image(:index, 82).fileCreatedDate }
|
104
|
+
#assert_raises(UnknownObjectException ) { browser.image(:index, 82).fileSize }
|
105
105
|
|
106
|
-
assert_raises(UnknownObjectException ) {
|
107
|
-
assert_raises(UnknownObjectException ) {
|
106
|
+
assert_raises(UnknownObjectException ) { browser.image(:index, 82).alt}
|
107
|
+
assert_raises(UnknownObjectException ) { browser.image(:index, 82).title}
|
108
108
|
|
109
|
-
assert_equal( "" ,
|
110
|
-
assert_equal( "square" ,
|
111
|
-
assert_match( /square\.jpg/i
|
112
|
-
assert_equal( "" ,
|
113
|
-
assert_equal( "88" ,
|
114
|
-
assert_equal( "88" ,
|
109
|
+
assert_equal( "" , browser.image(:index, 2).name )
|
110
|
+
assert_equal( "square" , browser.image(:index, 2).id )
|
111
|
+
assert_match( /square\.jpg/i ,browser.image(:index, 2).src )
|
112
|
+
assert_equal( "" , browser.image(:index, 2).value )
|
113
|
+
assert_equal( "88" , browser.image(:index, 2).height )
|
114
|
+
assert_equal( "88" , browser.image(:index, 2).width )
|
115
115
|
|
116
116
|
# this line fails, as the date is when it is installed on the local oc, not the date the file was really created
|
117
|
-
#assert_equal( "03/10/2005" ,
|
118
|
-
#assert_equal( "788",
|
117
|
+
#assert_equal( "03/10/2005" , browser.image(:index, 2).fileCreatedDate )
|
118
|
+
#assert_equal( "788", browser.image(:index, 2).fileSize )
|
119
119
|
|
120
120
|
# tool tips: alt text + title
|
121
|
-
assert_equal('circle' ,
|
122
|
-
assert_equal( "" ,
|
123
|
-
assert_equal('square_image',
|
121
|
+
assert_equal('circle' , browser.image(:index, 6).alt)
|
122
|
+
assert_equal( "" , browser.image(:index, 2).alt)
|
123
|
+
assert_equal('square_image', browser.image(:id, 'square').title)
|
124
124
|
|
125
125
|
# to string tests -- output should be verified!
|
126
|
-
puts
|
127
|
-
puts
|
126
|
+
puts browser.image(:name , "circle").to_s
|
127
|
+
puts browser.image(:index , 2).to_s
|
128
128
|
end
|
129
129
|
|
130
130
|
def test_image_iterator
|
131
|
-
assert_equal(6 ,
|
132
|
-
assert_equal("" ,
|
133
|
-
assert_equal("square",
|
134
|
-
assert_match(/square/,
|
131
|
+
assert_equal(6 , browser.images.length)
|
132
|
+
assert_equal("" , browser.images[2].name )
|
133
|
+
assert_equal("square", browser.images[2].id )
|
134
|
+
assert_match(/square/, browser.images[2].src )
|
135
135
|
|
136
136
|
index = 1
|
137
|
-
|
138
|
-
assert_equal(
|
139
|
-
assert_equal(
|
140
|
-
assert_equal(
|
141
|
-
assert_equal(
|
142
|
-
assert_equal(
|
137
|
+
browser.images.each do |i|
|
138
|
+
assert_equal( browser.image(:index, index).id , i.id )
|
139
|
+
assert_equal( browser.image(:index, index).name , i.name )
|
140
|
+
assert_equal( browser.image(:index, index).src , i.src )
|
141
|
+
assert_equal( browser.image(:index, index).height , i.height.to_s )
|
142
|
+
assert_equal( browser.image(:index, index).width , i.width.to_s )
|
143
143
|
|
144
144
|
index+=1
|
145
145
|
end
|
146
|
-
assert_equal( index-1 ,
|
146
|
+
assert_equal( index-1 , browser.images.length )
|
147
147
|
end
|
148
148
|
|
149
149
|
#def test_save_local_image
|
150
|
-
#
|
151
|
-
# assert(File.compare(@saved_img_path,
|
150
|
+
# browser.images[1].save(build_windows_path("sample.img.dat"))
|
151
|
+
# assert(File.compare(@saved_img_path, browser.images[1].src.gsub(/^file:\/\/\//, '')))
|
152
152
|
#end
|
153
153
|
|
154
154
|
def clean_saved_image
|
@@ -165,13 +165,14 @@ class TC_Images < Test::Unit::TestCase
|
|
165
165
|
end
|
166
166
|
|
167
167
|
class TC_Images_Display < Test::Unit::TestCase
|
168
|
-
|
168
|
+
|
169
169
|
include MockStdoutTestCase
|
170
170
|
|
171
|
+
tag_method :test_showImages, :fails_on_ie
|
171
172
|
def test_showImages
|
172
|
-
|
173
|
+
goto_page("images1.html")
|
173
174
|
$stdout = @mockout
|
174
|
-
|
175
|
+
browser.showImages
|
175
176
|
assert_equal(<<END_OF_MESSAGE, @mockout)
|
176
177
|
There are 6 images
|
177
178
|
image: name:
|