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/checkbox_test.rb
CHANGED
@@ -1,132 +1,133 @@
|
|
1
1
|
# feature tests for Check Boxes
|
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_CheckBox < Test::Unit::TestCase
|
8
|
-
|
8
|
+
|
9
9
|
|
10
10
|
def setup()
|
11
|
-
|
11
|
+
goto_page("checkboxes1.html")
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_checkbox_properties
|
15
|
-
assert_raises(UnknownObjectException
|
16
|
-
assert_raises(UnknownObjectException
|
17
|
-
assert_raises(UnknownObjectException
|
18
|
-
assert_raises(UnknownObjectException
|
19
|
-
assert_raises(UnknownObjectException
|
20
|
-
|
21
|
-
assert_equal("box1" ,
|
22
|
-
|
23
|
-
|
24
|
-
assert_equal("
|
25
|
-
assert_equal("
|
26
|
-
assert_equal(
|
27
|
-
|
28
|
-
|
29
|
-
assert_equal("" ,
|
30
|
-
|
31
|
-
|
32
|
-
assert_equal("
|
33
|
-
assert_equal("
|
34
|
-
assert_equal(
|
35
|
-
assert_equal(
|
36
|
-
|
37
|
-
|
38
|
-
assert_equal("" ,
|
15
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").id }
|
16
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").name }
|
17
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").disabled }
|
18
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").type }
|
19
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").value }
|
20
|
+
|
21
|
+
assert_equal("box1" , browser.checkbox(:index, 1).name )
|
22
|
+
assert_class(browser.checkbox(:index,1), 'Checkbox')
|
23
|
+
|
24
|
+
assert_equal("" , browser.checkbox(:index, 1).id )
|
25
|
+
assert_equal("checkbox" , browser.checkbox(:index, 1).type )
|
26
|
+
assert_equal("on" , browser.checkbox(:index, 1).value )
|
27
|
+
assert_equal(false , browser.checkbox(:index, 1).disabled )
|
28
|
+
|
29
|
+
assert_equal("check_box_style" , browser.checkbox(:name, "box1").class_name)
|
30
|
+
assert_equal("" , browser.checkbox(:name, "box2").class_name)
|
31
|
+
|
32
|
+
assert_equal("1" , browser.checkbox(:name,"box4").value )
|
33
|
+
assert_equal("3" , browser.checkbox(:name,"box4" , 3).value )
|
34
|
+
assert_equal("checkbox" , browser.checkbox(:name,"box4" , 3).type )
|
35
|
+
assert_equal(false , browser.checkbox(:name,"box4" , 3).disabled )
|
36
|
+
assert_equal("" , browser.checkbox(:name,"box4" , 3).id )
|
37
|
+
|
38
|
+
assert_equal("box4-value5" , browser.checkbox(:name,"box4" , 5).title)
|
39
|
+
assert_equal("" , browser.checkbox(:name,"box4" , 4).title)
|
39
40
|
end
|
40
41
|
|
41
42
|
def test_onClick
|
42
|
-
assert_false(
|
43
|
-
|
44
|
-
assert(
|
43
|
+
assert_false(browser.button(:value , "foo").enabled?)
|
44
|
+
browser.checkbox(:name, "box5").set
|
45
|
+
assert(browser.button(:value , "foo").enabled?)
|
45
46
|
|
46
|
-
|
47
|
-
assert_false(
|
47
|
+
browser.checkbox(:name, "box5").clear
|
48
|
+
assert_false(browser.button(:value , "foo").enabled?)
|
48
49
|
|
49
|
-
|
50
|
-
assert_false(
|
50
|
+
browser.checkbox(:name, "box5").clear
|
51
|
+
assert_false(browser.button(:value , "foo").enabled?)
|
51
52
|
end
|
52
53
|
|
53
54
|
def test_CheckBox_Exists
|
54
|
-
assert(
|
55
|
-
assert_false(
|
55
|
+
assert(browser.checkbox(:name, "box1").exists?)
|
56
|
+
assert_false(browser.checkbox(:name, "missing").exists?)
|
56
57
|
|
57
|
-
assert(
|
58
|
-
assert_false(
|
58
|
+
assert(browser.checkbox(:name, "box4" , 1).exists?)
|
59
|
+
assert_false(browser.checkbox(:name, "box4" , 22).exists?)
|
59
60
|
end
|
60
61
|
|
61
62
|
#def test_checkbox_Enabled
|
62
|
-
# assert_raises(UnknownObjectException) {
|
63
|
-
# assert_raises(UnknownObjectException) {
|
64
|
-
# assert_raises(UnknownObjectException) {
|
63
|
+
# assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").enabled? }
|
64
|
+
# assert_raises(UnknownObjectException) { browser.checkbox(:id, "noName").enabled? }
|
65
|
+
# assert_raises(UnknownObjectException) { browser.checkbox(:name, "box4" , 6).enabled? }
|
65
66
|
#
|
66
|
-
# assert(
|
67
|
-
# assert_false(
|
67
|
+
# assert(browser.checkbox(:name, "box1").enabled?)
|
68
|
+
# assert_false(browser.checkbox(:name, "box2").enabled?)
|
68
69
|
#
|
69
|
-
# assert(
|
70
|
-
# assert_false(
|
70
|
+
# assert(browser.checkbox(:name, "box4", 4).enabled?)
|
71
|
+
# assert_false(browser.checkbox(:name, "box4" , 5 ).enabled?)
|
71
72
|
#end
|
72
73
|
|
73
74
|
def test_checkbox_isSet
|
74
|
-
assert_raises(UnknownObjectException ) {
|
75
|
+
assert_raises(UnknownObjectException ) { browser.checkbox(:name, "noName").isSet? }
|
75
76
|
|
76
|
-
assert_false(
|
77
|
-
assert_false(
|
78
|
-
assert(
|
77
|
+
assert_false(browser.checkbox(:name, "box1").isSet?)
|
78
|
+
assert_false(browser.checkbox(:name, "box2").isSet?)
|
79
|
+
assert(browser.checkbox(:name, "box3").isSet?)
|
79
80
|
|
80
|
-
assert_false(
|
81
|
-
assert(
|
81
|
+
assert_false(browser.checkbox(:name, "box4" , 2 ).isSet?)
|
82
|
+
assert(browser.checkbox(:name, "box4" , 1 ).isSet?)
|
82
83
|
end
|
83
84
|
|
84
85
|
def test_checkbox_clear
|
85
|
-
assert_raises(UnknownObjectException) {
|
86
|
-
|
87
|
-
assert_false(
|
86
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").clear }
|
87
|
+
browser.checkbox(:name, "box1").clear
|
88
|
+
assert_false(browser.checkbox(:name, "box1").isSet?)
|
88
89
|
|
89
|
-
assert_raises(ObjectDisabledException) {
|
90
|
-
assert_false(
|
90
|
+
assert_raises(ObjectDisabledException) { browser.checkbox(:name, "box2").clear }
|
91
|
+
assert_false(browser.checkbox(:name, "box2").isSet?)
|
91
92
|
|
92
|
-
|
93
|
-
assert_false(
|
93
|
+
browser.checkbox(:name, "box3").clear
|
94
|
+
assert_false(browser.checkbox(:name, "box3").isSet?)
|
94
95
|
|
95
|
-
|
96
|
-
assert_false(
|
96
|
+
browser.checkbox(:name, "box4" , 1).clear
|
97
|
+
assert_false(browser.checkbox(:name, "box4" , 1).isSet?)
|
97
98
|
end
|
98
99
|
|
99
100
|
def test_checkbox_getState
|
100
|
-
assert_raises(UnknownObjectException) {
|
101
|
-
assert_equal( false ,
|
102
|
-
assert_equal( true ,
|
101
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").getState }
|
102
|
+
assert_equal( false , browser.checkbox(:name, "box1").getState )
|
103
|
+
assert_equal( true , browser.checkbox(:name, "box3").getState)
|
103
104
|
|
104
105
|
# checkboxes that have the same name but different values
|
105
|
-
assert_equal( false ,
|
106
|
-
assert_equal( true ,
|
106
|
+
assert_equal( false , browser.checkbox(:name, "box4" , 2).getState )
|
107
|
+
assert_equal( true , browser.checkbox(:name, "box4" , 1).getState)
|
107
108
|
end
|
108
109
|
|
109
110
|
def test_checkbox_set
|
110
|
-
assert_raises(UnknownObjectException) {
|
111
|
-
|
112
|
-
assert(
|
111
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:name, "noName").set }
|
112
|
+
browser.checkbox(:name, "box1").set
|
113
|
+
assert(browser.checkbox(:name, "box1").isSet?)
|
113
114
|
|
114
|
-
assert_raises(ObjectDisabledException) {
|
115
|
+
assert_raises(ObjectDisabledException) { browser.checkbox(:name, "box2").set }
|
115
116
|
|
116
|
-
|
117
|
-
assert(
|
117
|
+
browser.checkbox(:name, "box3").set
|
118
|
+
assert(browser.checkbox(:name, "box3").isSet?)
|
118
119
|
|
119
120
|
# checkboxes that have the same name but different values
|
120
|
-
|
121
|
-
assert(
|
121
|
+
browser.checkbox(:name, "box4" , 3).set
|
122
|
+
assert(browser.checkbox(:name, "box4" , 3).isSet?)
|
122
123
|
|
123
124
|
# test set using the optinal true/false
|
124
125
|
# assumes the checkbox is already checked
|
125
|
-
|
126
|
-
assert_false(
|
126
|
+
browser.checkbox(:name, "box1").set( false )
|
127
|
+
assert_false(browser.checkbox(:name, "box1").isSet?)
|
127
128
|
|
128
|
-
|
129
|
-
assert(
|
129
|
+
browser.checkbox(:name, "box1").set( true )
|
130
|
+
assert(browser.checkbox(:name, "box1").isSet?)
|
130
131
|
|
131
132
|
|
132
133
|
|
@@ -135,18 +136,18 @@ class TC_CheckBox < Test::Unit::TestCase
|
|
135
136
|
|
136
137
|
def test_checkbox_iterator
|
137
138
|
|
138
|
-
assert_equal(11,
|
139
|
-
assert_equal("box1" ,
|
139
|
+
assert_equal(11, browser.checkboxes.length)
|
140
|
+
assert_equal("box1" , browser.checkboxes[1].name )
|
140
141
|
|
141
142
|
index=1
|
142
|
-
|
143
|
-
assert_equal(
|
144
|
-
assert_equal(
|
145
|
-
assert_equal(
|
146
|
-
assert_equal(
|
143
|
+
browser.checkboxes.each do |c|
|
144
|
+
assert_equal( browser.checkbox(:index, index).name , c.name )
|
145
|
+
assert_equal( browser.checkbox(:index, index).id, c.id )
|
146
|
+
assert_equal( browser.checkbox(:index, index).value, c.value )
|
147
|
+
assert_equal( browser.checkbox(:index, index).isSet?, c.isSet? )
|
147
148
|
index+=1
|
148
149
|
end
|
149
|
-
assert_equal(index-1,
|
150
|
+
assert_equal(index-1, browser.checkboxes.length)
|
150
151
|
|
151
152
|
end
|
152
153
|
|
@@ -1,107 +1,107 @@
|
|
1
1
|
# feature tests for Check Boxes
|
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_CheckBox_XPath < Test::Unit::TestCase
|
8
|
-
|
8
|
+
|
9
9
|
|
10
10
|
def setup
|
11
|
-
|
11
|
+
goto_page("checkboxes1.html")
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_checkbox_properties
|
15
|
-
assert_raises(UnknownObjectException
|
16
|
-
assert_raises(UnknownObjectException
|
17
|
-
assert_raises(UnknownObjectException
|
18
|
-
assert_raises(UnknownObjectException
|
19
|
-
assert_raises(UnknownObjectException
|
20
|
-
|
21
|
-
assert_equal("1" ,
|
22
|
-
assert_equal("3" ,
|
23
|
-
assert_equal("checkbox" ,
|
24
|
-
assert_equal(false ,
|
25
|
-
assert_equal("" ,
|
26
|
-
|
27
|
-
assert_equal("box4-value5" ,
|
28
|
-
assert_equal("" ,
|
15
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").id }
|
16
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").name }
|
17
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").disabled }
|
18
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").type }
|
19
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").value }
|
20
|
+
|
21
|
+
assert_equal("1" , browser.checkbox(:xpath , "//input[@name='box4']").value )
|
22
|
+
assert_equal("3" , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").value )
|
23
|
+
assert_equal("checkbox" , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").type )
|
24
|
+
assert_equal(false , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").disabled )
|
25
|
+
assert_equal("" , browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").id )
|
26
|
+
|
27
|
+
assert_equal("box4-value5" , browser.checkbox(:xpath , "//input[@name='box4' and @value='5']").title)
|
28
|
+
assert_equal("" , browser.checkbox(:xpath , "//input[@name='box4' and @value='4']").title)
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_CheckBox_Exists
|
32
|
-
assert(
|
33
|
-
assert_false(
|
32
|
+
assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='1']").exists?)
|
33
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='22']").exists?)
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_checkbox_Enabled
|
37
|
-
assert_raises(UnknownObjectException) {
|
38
|
-
assert_raises(UnknownObjectException) {
|
39
|
-
assert_raises(UnknownObjectException) {
|
37
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").enabled? }
|
38
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@id='noName']").enabled? }
|
39
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='box4' and @value='6']").enabled? }
|
40
40
|
|
41
|
-
assert(
|
42
|
-
assert_false(
|
41
|
+
assert(browser.checkbox(:xpath , "//input[@name='box1']").enabled?)
|
42
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box2']").enabled?)
|
43
43
|
|
44
|
-
assert(
|
45
|
-
assert_false(
|
44
|
+
assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='4']").enabled?)
|
45
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='5']").enabled?)
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_checkbox_isSet
|
49
|
-
assert_raises(UnknownObjectException ) {
|
49
|
+
assert_raises(UnknownObjectException ) { browser.checkbox(:xpath , "//input[@name='noName']").isSet? }
|
50
50
|
|
51
|
-
assert_false(
|
52
|
-
assert_false(
|
53
|
-
assert(
|
51
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box1']").isSet?)
|
52
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box2']").isSet?)
|
53
|
+
assert(browser.checkbox(:xpath , "//input[@name='box3']").isSet?)
|
54
54
|
|
55
|
-
assert_false(
|
56
|
-
assert(
|
55
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='2']").isSet?)
|
56
|
+
assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='1']").isSet?)
|
57
57
|
end
|
58
58
|
|
59
59
|
def test_checkbox_clear
|
60
|
-
assert_raises(UnknownObjectException) {
|
61
|
-
|
62
|
-
assert_false(
|
60
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").clear }
|
61
|
+
browser.checkbox(:xpath , "//input[@name='box1']").clear
|
62
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box1']").isSet?)
|
63
63
|
|
64
|
-
assert_raises(ObjectDisabledException) {
|
65
|
-
assert_false(
|
64
|
+
assert_raises(ObjectDisabledException) { browser.checkbox(:xpath , "//input[@name='box2']").clear }
|
65
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box2']").isSet?)
|
66
66
|
|
67
|
-
|
68
|
-
assert_false(
|
67
|
+
browser.checkbox(:xpath , "//input[@name='box3']").clear
|
68
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box3']").isSet?)
|
69
69
|
|
70
|
-
|
71
|
-
assert_false(
|
70
|
+
browser.checkbox(:xpath , "//input[@name='box4' and @value='1']").clear
|
71
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box4' and @value='1']").isSet?)
|
72
72
|
end
|
73
73
|
|
74
74
|
def test_checkbox_getState
|
75
|
-
assert_raises(UnknownObjectException) {
|
76
|
-
assert_equal( false ,
|
77
|
-
assert_equal( true ,
|
75
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").getState }
|
76
|
+
assert_equal( false , browser.checkbox(:xpath , "//input[@name='box1']").getState )
|
77
|
+
assert_equal( true , browser.checkbox(:xpath , "//input[@name='box3']").getState)
|
78
78
|
|
79
79
|
# checkboxes that have the same name but different values
|
80
|
-
assert_equal( false ,
|
81
|
-
assert_equal( true ,
|
80
|
+
assert_equal( false , browser.checkbox(:xpath , "//input[@name='box4' and @value='2']").getState )
|
81
|
+
assert_equal( true , browser.checkbox(:xpath , "//input[@name='box4' and @value='1']").getState)
|
82
82
|
end
|
83
83
|
|
84
84
|
def test_checkbox_set
|
85
|
-
assert_raises(UnknownObjectException) {
|
86
|
-
|
87
|
-
assert(
|
85
|
+
assert_raises(UnknownObjectException) { browser.checkbox(:xpath , "//input[@name='noName']").set }
|
86
|
+
browser.checkbox(:xpath , "//input[@name='box1']").set
|
87
|
+
assert(browser.checkbox(:xpath , "//input[@name='box1']").isSet?)
|
88
88
|
|
89
|
-
assert_raises(ObjectDisabledException) {
|
89
|
+
assert_raises(ObjectDisabledException) { browser.checkbox(:xpath , "//input[@name='box2']").set }
|
90
90
|
|
91
|
-
|
92
|
-
assert(
|
91
|
+
browser.checkbox(:xpath , "//input[@name='box3']").set
|
92
|
+
assert(browser.checkbox(:xpath , "//input[@name='box3']").isSet?)
|
93
93
|
|
94
94
|
# checkboxes that have the same name but different values
|
95
|
-
|
96
|
-
assert(
|
95
|
+
browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").set
|
96
|
+
assert(browser.checkbox(:xpath , "//input[@name='box4' and @value='3']").isSet?)
|
97
97
|
|
98
98
|
# test set using the optinal true/false
|
99
99
|
# assumes the checkbox is already checked
|
100
|
-
|
101
|
-
assert_false(
|
100
|
+
browser.checkbox(:xpath , "//input[@name='box1']").set( false )
|
101
|
+
assert_false(browser.checkbox(:xpath , "//input[@name='box1']").isSet?)
|
102
102
|
|
103
|
-
|
104
|
-
assert(
|
103
|
+
browser.checkbox(:xpath , "//input[@name='box1']").set( true )
|
104
|
+
assert(browser.checkbox(:xpath , "//input[@name='box1']").isSet?)
|
105
105
|
|
106
106
|
end
|
107
107
|
end
|
data/unittests/div_test.rb
CHANGED
@@ -1,202 +1,204 @@
|
|
1
1
|
# feature tests for Divs, Spans and P's
|
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_Divs < Test::Unit::TestCase
|
8
|
-
|
8
|
+
|
9
9
|
|
10
10
|
def setup
|
11
|
-
|
11
|
+
goto_page("div.html")
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_divs
|
15
|
-
assert_raises(UnknownObjectException) {
|
16
|
-
assert_raises(UnknownObjectException) {
|
15
|
+
assert_raises(UnknownObjectException) {browser.div(:id , "div77").click }
|
16
|
+
assert_raises(UnknownObjectException) {browser.div(:title , "div77").click }
|
17
17
|
|
18
|
-
assert(
|
19
|
-
|
20
|
-
assert(
|
21
|
-
|
22
|
-
assert(
|
18
|
+
assert(browser.text_field(:name, "text1").verify_contains("0") )
|
19
|
+
browser.div(:id , "div3").click
|
20
|
+
assert(browser.text_field(:name, "text1").verify_contains("1") )
|
21
|
+
browser.div(:id , "div4").click
|
22
|
+
assert(browser.text_field(:name, "text1").verify_contains("0") )
|
23
23
|
end
|
24
24
|
|
25
|
+
tag_method :test_show_all_objects, :fails_on_ie
|
25
26
|
def test_show_all_objects
|
26
|
-
assert_equal(36,
|
27
|
-
assert_equal(3
|
27
|
+
assert_equal(36, browser.show_all_objects.length)
|
28
|
+
assert_equal(3,browser.div(:id,"text_fields1").show_all_objects.length)
|
28
29
|
|
29
|
-
assert_equal(8
|
30
|
-
assert_equal(3
|
30
|
+
assert_equal(8,browser.text_fields.length)
|
31
|
+
assert_equal(3,browser.div(:id,"text_fields1").text_fields.length)
|
31
32
|
end
|
32
33
|
|
33
34
|
def test_div_properties
|
34
|
-
assert_raises(UnknownObjectException) {
|
35
|
-
assert_raises(UnknownObjectException) {
|
35
|
+
assert_raises(UnknownObjectException) {browser.div(:id , "div77").text }
|
36
|
+
assert_raises(UnknownObjectException) {browser.div(:title , "div77").text }
|
36
37
|
|
37
|
-
assert_equal("This div has an onClick that increments text1",
|
38
|
-
assert_equal("This text is in a div with an id of div1 and title of test1"
|
38
|
+
assert_equal("This div has an onClick that increments text1", browser.div(:id , "div3").text.strip )
|
39
|
+
assert_equal("This text is in a div with an id of div1 and title of test1",browser.div(:title , "Test1").text.strip )
|
39
40
|
|
40
|
-
assert_raises(UnknownObjectException) {
|
41
|
-
assert_equal("blueText" ,
|
42
|
-
assert_equal("" ,
|
41
|
+
assert_raises(UnknownObjectException) {browser.div(:id , "div77").class_name }
|
42
|
+
assert_equal("blueText" , browser.div(:id , "div2").class_name )
|
43
|
+
assert_equal("" , browser.div(:id , "div1").class_name )
|
43
44
|
|
44
|
-
assert_raises(UnknownObjectException) {
|
45
|
-
assert_equal("div1" ,
|
46
|
-
assert_equal("" ,
|
47
|
-
assert_equal("blueText" ,
|
48
|
-
assert_equal("" ,
|
49
|
-
|
50
|
-
assert_equal("" ,
|
51
|
-
assert_equal("div2",
|
52
|
-
#puts
|
45
|
+
assert_raises(UnknownObjectException) {browser.div(:index , 44).class_name }
|
46
|
+
assert_equal("div1" , browser.div(:index , 1).id )
|
47
|
+
assert_equal("" , browser.div(:index , 1).class_name )
|
48
|
+
assert_equal("blueText" , browser.div(:index , 2).class_name )
|
49
|
+
assert_equal("" , browser.div(:index , 2).value)
|
50
|
+
assert_equal(false , browser.div(:index , 2).disabled)
|
51
|
+
assert_equal("" , browser.div(:index , 2).name)
|
52
|
+
assert_equal("div2", browser.div(:index , 2).id)
|
53
|
+
#puts browser.div(:id,"text_fields1").to_s
|
53
54
|
end
|
54
55
|
|
55
56
|
def test_div_iterator
|
56
|
-
assert_equal( 7 ,
|
57
|
-
assert_equal( "div1" ,
|
57
|
+
assert_equal( 7 , browser.divs.length)
|
58
|
+
assert_equal( "div1" , browser.divs[1].id )
|
58
59
|
|
59
60
|
index =1
|
60
|
-
|
61
|
+
browser.divs.each do |s|
|
61
62
|
# puts "each - div= " + s.to_s
|
62
|
-
assert_equal(
|
63
|
-
assert_equal(
|
64
|
-
assert_equal(
|
63
|
+
assert_equal(browser.div(:index, index ).name , s.name )
|
64
|
+
assert_equal(browser.div(:index, index ).id , s.id )
|
65
|
+
assert_equal(browser.div(:index, index ).class_name , s.class_name )
|
65
66
|
index +=1
|
66
67
|
end
|
67
|
-
assert_equal(index-1,
|
68
|
+
assert_equal(index-1, browser.divs.length) # -1 as we add 1 at the end of the loop
|
68
69
|
end
|
69
70
|
|
70
71
|
def test_objects_in_div
|
71
|
-
assert(
|
72
|
-
|
73
|
-
assert(
|
74
|
-
|
72
|
+
assert(browser.div(:id, 'buttons1').button(:index,1).exists? )
|
73
|
+
assert_false(browser.div(:id, 'buttons1').button(:index,3).exists? )
|
74
|
+
assert(browser.div(:id, 'buttons1').button(:name,'b1').exists? )
|
75
|
+
browser.div(:id, 'buttons1').button(:name,'b1').click
|
75
76
|
|
76
|
-
assert(
|
77
|
-
assert(
|
78
|
-
|
77
|
+
assert(browser.div(:id, 'buttons2').button(:index,1).exists? )
|
78
|
+
assert(browser.div(:id, 'buttons2').button(:index,2).exists? )
|
79
|
+
assert_false(browser.div(:id, 'buttons1').button(:index,3).exists? )
|
79
80
|
|
80
|
-
|
81
|
+
browser.div(:id, 'buttons1').button(:index,1).click
|
81
82
|
|
82
|
-
assert_equal( 'button1' ,
|
83
|
+
assert_equal( 'button1' , browser.div(:id , 'text_fields1').text_field(:index,1).value)
|
83
84
|
|
84
|
-
#assert_equal( 3 ,
|
85
|
-
|
86
|
-
assert_equal("drink me",
|
85
|
+
#assert_equal( 3 , browser.div(:id , 'text_fields1').text_fields.length )
|
86
|
+
browser.div(:id, 'text_fields1').text_field(:name, 'div_text1').set("drink me")
|
87
|
+
assert_equal("drink me", browser.div(:id, 'text_fields1').text_field(:name, 'div_text1').value)
|
87
88
|
end
|
88
89
|
|
89
90
|
#---- Span Tests ---
|
90
91
|
def test_spans
|
91
|
-
assert_raises(UnknownObjectException) {
|
92
|
-
assert_raises(UnknownObjectException) {
|
92
|
+
assert_raises(UnknownObjectException) {browser.span(:id , "span77").click }
|
93
|
+
assert_raises(UnknownObjectException) {browser.span(:title , "span77").click }
|
93
94
|
|
94
|
-
assert(
|
95
|
-
|
96
|
-
assert(
|
95
|
+
assert(browser.text_field(:name, "text2").verify_contains("0") )
|
96
|
+
browser.span(:id , "span3").click
|
97
|
+
assert(browser.text_field(:name, "text2").verify_contains("1") )
|
97
98
|
|
98
|
-
|
99
|
-
assert(
|
99
|
+
browser.span(:id , "span4").click
|
100
|
+
assert(browser.text_field(:name, "text2").verify_contains("0") )
|
100
101
|
|
101
|
-
#puts
|
102
|
+
#puts browser.span(:id,"text_fields1").to_s
|
102
103
|
end
|
103
104
|
|
104
105
|
def test_span_properties
|
105
|
-
assert_raises(UnknownObjectException) {
|
106
|
-
assert_raises(UnknownObjectException) {
|
106
|
+
assert_raises(UnknownObjectException) {browser.span(:id , "span77").text }
|
107
|
+
assert_raises(UnknownObjectException) {browser.span(:title , "span77").text }
|
107
108
|
|
108
|
-
assert_equal("This span has an onClick that increments text2" ,
|
109
|
-
assert_equal("This text is in a span with an id of span1 and title of test2" ,
|
109
|
+
assert_equal("This span has an onClick that increments text2" , browser.span(:id , "span3").text.strip )
|
110
|
+
assert_equal("This text is in a span with an id of span1 and title of test2" , browser.span(:title , "Test2").text.strip )
|
110
111
|
|
111
|
-
assert_raises(UnknownObjectException) {
|
112
|
-
assert_equal("blueText" ,
|
113
|
-
assert_equal("" ,
|
112
|
+
assert_raises(UnknownObjectException) {browser.span(:id , "span77").class_name }
|
113
|
+
assert_equal("blueText" , browser.span(:id , "span2").class_name )
|
114
|
+
assert_equal("" , browser.span(:id , "span1").class_name )
|
114
115
|
|
115
|
-
assert_raises(UnknownObjectException) {
|
116
|
-
assert_equal("span1" ,
|
117
|
-
assert_equal("" ,
|
118
|
-
assert_equal("blueText" ,
|
119
|
-
assert_equal("" ,
|
120
|
-
|
121
|
-
assert_equal("" ,
|
122
|
-
assert_equal("span2",
|
116
|
+
assert_raises(UnknownObjectException) {browser.span(:index , 44).class_name }
|
117
|
+
assert_equal("span1" , browser.span(:index , 1).id )
|
118
|
+
assert_equal("" , browser.span(:index , 1).class_name )
|
119
|
+
assert_equal("blueText" , browser.span(:index , 2).class_name )
|
120
|
+
assert_equal("" , browser.span(:index , 2).value)
|
121
|
+
assert_equal(false , browser.span(:index , 2).disabled)
|
122
|
+
assert_equal("" , browser.span(:index , 2).name)
|
123
|
+
assert_equal("span2", browser.span(:index , 2).id)
|
123
124
|
end
|
124
125
|
|
125
126
|
def test_span_iterator
|
126
|
-
assert_equal(7,
|
127
|
-
assert_equal("span1",
|
127
|
+
assert_equal(7, browser.spans.length)
|
128
|
+
assert_equal("span1", browser.spans[1].id)
|
128
129
|
|
129
130
|
index = 1
|
130
|
-
|
131
|
+
browser.spans.each do |s|
|
131
132
|
# puts "each - span = " + s.to_s
|
132
|
-
assert_equal(
|
133
|
-
assert_equal(
|
134
|
-
assert_equal(
|
133
|
+
assert_equal(browser.span(:index, index ).name , s.name )
|
134
|
+
assert_equal(browser.span(:index, index ).id , s.id )
|
135
|
+
assert_equal(browser.span(:index, index ).class_name , s.class_name )
|
135
136
|
index += 1
|
136
137
|
end
|
137
|
-
assert_equal(index - 1,
|
138
|
+
assert_equal(index - 1, browser.spans.length) # -1 as we add 1 at the end of the loop
|
138
139
|
end
|
139
140
|
|
140
141
|
def test_objects_in_span
|
141
|
-
assert(
|
142
|
-
|
143
|
-
assert(
|
142
|
+
assert(browser.span(:id, 'buttons1').button(:index,1).exists? )
|
143
|
+
assert_false(browser.span(:id, 'buttons1').button(:index,3).exists? )
|
144
|
+
assert(browser.span(:id, 'buttons1').button(:name,'b1').exists? )
|
144
145
|
|
145
|
-
assert(
|
146
|
-
assert(
|
147
|
-
|
146
|
+
assert(browser.span(:id, 'buttons2').button(:index,1).exists? )
|
147
|
+
assert(browser.span(:id, 'buttons2').button(:index,2).exists? )
|
148
|
+
assert_false(browser.span(:id, 'buttons1').button(:index,3).exists? )
|
148
149
|
|
149
|
-
|
150
|
+
browser.span(:id, 'buttons1').button(:index,1).click
|
150
151
|
|
151
|
-
assert_equal( 'button1' ,
|
152
|
-
|
153
|
-
assert_equal( 'text box inside span' ,
|
152
|
+
assert_equal( 'button1' , browser.span(:id , 'text_fields1').text_field(:index,1).value)
|
153
|
+
browser.span(:id , 'text_fields1').text_field(:index,1).set('text box inside span')
|
154
|
+
assert_equal( 'text box inside span' , browser.span(:id , 'text_fields1').text_field(:index,1).value)
|
154
155
|
|
155
|
-
#assert_equal( 3 ,
|
156
|
+
#assert_equal( 3 , browser.span(:id , 'text_fields1').text_fields.length )
|
156
157
|
end
|
157
158
|
|
158
159
|
def test_p
|
159
|
-
assert(
|
160
|
-
assert(
|
161
|
-
assert(
|
160
|
+
assert(browser.p(:id, 'number1').exists?)
|
161
|
+
assert(browser.p(:index, 3).exists?)
|
162
|
+
assert(browser.p(:title, 'test_3').exists?)
|
162
163
|
|
163
|
-
|
164
|
-
|
165
|
-
|
164
|
+
assert_false(browser.p(:id, 'missing').exists?)
|
165
|
+
assert_false(browser.p(:index, 8).exists?)
|
166
|
+
assert_false(browser.p(:title, 'test_55').exists?)
|
166
167
|
|
167
|
-
assert_raises( UnknownObjectException) {
|
168
|
-
assert_raises( UnknownObjectException) {
|
169
|
-
assert_raises( UnknownObjectException) {
|
170
|
-
assert_raises( UnknownObjectException) {
|
171
|
-
assert_raises( UnknownObjectException) {
|
168
|
+
assert_raises( UnknownObjectException) {browser.p(:id , 'missing').class_name }
|
169
|
+
assert_raises( UnknownObjectException) {browser.p(:id , 'missing').text }
|
170
|
+
assert_raises( UnknownObjectException) {browser.p(:id , 'missing').title }
|
171
|
+
assert_raises( UnknownObjectException) {browser.p(:id , 'missing').to_s }
|
172
|
+
assert_raises( UnknownObjectException) {browser.p(:id , 'missing').disabled }
|
172
173
|
|
173
|
-
assert_equal( 'redText' ,
|
174
|
-
assert_equal( 'P_tag_1' ,
|
175
|
-
assert_equal( 'This text is in a p with an id of number2' ,
|
174
|
+
assert_equal( 'redText' , browser.p(:index,1).class_name)
|
175
|
+
assert_equal( 'P_tag_1' , browser.p(:index,1).title)
|
176
|
+
assert_equal( 'This text is in a p with an id of number2' , browser.p(:index,2).text)
|
176
177
|
end
|
177
178
|
|
178
179
|
def test_p_iterator
|
179
|
-
assert_equal( 3,
|
180
|
-
assert_equal( 'italicText',
|
181
|
-
assert_equal( 'number3',
|
180
|
+
assert_equal( 3, browser.ps.length)
|
181
|
+
assert_equal( 'italicText', browser.ps[2].class_name)
|
182
|
+
assert_equal( 'number3', browser.ps[3].id)
|
182
183
|
|
183
184
|
count=1
|
184
|
-
|
185
|
+
browser.ps.each do |p|
|
185
186
|
assert_equal('number'+count.to_s , p.id)
|
186
187
|
count+=1
|
187
188
|
end
|
188
|
-
assert_equal( count-1 ,
|
189
|
+
assert_equal( count-1 , browser.ps.length)
|
189
190
|
end
|
190
191
|
end
|
191
192
|
|
192
193
|
class TC_Divs_Display < Test::Unit::TestCase
|
193
|
-
|
194
|
+
|
194
195
|
include MockStdoutTestCase
|
195
196
|
|
197
|
+
tag_method :test_showDivs, :fails_on_ie
|
196
198
|
def test_showDivs
|
197
|
-
|
199
|
+
goto_page("div.html")
|
198
200
|
$stdout = @mockout
|
199
|
-
|
201
|
+
browser.showDivs
|
200
202
|
assert_equal(<<END_OF_MESSAGE, @mockout)
|
201
203
|
There are 7 divs
|
202
204
|
div: name:
|
@@ -232,13 +234,13 @@ END_OF_MESSAGE
|
|
232
234
|
end
|
233
235
|
|
234
236
|
class TC_Spans_Display < Test::Unit::TestCase
|
235
|
-
include FireWatir
|
236
237
|
include MockStdoutTestCase
|
237
238
|
|
239
|
+
tag_method :test_showSpans, :fails_on_ie
|
238
240
|
def test_showSpans
|
239
|
-
|
241
|
+
goto_page("div.html")
|
240
242
|
$stdout = @mockout
|
241
|
-
|
243
|
+
browser.showSpans
|
242
244
|
assert_equal(<<END_OF_MESSAGE, @mockout)
|
243
245
|
There are 7 spans
|
244
246
|
span: name:
|