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
@@ -1,68 +1,69 @@
|
|
1
1
|
# feature tests for Text Fields & Labels
|
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_Fields < Test::Unit::TestCase
|
8
|
-
|
8
|
+
|
9
9
|
|
10
10
|
def setup
|
11
|
-
|
11
|
+
goto_page("textfields1.html")
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_text_field_exists
|
15
|
-
assert(
|
16
|
-
assert_false(
|
15
|
+
assert(browser.text_field(:name, "text1").exists?)
|
16
|
+
assert_false(browser.text_field(:name, "missing").exists?)
|
17
17
|
|
18
|
-
assert(
|
19
|
-
assert_false(
|
18
|
+
assert(browser.text_field(:id, "text2").exists?)
|
19
|
+
assert_false(browser.text_field(:id, "alsomissing").exists?)
|
20
20
|
|
21
21
|
# TODO: Need to find an alternative to this in Mozilla
|
22
|
-
#assert(
|
23
|
-
#assert(
|
22
|
+
#assert(browser.text_field(:beforeText, "This Text After").exists? )
|
23
|
+
#assert(browser.text_field(:afterText, "This Text Before").exists? )
|
24
24
|
|
25
|
-
#assert(
|
26
|
-
#assert(
|
25
|
+
#assert(browser.text_field(:beforeText, /after/i).exists? )
|
26
|
+
#assert(browser.text_field(:afterText, /before/i).exists? )
|
27
27
|
end
|
28
28
|
|
29
29
|
# Drag Contents to in not supported by Mozilla because onDragStart, onDragEnd etc are not
|
30
30
|
# supported in Mozilla
|
31
31
|
#def test_text_field_dragContentsTo
|
32
32
|
|
33
|
-
|
34
|
-
#assert_equal(
|
35
|
-
#assert_equal(
|
33
|
+
#browser.text_field(:name, "text1").dragContentsTo(:id, "text2")
|
34
|
+
#assert_equal(browser.text_field(:name, "text1").value, "")
|
35
|
+
#assert_equal(browser.text_field(:id, "text2").value, "goodbye allHello World")
|
36
36
|
#end
|
37
37
|
|
38
38
|
def test_text_field_verify_contains
|
39
|
-
assert(
|
40
|
-
assert(
|
41
|
-
assert_false(
|
42
|
-
assert_false(
|
43
|
-
assert_raises(UnknownObjectException) {
|
39
|
+
assert(browser.text_field(:name, "text1").verify_contains("Hello World"))
|
40
|
+
assert(browser.text_field(:name, "text1").verify_contains(/Hello\sW/))
|
41
|
+
assert_false(browser.text_field(:name, "text1").verify_contains("Ruby"))
|
42
|
+
assert_false(browser.text_field(:name, "text1").verify_contains(/R/))
|
43
|
+
assert_raises(UnknownObjectException) { browser.text_field(:name, "NoName").verify_contains("No field to get a value of") }
|
44
44
|
|
45
|
-
assert(
|
46
|
-
assert_raises(UnknownObjectException) {
|
45
|
+
assert(browser.text_field(:id, "text2").verify_contains("goodbye all") )
|
46
|
+
assert_raises(UnknownObjectException) { browser.text_field(:id, "noID").verify_contains("No field to get a value of") }
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_text_field_enabled
|
50
|
-
assert_false(
|
51
|
-
assert(
|
52
|
-
assert(
|
50
|
+
assert_false(browser.text_field(:name, "disabled").enabled? )
|
51
|
+
assert(browser.text_field(:name, "text1").enabled? )
|
52
|
+
assert(browser.text_field(:id, "text2").enabled? )
|
53
53
|
end
|
54
54
|
|
55
55
|
def test_text_field_readonly
|
56
|
-
assert_false(
|
57
|
-
assert(
|
58
|
-
assert(
|
56
|
+
assert_false(browser.text_field(:name, "disabled").readonly? )
|
57
|
+
assert(browser.text_field(:name, "readOnly").readonly? )
|
58
|
+
assert(browser.text_field(:id, "readOnly2").readonly? )
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_text_field_get_contents
|
62
|
-
assert_raises(UnknownObjectException) {
|
63
|
-
assert_equal("Hello World",
|
62
|
+
assert_raises(UnknownObjectException) { browser.text_field(:name, "missing_field").append("Some Text") }
|
63
|
+
assert_equal("Hello World", browser.text_field(:name, "text1").value)
|
64
64
|
end
|
65
65
|
|
66
|
+
tag_method :test_text_field_to_s, :fails_on_ie
|
66
67
|
def test_text_field_to_s
|
67
68
|
expected = [
|
68
69
|
"name: text1",
|
@@ -76,141 +77,143 @@ class TC_Fields < Test::Unit::TestCase
|
|
76
77
|
"max length: 500",
|
77
78
|
"length: 0"
|
78
79
|
]
|
79
|
-
assert_equal(expected,
|
80
|
+
assert_equal(expected, browser.text_field(:index, 1).to_s)
|
80
81
|
expected[0] = "name: "
|
81
82
|
expected[2] = "id: text2"
|
82
83
|
expected[3] = "value: goodbye all"
|
83
|
-
assert_equal(expected,
|
84
|
-
assert_raises(UnknownObjectException) {
|
85
|
-
#puts
|
86
|
-
#puts
|
84
|
+
assert_equal(expected, browser.text_field(:index, 2).to_s)
|
85
|
+
assert_raises(UnknownObjectException) { browser.text_field(:index, 999).to_s }
|
86
|
+
#puts browser.text_field(:name, "text1").to_s
|
87
|
+
#puts browser.text_field(:name, "readOnly").to_s
|
87
88
|
end
|
88
89
|
|
89
90
|
def test_text_field_append
|
90
|
-
assert_raises(ObjectReadOnlyException) {
|
91
|
-
assert_raises(ObjectDisabledException) {
|
92
|
-
assert_raises(UnknownObjectException) {
|
91
|
+
assert_raises(ObjectReadOnlyException) { browser.text_field(:id, "readOnly2").append("Some Text") }
|
92
|
+
assert_raises(ObjectDisabledException) { browser.text_field(:name, "disabled").append("Some Text") }
|
93
|
+
assert_raises(UnknownObjectException) { browser.text_field(:name, "missing_field").append("Some Text") }
|
93
94
|
|
94
|
-
|
95
|
-
assert_equal("Hello World Some Text",
|
95
|
+
browser.text_field(:name, "text1").append(" Some Text")
|
96
|
+
assert_equal("Hello World Some Text", browser.text_field(:name, "text1").value)
|
96
97
|
end
|
97
98
|
|
98
99
|
def test_text_field_clear
|
99
|
-
|
100
|
-
assert_equal("",
|
100
|
+
browser.text_field(:name, "text1").clear
|
101
|
+
assert_equal("", browser.text_field(:name, "text1").value)
|
101
102
|
end
|
102
103
|
|
103
104
|
def test_text_field_set
|
104
|
-
|
105
|
-
assert_equal("FireWatir Firefox Controller"
|
105
|
+
browser.text_field(:name, "text1").set("FireWatir Firefox Controller")
|
106
|
+
assert_equal("FireWatir Firefox Controller", browser.text_field(:name, "text1").value)
|
106
107
|
end
|
107
108
|
|
108
109
|
def test_text_field_properties
|
109
|
-
assert_raises(UnknownObjectException) {
|
110
|
-
assert_raises(UnknownObjectException) {
|
111
|
-
assert_raises(UnknownObjectException) {
|
112
|
-
assert_raises(UnknownObjectException) {
|
113
|
-
assert_raises(UnknownObjectException) {
|
110
|
+
assert_raises(UnknownObjectException) { browser.text_field(:index, 199).value }
|
111
|
+
assert_raises(UnknownObjectException) { browser.text_field(:index, 199).name }
|
112
|
+
assert_raises(UnknownObjectException) { browser.text_field(:index, 199).id }
|
113
|
+
assert_raises(UnknownObjectException) { browser.text_field(:index, 199).disabled }
|
114
|
+
assert_raises(UnknownObjectException) { browser.text_field(:index, 199).type }
|
114
115
|
|
115
|
-
assert_equal("Hello World" ,
|
116
|
-
assert_equal("text" ,
|
117
|
-
assert_equal("text1" ,
|
118
|
-
assert_equal("" ,
|
119
|
-
assert_equal(false ,
|
116
|
+
assert_equal("Hello World" , browser.text_field(:index, 1).value)
|
117
|
+
assert_equal("text" , browser.text_field(:index, 1).type)
|
118
|
+
assert_equal("text1" , browser.text_field(:index, 1).name)
|
119
|
+
assert_equal("" , browser.text_field(:index, 1).id)
|
120
|
+
assert_equal(false , browser.text_field(:index, 1).disabled)
|
120
121
|
|
121
|
-
assert_equal("" ,
|
122
|
-
assert_equal("text2" ,
|
122
|
+
assert_equal("" , browser.text_field(:index, 2).name)
|
123
|
+
assert_equal("text2" , browser.text_field(:index, 2).id)
|
123
124
|
|
124
|
-
assert(
|
125
|
+
assert(browser.text_field(:index, 3).disabled)
|
125
126
|
|
126
|
-
assert_equal("This used to test :afterText",
|
127
|
-
assert_equal("",
|
127
|
+
assert_equal("This used to test :afterText", browser.text_field(:name, "aftertest").title)
|
128
|
+
assert_equal("", browser.text_field(:index, 1).title)
|
128
129
|
end
|
129
130
|
|
130
131
|
def test_text_field_iterators
|
131
|
-
assert_equal(12,
|
132
|
+
assert_equal(12, browser.text_fields.length)
|
132
133
|
|
133
134
|
# watir is 1 based, so this is the first text field
|
134
|
-
assert_equal("Hello World" ,
|
135
|
-
assert_equal("text1" ,
|
136
|
-
assert_equal("password" ,
|
135
|
+
assert_equal("Hello World" , browser.text_fields[1].value)
|
136
|
+
assert_equal("text1" , browser.text_fields[1].name)
|
137
|
+
assert_equal("password" , browser.text_fields[browser.text_fields.length].type)
|
137
138
|
|
138
139
|
index = 1
|
139
|
-
|
140
|
-
assert_equal(
|
141
|
-
assert_equal(
|
142
|
-
assert_equal(
|
140
|
+
browser.text_fields.each do |t|
|
141
|
+
assert_equal(browser.text_field(:index, index).value, t.value)
|
142
|
+
assert_equal(browser.text_field(:index, index).id, t.id)
|
143
|
+
assert_equal(browser.text_field(:index, index).name, t.name)
|
143
144
|
index += 1
|
144
145
|
end
|
145
|
-
assert_equal(index - 1,
|
146
|
+
assert_equal(index - 1, browser.text_fields.length)
|
146
147
|
end
|
147
148
|
|
149
|
+
tag_method :test_JS_Events, :fails_on_ie
|
148
150
|
def test_JS_Events
|
149
|
-
|
151
|
+
browser.text_field(:name, 'events_tester').set('p')
|
150
152
|
|
151
153
|
# the following line has an extra keypress at the begining, as we mimic the delete key being pressed
|
152
|
-
assert_equal( "keypresskeydownkeypresskeyup" ,
|
153
|
-
|
154
|
-
|
154
|
+
assert_equal( "keypresskeydownkeypresskeyup" , browser.text_field(:name , 'events_text').value.gsub("\n" , "") )
|
155
|
+
browser.button(:value , "Clear Events Box").click
|
156
|
+
browser.text_field(:name , 'events_tester').set('ab')
|
155
157
|
|
156
158
|
# the following line has an extra keypress at the begining, as we mimic the delete key being pressed
|
157
|
-
assert_equal( "keypresskeydownkeypresskeyupkeydownkeypresskeyup" ,
|
159
|
+
assert_equal( "keypresskeydownkeypresskeyupkeydownkeypresskeyup" , browser.text_field(:name , 'events_text').value.gsub("\n" , "") )
|
158
160
|
|
159
|
-
|
160
|
-
|
161
|
-
|
161
|
+
browser.text_field(:name, "events_text").set("angrez\nsingh")
|
162
|
+
browser.text_field(:name, "events_text").append("\n")
|
163
|
+
browser.text_field(:name, "events_text").append("singh") #\\nsupel")
|
162
164
|
end
|
163
165
|
|
164
166
|
def test_password
|
165
|
-
|
166
|
-
assert( 'secret' ,
|
167
|
+
browser.text_field(:name , "password1").set("secret")
|
168
|
+
assert( 'secret' , browser.text_field(:name , "password1").value )
|
167
169
|
|
168
|
-
|
169
|
-
assert( 'top_secret' ,
|
170
|
+
browser.text_field(:id , "password1").set("top_secret")
|
171
|
+
assert( 'top_secret' , browser.text_field(:id, "password1").value )
|
170
172
|
end
|
171
173
|
|
172
174
|
def test_labels_iterator
|
173
|
-
assert_equal(3,
|
174
|
-
assert_equal('Label For this Field' ,
|
175
|
-
assert_equal('Password With ID ( the text here is a label for it )' ,
|
175
|
+
assert_equal(3, browser.labels.length)
|
176
|
+
assert_equal('Label For this Field' , browser.labels[1].innerText.strip )
|
177
|
+
assert_equal('Password With ID ( the text here is a label for it )' , browser.labels[3].innerText )
|
176
178
|
|
177
179
|
count=0
|
178
|
-
|
180
|
+
browser.labels.each do |l|
|
179
181
|
count +=1
|
180
182
|
end
|
181
|
-
assert_equal(count,
|
183
|
+
assert_equal(count, browser.labels.length)
|
182
184
|
end
|
183
185
|
|
184
186
|
def test_label_properties
|
185
|
-
assert_raises(UnknownObjectException) {
|
186
|
-
assert_raises(UnknownObjectException) {
|
187
|
-
assert_raises(UnknownObjectException) {
|
188
|
-
assert_raises(UnknownObjectException) {
|
189
|
-
assert_raises(UnknownObjectException) {
|
190
|
-
|
191
|
-
assert_false(
|
192
|
-
assert_false(
|
193
|
-
assert(
|
187
|
+
assert_raises(UnknownObjectException) { browser.label(:index,20).innerText }
|
188
|
+
assert_raises(UnknownObjectException) { browser.label(:index,20).for }
|
189
|
+
assert_raises(UnknownObjectException) { browser.label(:index,20).name }
|
190
|
+
assert_raises(UnknownObjectException) { browser.label(:index,20).type }
|
191
|
+
assert_raises(UnknownObjectException) { browser.label(:index,20).id }
|
192
|
+
|
193
|
+
assert_false(browser.label(:index,10).exists?)
|
194
|
+
assert_false(browser.label(:id,'missing').exists?)
|
195
|
+
assert(browser.label(:index,1).exists?)
|
194
196
|
|
195
|
-
assert_equal("",
|
196
|
-
|
197
|
-
assert(
|
197
|
+
assert_equal("", browser.label(:index,1).id)
|
198
|
+
assert_false( browser.label(:index,1).disabled?)
|
199
|
+
assert( browser.label(:index,1).enabled?)
|
198
200
|
|
199
|
-
assert_equal("label2",
|
201
|
+
assert_equal("label2", browser.label(:index,2).id )
|
200
202
|
|
201
|
-
assert_equal("Password With ID ( the text here is a label for it )" ,
|
202
|
-
assert_equal("password1",
|
203
|
+
assert_equal("Password With ID ( the text here is a label for it )" , browser.label(:index,3).innerText)
|
204
|
+
assert_equal("password1", browser.label(:index,3).for)
|
203
205
|
end
|
204
206
|
end
|
205
207
|
|
206
208
|
class TC_Labels_Display < Test::Unit::TestCase
|
207
|
-
|
209
|
+
|
208
210
|
include MockStdoutTestCase
|
209
211
|
|
212
|
+
tag_method :test_showLabels, :fails_on_ie
|
210
213
|
def test_showLabels
|
211
|
-
|
214
|
+
goto_page("textfields1.html")
|
212
215
|
$stdout = @mockout
|
213
|
-
|
216
|
+
browser.showLabels
|
214
217
|
assert_equal(<<END_OF_MESSAGE, @mockout)
|
215
218
|
There are 3 labels
|
216
219
|
label: name:
|
@@ -1,60 +1,60 @@
|
|
1
1
|
# feature tests for Text Fields
|
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_Fields_XPath < Test::Unit::TestCase
|
8
|
-
|
8
|
+
|
9
9
|
|
10
10
|
def setup()
|
11
|
-
|
11
|
+
goto_page("textfields1.html")
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_text_field_exists
|
15
|
-
assert(
|
16
|
-
assert_false(
|
15
|
+
assert(browser.text_field(:xpath , "//input[@name='text1']").exists?)
|
16
|
+
assert_false(browser.text_field(:xpath , "//input[@name='missing']").exists?)
|
17
17
|
|
18
|
-
assert(
|
19
|
-
assert_false(
|
18
|
+
assert(browser.text_field(:xpath , "//input[@id='text2']").exists?)
|
19
|
+
assert_false(browser.text_field(:xpath , "//input[@id='alsomissing']").exists?)
|
20
20
|
|
21
|
-
#assert(
|
22
|
-
#assert(
|
21
|
+
#assert(browser.text_field(:xpath , "//input[@beforeText='This Text After']").exists? )
|
22
|
+
#assert(browser.text_field(:xpath , "//input[@afterText='This Text Before']").exists? )
|
23
23
|
end
|
24
24
|
|
25
25
|
# Not supported by Mozilla
|
26
26
|
#def test_text_field_dragContentsTo
|
27
|
-
#
|
28
|
-
# assert_equal(
|
29
|
-
# assert_equal(
|
27
|
+
# browser.text_field(:xpath , "//input[@name='text1']").dragContentsTo(:xpath , "//input[@id='text2']/")
|
28
|
+
# assert_equal(browser.text_field(:xpath , "//input[@name='text1']").value, "" )
|
29
|
+
# assert_equal(browser.text_field(:xpath , "//input[@id='text2']").value, "goodbye allHello World" )
|
30
30
|
#end
|
31
31
|
|
32
32
|
def test_text_field_VerifyContents
|
33
|
-
assert(
|
34
|
-
assert(
|
35
|
-
assert_false(
|
36
|
-
assert_false(
|
37
|
-
assert_raises(UnknownObjectException
|
38
|
-
|
39
|
-
assert(
|
40
|
-
assert_raises(UnknownObjectException
|
33
|
+
assert(browser.text_field(:xpath , "//input[@name='text1']").verify_contains("Hello World") )
|
34
|
+
assert(browser.text_field(:xpath , "//input[@name='text1']").verify_contains(/Hello\sW/ ) )
|
35
|
+
assert_false(browser.text_field(:xpath , "//input[@name='text1']").verify_contains("Ruby") )
|
36
|
+
assert_false(browser.text_field(:xpath , "//input[@name='text1']").verify_contains(/R/) )
|
37
|
+
assert_raises(UnknownObjectException) { browser.text_field(:xpath , "//input[@name='NoName']").verify_contains("No field to get a value of") }
|
38
|
+
|
39
|
+
assert(browser.text_field(:xpath , "//input[@id='text2']").verify_contains("goodbye all") )
|
40
|
+
assert_raises(UnknownObjectException) { browser.text_field(:xpath , "//input[@id='noID']").verify_contains("No field to get a value of") }
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_text_field_enabled
|
44
|
-
assert_false(
|
45
|
-
assert(
|
46
|
-
assert(
|
44
|
+
assert_false(browser.text_field(:xpath , "//input[@name='disabled']").enabled? )
|
45
|
+
assert(browser.text_field(:xpath , "//input[@name='text1']").enabled? )
|
46
|
+
assert(browser.text_field(:xpath , "//input[@id='text2']").enabled? )
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_text_field_readOnly
|
50
|
-
assert_false(
|
51
|
-
assert(
|
52
|
-
assert(
|
50
|
+
assert_false(browser.text_field(:xpath , "//input[@name='disabled']").readonly? )
|
51
|
+
assert(browser.text_field(:xpath , "//input[@name='readOnly']").readonly? )
|
52
|
+
assert(browser.text_field(:xpath , "//input[@id='readOnly2']").readonly? )
|
53
53
|
end
|
54
54
|
|
55
55
|
def test_text_field_value()
|
56
|
-
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) {
|
57
|
-
assert_equal( "Hello World" ,
|
56
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@name='missing_field']").append("Some Text") }
|
57
|
+
assert_equal( "Hello World" , browser.text_field(:xpath , "//input[@name='text1']").value )
|
58
58
|
end
|
59
59
|
|
60
60
|
def build_to_s_regex(lhs, rhs)
|
@@ -62,51 +62,52 @@ class TC_Fields_XPath < Test::Unit::TestCase
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_text_field_Append
|
65
|
-
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) {
|
66
|
-
assert_raises(ObjectDisabledException , "ObjectDisabledException was supposed to be thrown" ) {
|
67
|
-
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) {
|
65
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@id='readOnly2']").append("Some Text") }
|
66
|
+
assert_raises(ObjectDisabledException , "ObjectDisabledException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@name='disabled']").append("Some Text") }
|
67
|
+
assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@name='missing_field']").append("Some Text") }
|
68
68
|
|
69
|
-
|
70
|
-
assert_equal( "Hello World Some Text" ,
|
69
|
+
browser.text_field(:xpath , "//input[@name='text1']").append(" Some Text")
|
70
|
+
assert_equal( "Hello World Some Text" , browser.text_field(:xpath , "//input[@name='text1']").value )
|
71
71
|
end
|
72
72
|
|
73
73
|
|
74
74
|
def test_text_field_Clear
|
75
|
-
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) {
|
76
|
-
assert_raises(ObjectDisabledException , "ObjectReadOnlyException was supposed to be thrown" ) {
|
77
|
-
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) {
|
75
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@id='readOnly2']").append("Some Text") }
|
76
|
+
assert_raises(ObjectDisabledException , "ObjectReadOnlyException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@name='disabled']").append("Some Text") }
|
77
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@name='missing_field']").append("Some Text") }
|
78
78
|
|
79
|
-
|
80
|
-
assert_equal( "" ,
|
79
|
+
browser.text_field(:xpath , "//input[@name='text1']").clear()
|
80
|
+
assert_equal( "" , browser.text_field(:xpath , "//input[@name='text1']").value )
|
81
81
|
end
|
82
82
|
|
83
83
|
def test_text_field_Set
|
84
|
-
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) {
|
85
|
-
assert_raises(ObjectDisabledException , "ObjectReadOnlyException was supposed to be thrown" ) {
|
86
|
-
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) {
|
84
|
+
assert_raises(ObjectReadOnlyException , "ObjectReadOnlyException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@id='readOnly2']").append("Some Text") }
|
85
|
+
assert_raises(ObjectDisabledException , "ObjectReadOnlyException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@name='disabled']").append("Some Text") }
|
86
|
+
assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { browser.text_field(:xpath , "//input[@name='missing_field']").append("Some Text") }
|
87
87
|
|
88
|
-
|
89
|
-
assert_equal( "FireWatir Firefox Controller" ,
|
88
|
+
browser.text_field(:xpath , "//input[@name='text1']").set("FireWatir Firefox Controller")
|
89
|
+
assert_equal( "FireWatir Firefox Controller" , browser.text_field(:xpath , "//input[@name='text1']").value )
|
90
90
|
end
|
91
91
|
|
92
|
+
tag_method :test_JS_Events, :fails_on_ie
|
92
93
|
def test_JS_Events
|
93
|
-
|
94
|
+
browser.text_field(:xpath , "//input[@name='events_tester']").set('p')
|
94
95
|
|
95
96
|
# the following line has an extra keypress at the begining, as we mimic the delete key being pressed
|
96
|
-
assert_equal( "keypresskeydownkeypresskeyup" ,
|
97
|
-
|
98
|
-
|
97
|
+
assert_equal( "keypresskeydownkeypresskeyup" , browser.text_field(:xpath , "//textarea[@name='events_text']").value.gsub("\n" , "") )
|
98
|
+
browser.button(:xpath , "//input[@value = 'Clear Events Box']").click
|
99
|
+
browser.text_field(:xpath , "//input[@name='events_tester']").set('ab')
|
99
100
|
|
100
101
|
# the following line has an extra keypress at the begining, as we mimic the delete key being pressed
|
101
|
-
assert_equal( "keypresskeydownkeypresskeyupkeydownkeypresskeyup" ,
|
102
|
+
assert_equal( "keypresskeydownkeypresskeyupkeydownkeypresskeyup" , browser.text_field(:xpath , "//textarea[@name='events_text']").value.gsub("\n" , "") )
|
102
103
|
end
|
103
104
|
|
104
105
|
def test_password
|
105
|
-
|
106
|
-
assert( 'secret' ,
|
106
|
+
browser.text_field(:xpath , "//input[@name='password1']").set("secret")
|
107
|
+
assert( 'secret' , browser.text_field(:xpath , "//input[@name='password1']").value )
|
107
108
|
|
108
|
-
|
109
|
-
assert( 'top_secret' ,
|
109
|
+
browser.text_field(:xpath , "//input[@id='password1']").set("top_secret")
|
110
|
+
assert( 'top_secret' , browser.text_field(:xpath , "//input[@id='password1']").value )
|
110
111
|
end
|
111
112
|
|
112
113
|
end
|