firewatir 1.2.1 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/lib/firewatir.rb +50 -0
  2. data/lib/firewatir/MozillaBaseElement.rb +1863 -0
  3. data/lib/firewatir/container.rb +534 -0
  4. data/lib/firewatir/exceptions.rb +10 -0
  5. data/lib/firewatir/firefox.rb +1127 -0
  6. data/lib/firewatir/htmlelements.rb +1911 -0
  7. data/lib/firewatir/version.rb +5 -0
  8. data/{firewatir → lib/firewatir}/winClicker.rb +0 -0
  9. data/{firewatir → lib/firewatir}/x11.rb +0 -0
  10. data/unittests/attach_to_new_window_test.rb +20 -12
  11. data/unittests/bug_fixes_test.rb +79 -69
  12. data/unittests/buttons_xpath_test.rb +45 -44
  13. data/unittests/checkbox_test.rb +86 -85
  14. data/unittests/checkbox_xpath_test.rb +58 -58
  15. data/unittests/div_test.rb +117 -115
  16. data/unittests/filefield_test.rb +12 -12
  17. data/unittests/filefield_xpath_test.rb +11 -11
  18. data/unittests/form_test.rb +134 -133
  19. data/unittests/frame_test.rb +42 -41
  20. data/unittests/hidden_test.rb +40 -40
  21. data/unittests/hidden_xpath_test.rb +32 -32
  22. data/unittests/images_test.rb +85 -84
  23. data/unittests/images_xpath_test.rb +57 -56
  24. data/unittests/iostring_test.rb +1 -1
  25. data/unittests/javascript_test.rb +42 -38
  26. data/unittests/links_test.rb +88 -86
  27. data/unittests/links_xpath_test.rb +38 -38
  28. data/unittests/mozilla_all_tests.rb +2 -14
  29. data/unittests/pre_test.rb +27 -25
  30. data/unittests/radios_test.rb +86 -86
  31. data/unittests/radios_xpath_test.rb +48 -48
  32. data/unittests/redirect_test.rb +20 -19
  33. data/unittests/selectbox_test.rb +72 -71
  34. data/unittests/selectbox_xpath_test.rb +58 -56
  35. data/unittests/setup.rb +22 -27
  36. data/unittests/table_test.rb +89 -88
  37. data/unittests/table_xpath_test.rb +37 -36
  38. data/unittests/textfields_test.rb +105 -102
  39. data/unittests/textfields_xpath_test.rb +53 -52
  40. metadata +37 -18
  41. data/MozillaBaseElement.rb +0 -1780
  42. data/container.rb +0 -900
  43. data/firewatir.rb +0 -1195
  44. data/firewatir/exceptions.rb +0 -44
  45. data/firewatir/testUnitAddons.rb +0 -8
  46. data/htmlelements.rb +0 -2281
  47. 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__), '..') if $0 == __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
- include FireWatir
8
+
9
9
 
10
10
  def setup
11
- $ff.goto($htmlRoot + "textfields1.html")
11
+ goto_page("textfields1.html")
12
12
  end
13
13
 
14
14
  def test_text_field_exists
15
- assert($ff.text_field(:name, "text1").exists?)
16
- assert_false($ff.text_field(:name, "missing").exists?)
15
+ assert(browser.text_field(:name, "text1").exists?)
16
+ assert_false(browser.text_field(:name, "missing").exists?)
17
17
 
18
- assert($ff.text_field(:id, "text2").exists?)
19
- assert_false($ff.text_field(:id, "alsomissing").exists?)
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($ff.text_field(:beforeText, "This Text After").exists? )
23
- #assert($ff.text_field(:afterText, "This Text Before").exists? )
22
+ #assert(browser.text_field(:beforeText, "This Text After").exists? )
23
+ #assert(browser.text_field(:afterText, "This Text Before").exists? )
24
24
 
25
- #assert($ff.text_field(:beforeText, /after/i).exists? )
26
- #assert($ff.text_field(:afterText, /before/i).exists? )
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
- #$ff.text_field(:name, "text1").dragContentsTo(:id, "text2")
34
- #assert_equal($ff.text_field(:name, "text1").value, "")
35
- #assert_equal($ff.text_field(:id, "text2").value, "goodbye allHello World")
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($ff.text_field(:name, "text1").verify_contains("Hello World"))
40
- assert($ff.text_field(:name, "text1").verify_contains(/Hello\sW/))
41
- assert_false($ff.text_field(:name, "text1").verify_contains("Ruby"))
42
- assert_false($ff.text_field(:name, "text1").verify_contains(/R/))
43
- assert_raises(UnknownObjectException) { $ff.text_field(:name, "NoName").verify_contains("No field to get a value of") }
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($ff.text_field(:id, "text2").verify_contains("goodbye all") )
46
- assert_raises(UnknownObjectException) { $ff.text_field(:id, "noID").verify_contains("No field to get a value of") }
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($ff.text_field(:name, "disabled").enabled? )
51
- assert($ff.text_field(:name, "text1").enabled? )
52
- assert($ff.text_field(:id, "text2").enabled? )
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($ff.text_field(:name, "disabled").readonly? )
57
- assert($ff.text_field(:name, "readOnly").readonly? )
58
- assert($ff.text_field(:id, "readOnly2").readonly? )
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) { $ff.text_field(:name, "missing_field").append("Some Text") }
63
- assert_equal("Hello World", $ff.text_field(:name, "text1").value)
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, $ff.text_field(:index, 1).to_s)
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, $ff.text_field(:index, 2).to_s)
84
- assert_raises(UnknownObjectException) { $ff.text_field(:index, 999).to_s }
85
- #puts $ff.text_field(:name, "text1").to_s
86
- #puts $ff.text_field(:name, "readOnly").to_s
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) { $ff.text_field(:id, "readOnly2").append("Some Text") }
91
- assert_raises(ObjectDisabledException) { $ff.text_field(:name, "disabled").append("Some Text") }
92
- assert_raises(UnknownObjectException) { $ff.text_field(:name, "missing_field").append("Some Text") }
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
- $ff.text_field(:name, "text1").append(" Some Text")
95
- assert_equal("Hello World Some Text", $ff.text_field(:name, "text1").value)
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
- $ff.text_field(:name, "text1").clear
100
- assert_equal("", $ff.text_field(:name, "text1").value)
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
- $ff.text_field(:name, "text1").set("FireWatir Firefox Controller")
105
- assert_equal("FireWatir Firefox Controller" , $ff.text_field(:name, "text1").value)
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) { $ff.text_field(:index, 199).value }
110
- assert_raises(UnknownObjectException) { $ff.text_field(:index, 199).name }
111
- assert_raises(UnknownObjectException) { $ff.text_field(:index, 199).id }
112
- assert_raises(UnknownObjectException) { $ff.text_field(:index, 199).disabled }
113
- assert_raises(UnknownObjectException) { $ff.text_field(:index, 199).type }
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" , $ff.text_field(:index, 1).value)
116
- assert_equal("text" , $ff.text_field(:index, 1).type)
117
- assert_equal("text1" , $ff.text_field(:index, 1).name)
118
- assert_equal("" , $ff.text_field(:index, 1).id)
119
- assert_equal(false , $ff.text_field(:index, 1).disabled)
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("" , $ff.text_field(:index, 2).name)
122
- assert_equal("text2" , $ff.text_field(:index, 2).id)
122
+ assert_equal("" , browser.text_field(:index, 2).name)
123
+ assert_equal("text2" , browser.text_field(:index, 2).id)
123
124
 
124
- assert($ff.text_field(:index, 3).disabled)
125
+ assert(browser.text_field(:index, 3).disabled)
125
126
 
126
- assert_equal("This used to test :afterText", $ff.text_field(:name, "aftertest").title)
127
- assert_equal("", $ff.text_field(:index, 1).title)
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, $ff.text_fields.length)
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" , $ff.text_fields[1].value)
135
- assert_equal("text1" , $ff.text_fields[1].name)
136
- assert_equal("password" , $ff.text_fields[$ff.text_fields.length].type)
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
- $ff.text_fields.each do |t|
140
- assert_equal($ff.text_field(:index, index).value, t.value)
141
- assert_equal($ff.text_field(:index, index).id, t.id)
142
- assert_equal($ff.text_field(:index, index).name, t.name)
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, $ff.text_fields.length)
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
- $ff.text_field(:name, 'events_tester').set('p')
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" , $ff.text_field(:name , 'events_text').value.gsub("\n" , "") )
153
- $ff.button(:value , "Clear Events Box").click
154
- $ff.text_field(:name , 'events_tester').set('ab')
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" , $ff.text_field(:name , 'events_text').value.gsub("\n" , "") )
159
+ assert_equal( "keypresskeydownkeypresskeyupkeydownkeypresskeyup" , browser.text_field(:name , 'events_text').value.gsub("\n" , "") )
158
160
 
159
- $ff.text_field(:name, "events_text").set("angrez\nsingh")
160
- $ff.text_field(:name, "events_text").append("\n")
161
- $ff.text_field(:name, "events_text").append("singh") #\\nsupel")
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
- $ff.text_field(:name , "password1").set("secret")
166
- assert( 'secret' , $ff.text_field(:name , "password1").value )
167
+ browser.text_field(:name , "password1").set("secret")
168
+ assert( 'secret' , browser.text_field(:name , "password1").value )
167
169
 
168
- $ff.text_field(:id , "password1").set("top_secret")
169
- assert( 'top_secret' , $ff.text_field(:id, "password1").value )
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, $ff.labels.length)
174
- assert_equal('Label For this Field' , $ff.labels[1].innerText.strip )
175
- assert_equal('Password With ID ( the text here is a label for it )' , $ff.labels[3].innerText )
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
- $ff.labels.each do |l|
180
+ browser.labels.each do |l|
179
181
  count +=1
180
182
  end
181
- assert_equal(count, $ff.labels.length)
183
+ assert_equal(count, browser.labels.length)
182
184
  end
183
185
 
184
186
  def test_label_properties
185
- assert_raises(UnknownObjectException) { $ff.label(:index,20).innerText }
186
- assert_raises(UnknownObjectException) { $ff.label(:index,20).for }
187
- assert_raises(UnknownObjectException) { $ff.label(:index,20).name }
188
- assert_raises(UnknownObjectException) { $ff.label(:index,20).type }
189
- assert_raises(UnknownObjectException) { $ff.label(:index,20).id }
190
-
191
- assert_false($ff.label(:index,10).exists?)
192
- assert_false($ff.label(:id,'missing').exists?)
193
- assert($ff.label(:index,1).exists?)
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("", $ff.label(:index,1).id)
196
- #assert_false( $ff.label(:index,1).disabled?)
197
- assert( $ff.label(:index,1).enabled?)
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", $ff.label(:index,2).id )
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 )" , $ff.label(:index,3).innerText)
202
- assert_equal("password1", $ff.label(:index,3).for)
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
- include FireWatir
209
+
208
210
  include MockStdoutTestCase
209
211
 
212
+ tag_method :test_showLabels, :fails_on_ie
210
213
  def test_showLabels
211
- $ff.goto($htmlRoot + "textfields1.html")
214
+ goto_page("textfields1.html")
212
215
  $stdout = @mockout
213
- $ff.showLabels
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__), '..') if $0 == __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
- include FireWatir
8
+
9
9
 
10
10
  def setup()
11
- $ff.goto($htmlRoot + "textfields1.html")
11
+ goto_page("textfields1.html")
12
12
  end
13
13
 
14
14
  def test_text_field_exists
15
- assert($ff.text_field(:xpath , "//input[@name='text1']").exists?)
16
- assert_false($ff.text_field(:xpath , "//input[@name='missing']").exists?)
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($ff.text_field(:xpath , "//input[@id='text2']").exists?)
19
- assert_false($ff.text_field(:xpath , "//input[@id='alsomissing']").exists?)
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($ff.text_field(:xpath , "//input[@beforeText='This Text After']").exists? )
22
- #assert($ff.text_field(:xpath , "//input[@afterText='This Text Before']").exists? )
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
- # $ff.text_field(:xpath , "//input[@name='text1']").dragContentsTo(:xpath , "//input[@id='text2']/")
28
- # assert_equal($ff.text_field(:xpath , "//input[@name='text1']").value, "" )
29
- # assert_equal($ff.text_field(:xpath , "//input[@id='text2']").value, "goodbye allHello World" )
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($ff.text_field(:xpath , "//input[@name='text1']").verify_contains("Hello World") )
34
- assert($ff.text_field(:xpath , "//input[@name='text1']").verify_contains(/Hello\sW/ ) )
35
- assert_false($ff.text_field(:xpath , "//input[@name='text1']").verify_contains("Ruby") )
36
- assert_false($ff.text_field(:xpath , "//input[@name='text1']").verify_contains(/R/) )
37
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.text_field(:xpath , "//input[@name='NoName']").verify_contains("No field to get a value of") }
38
-
39
- assert($ff.text_field(:xpath , "//input[@id='text2']").verify_contains("goodbye all") )
40
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.text_field(:xpath , "//input[@id='noID']").verify_contains("No field to get a value of") }
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($ff.text_field(:xpath , "//input[@name='disabled']").enabled? )
45
- assert($ff.text_field(:xpath , "//input[@name='text1']").enabled? )
46
- assert($ff.text_field(:xpath , "//input[@id='text2']").enabled? )
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($ff.text_field(:xpath , "//input[@name='disabled']").readonly? )
51
- assert($ff.text_field(:xpath , "//input[@name='readOnly']").readonly? )
52
- assert($ff.text_field(:xpath , "//input[@id='readOnly2']").readonly? )
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" ) { $ff.text_field(:xpath , "//input[@name='missing_field']").append("Some Text") }
57
- assert_equal( "Hello World" , $ff.text_field(:xpath , "//input[@name='text1']").value )
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" ) { $ff.text_field(:xpath , "//input[@id='readOnly2']").append("Some Text") }
66
- assert_raises(ObjectDisabledException , "ObjectDisabledException was supposed to be thrown" ) { $ff.text_field(:xpath , "//input[@name='disabled']").append("Some Text") }
67
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.text_field(:xpath , "//input[@name='missing_field']").append("Some Text") }
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
- $ff.text_field(:xpath , "//input[@name='text1']").append(" Some Text")
70
- assert_equal( "Hello World Some Text" , $ff.text_field(:xpath , "//input[@name='text1']").value )
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" ) { $ff.text_field(:xpath , "//input[@id='readOnly2']").append("Some Text") }
76
- assert_raises(ObjectDisabledException , "ObjectReadOnlyException was supposed to be thrown" ) { $ff.text_field(:xpath , "//input[@name='disabled']").append("Some Text") }
77
- assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { $ff.text_field(:xpath , "//input[@name='missing_field']").append("Some Text") }
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
- $ff.text_field(:xpath , "//input[@name='text1']").clear()
80
- assert_equal( "" , $ff.text_field(:xpath , "//input[@name='text1']").value )
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" ) { $ff.text_field(:xpath , "//input[@id='readOnly2']").append("Some Text") }
85
- assert_raises(ObjectDisabledException , "ObjectReadOnlyException was supposed to be thrown" ) { $ff.text_field(:xpath , "//input[@name='disabled']").append("Some Text") }
86
- assert_raises(UnknownObjectException , "ObjectReadOnlyException was supposed to be thrown" ) { $ff.text_field(:xpath , "//input[@name='missing_field']").append("Some Text") }
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
- $ff.text_field(:xpath , "//input[@name='text1']").set("FireWatir Firefox Controller")
89
- assert_equal( "FireWatir Firefox Controller" , $ff.text_field(:xpath , "//input[@name='text1']").value )
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
- $ff.text_field(:xpath , "//input[@name='events_tester']").set('p')
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" , $ff.text_field(:xpath , "//textarea[@name='events_text']").value.gsub("\n" , "") )
97
- $ff.button(:xpath , "//input[@value = 'Clear Events Box']").click
98
- $ff.text_field(:xpath , "//input[@name='events_tester']").set('ab')
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" , $ff.text_field(:xpath , "//textarea[@name='events_text']").value.gsub("\n" , "") )
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
- $ff.text_field(:xpath , "//input[@name='password1']").set("secret")
106
- assert( 'secret' , $ff.text_field(:xpath , "//input[@name='password1']").value )
106
+ browser.text_field(:xpath , "//input[@name='password1']").set("secret")
107
+ assert( 'secret' , browser.text_field(:xpath , "//input[@name='password1']").value )
107
108
 
108
- $ff.text_field(:xpath , "//input[@id='password1']").set("top_secret")
109
- assert( 'top_secret' , $ff.text_field(:xpath , "//input[@id='password1']").value )
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