firewatir 1.2.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,5 @@
1
+ module FireWatir
2
+ class Firefox
3
+ VERSION = '1.6.2'
4
+ end
5
+ end
File without changes
File without changes
@@ -1,34 +1,42 @@
1
1
  # feature tests for attaching to new Firefox windows
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_NewWindow < Test::Unit::TestCase
8
- include FireWatir
8
+ tags :fails_on_ie
9
9
 
10
10
  def setup
11
- $ff.goto($htmlRoot + "new_browser.html")
11
+ goto_page("new_browser.html")
12
12
  end
13
13
 
14
14
  def test_simply_attach_to_new_window_using_title
15
- $ff.link(:text, 'New Window').click
16
- ff_new = $ff.attach(:title, 'Pass Page')
15
+ browser.link(:text, 'New Window').click
16
+ begin
17
+ ff_new = browser.attach(:title, 'Pass Page')
18
+ rescue Watir::Exception::NoMatchingWindowFoundException
19
+ raise $!, "Attach failed, check your Firefox settings: http://wiki.openqa.org/display/WTR/FireWatir+Installation#FireWatirInstallation-ffsettings"
20
+ end
17
21
  assert(ff_new.text.include?('PASS'))
18
22
  ff_new.close
19
- #$ff.link(:text, 'New Window').click
23
+ #browser.link(:text, 'New Window').click
20
24
  end
21
25
 
22
26
  def test_simply_attach_to_new_window_using_url
23
- $ff.link(:text, 'New Window').click
24
- ff_new = $ff.attach(:url, /pass\.html/)
27
+ browser.link(:text, 'New Window').click
28
+ begin
29
+ ff_new = browser.attach(:url, /pass\.html/)
30
+ rescue Watir::Exception::NoMatchingWindowFoundException
31
+ raise $!, "Attach failed, check your Firefox settings: http://wiki.openqa.org/display/WTR/FireWatir+Installation#FireWatirInstallation-ffsettings"
32
+ end
25
33
  assert(ff_new.text.include?('PASS'))
26
34
  ff_new.close
27
- #$ff.link(:text, 'New Window').click
35
+ #browser.link(:text, 'New Window').click
28
36
  end
29
37
 
30
- def test_new_window_exists
31
- assert_raises(NoMatchingWindowFoundException , "NoMatchingWindowFoundException was supposed to be thrown" ) { $ff.attach(:title, "missing_title") }
32
- assert_raises(NoMatchingWindowFoundException , "NoMatchingWindowFoundException was supposed to be thrown" ) { $ff.attach(:url, "missing_url") }
38
+ def test_new_window_exists
39
+ assert_raises(NoMatchingWindowFoundException , "NoMatchingWindowFoundException was supposed to be thrown" ) { browser.attach(:title, "missing_title") }
40
+ assert_raises(NoMatchingWindowFoundException , "NoMatchingWindowFoundException was supposed to be thrown" ) { browser.attach(:url, "missing_url") }
33
41
  end
34
42
  end
@@ -1,15 +1,16 @@
1
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
1
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') unless $SETUP_LOADED
2
2
  require 'unittests/setup'
3
3
 
4
4
  class TC_Bugs< Test::Unit::TestCase
5
- include FireWatir
5
+
6
6
 
7
7
  def setup
8
- $ff.goto($htmlRoot + "frame_buttons.html")
8
+ goto_page("frame_buttons.html")
9
9
  end
10
10
 
11
+ tag_method :test_frame_objects_bug3, :fails_on_ie
11
12
  def test_frame_objects_bug3
12
- frame = $ff.frame("buttonFrame")
13
+ frame = browser.frame("buttonFrame")
13
14
  button = frame.button(:name, "b1")
14
15
  assert_equal("buttonFrame", frame.name)
15
16
  assert_equal("b2", button.id)
@@ -19,8 +20,8 @@ class TC_Bugs< Test::Unit::TestCase
19
20
  end
20
21
 
21
22
  def test_link_object_bug9
22
- $ff.goto($htmlRoot + "links1.html")
23
- link = $ff.link(:text, "nameDelet")
23
+ goto_page("links1.html")
24
+ link = browser.link(:text, "nameDelet")
24
25
  assert_equal("test_link", link.name)
25
26
  end
26
27
 
@@ -29,20 +30,21 @@ class TC_Bugs< Test::Unit::TestCase
29
30
  # appropriate class, not the generic Element class. So if it's a div,
30
31
  # it should return an instance of Div, if it's a checkbox, CheckBox,
31
32
  # and so on. TODO write tests for all classes
33
+ tag_method :test_element_by_xpath_bug01, :fails_on_ie
32
34
  def test_element_by_xpath_bug01
33
- $ff.goto($htmlRoot + "div.html")
34
- element = $ff.element_by_xpath("//div[@id='div1']")
35
+ goto_page("div.html")
36
+ element = browser.element_by_xpath("//div[@id='div1']")
35
37
  assert_not_nil(element) # helder
36
38
  # next assert always breaks, dunno why (error, not failure)
37
39
  #assert_instance_of(Div, element, "wrong constructor was used")
38
40
  # using this hack instead
39
- assert(element.instance_of?(Div),
40
- "element class should be: #{Div}; got: #{element.class}.")
41
+ assert_class element, 'Div'
41
42
  end
42
43
 
44
+ tag_method :test_elements_by_xpath_bug10, :fails_on_ie
43
45
  def test_elements_by_xpath_bug10
44
- $ff.goto($htmlRoot + "links1.html")
45
- elements = $ff.elements_by_xpath("//a")
46
+ goto_page("links1.html")
47
+ elements = browser.elements_by_xpath("//a")
46
48
  assert_equal(11, elements.length)
47
49
  assert_equal("links2.html", elements[0].href)
48
50
  assert_equal("link_class_1", elements[1].className)
@@ -51,116 +53,123 @@ class TC_Bugs< Test::Unit::TestCase
51
53
  end
52
54
 
53
55
  def test_button_by_value_bug8
54
- $ff.goto($htmlRoot + "buttons1.html")
55
- assert_equal("Sign In", $ff.button(:value,"Sign In").value)
56
+ goto_page("buttons1.html")
57
+ assert_equal("Sign In", browser.button(:value,"Sign In").value)
56
58
  end
57
59
 
60
+ tag_method :test_html_bug7, :fails_on_ie
58
61
  def test_html_bug7
59
- $ff.goto($htmlRoot + "links1.html")
60
- html = $ff.html
62
+ goto_page("links1.html")
63
+ html = browser.html
61
64
  assert_match(/.*<a id="linktos" *>*/,html)
62
65
  end
63
66
 
64
67
  def test_span_onclick_bug14
65
- $ff.goto($htmlRoot + "div.html")
66
- $ff.span(:id, "span1").fireEvent("onclick")
67
- assert($ff.text.include?("PASS") )
68
+ goto_page("div.html")
69
+ browser.span(:id, "span1").fireEvent("onclick")
70
+ assert(browser.text.include?("PASS") )
68
71
  end
69
72
 
73
+ tag_method :test_file_field_value_bug20, :fails_on_ie # hangs, actually
70
74
  def test_file_field_value_bug20
71
75
  actual_file_name = "c:\\Program Files\\TestFile.html"
72
- $ff.goto($htmlRoot + "fileupload.html")
73
- $ff.file_field(:name, "file3").set(actual_file_name)
74
- set_file_name = $ff.file_field(:name, "file3").value
76
+ goto_page("fileupload.html")
77
+ browser.file_field(:name, "file3").set(actual_file_name)
78
+ set_file_name = browser.file_field(:name, "file3").value
75
79
  # make sure correct value for upload file is posted.
76
80
  assert(actual_file_name, set_file_name)
77
81
  end
78
82
 
83
+ tag_method :test_attribute_value_bug22, :fails_on_ie
79
84
  def test_attribute_value_bug22
80
- $ff.goto($htmlRoot + "div.html")
81
- assert("Test1", $ff.element_by_xpath("//div[@id='div1']").attribute_value("title"))
85
+ goto_page("div.html")
86
+ assert("Test1", browser.element_by_xpath("//div[@id='div1']").attribute_value("title"))
82
87
  end
83
88
 
84
89
  def test_url_value_bug23
85
- $ff.goto($htmlRoot + "buttons1.html")
86
- $ff.button(:id, "b2").click
87
- assert($htmlRoot + "pass.html", $ff.url)
90
+ goto_page("buttons1.html")
91
+ browser.button(:id, "b2").click
92
+ assert($htmlRoot + "pass.html", browser.url)
88
93
  end
89
94
 
90
95
  def test_contains_text_bug28
91
- $ff.goto($htmlRoot + "buttons1.html")
92
- $ff.button(:id, "b2").click
93
- assert_false($ff.contains_text("passed"))
94
- assert($ff.contains_text("PASS"))
95
- assert($ff.contains_text("PAS"))
96
- assert($ff.contains_text(/PAS/))
97
- assert($ff.contains_text(/pass/i))
98
- assert_false($ff.contains_text(/pass/))
96
+ goto_page("buttons1.html")
97
+ browser.button(:id, "b2").click
98
+ assert_false(browser.contains_text("passed"))
99
+ assert(browser.contains_text("PASS"))
100
+ assert(browser.contains_text("PAS"))
101
+ assert(browser.contains_text(/PAS/))
102
+ assert(browser.contains_text(/pass/i))
103
+ assert_false(browser.contains_text(/pass/))
99
104
  end
100
105
 
106
+ tag_method :test_frame_bug_21, :fails_on_ie
101
107
  def test_frame_bug_21
102
- $ff.goto($htmlRoot + "frame_buttons.html")
103
- frame1 = $ff.frame(:name, "buttonFrame")
104
- frame2 = $ff.frame(:name, "buttonFrame2")
108
+ goto_page("frame_buttons.html")
109
+ frame1 = browser.frame(:name, "buttonFrame")
110
+ frame2 = browser.frame(:name, "buttonFrame2")
105
111
  assert_equal("buttons1.html", frame1.src)
106
112
  assert_equal("blankpage.html", frame2.src)
107
113
  end
108
114
 
109
115
  def test_quotes_bug_11
110
- $ff.goto($htmlRoot + "textfields1.html")
111
- $ff.text_field(:name, "text1").set("value with quote (\")")
112
- assert_equal("value with quote (\")", $ff.text_field(:name, "text1").value)
113
- $ff.text_field(:name, "text1").set("value with backslash (\\)")
114
- assert_equal("value with backslash (\\)", $ff.text_field(:name, "text1").value)
116
+ goto_page("textfields1.html")
117
+ browser.text_field(:name, "text1").set("value with quote (\")")
118
+ assert_equal("value with quote (\")", browser.text_field(:name, "text1").value)
119
+ browser.text_field(:name, "text1").set("value with backslash (\\)")
120
+ assert_equal("value with backslash (\\)", browser.text_field(:name, "text1").value)
115
121
  end
116
122
 
123
+ tag_method :test_close_bug_26, :fails_on_ie
117
124
  def test_close_bug_26
118
125
  if ! (RUBY_PLATFORM =~ /darwin/i)
119
- $ff.close()
120
- $ff = Firefox.new
126
+ browser.close()
127
+ browser = FireWatir::Firefox.new
121
128
  end
122
129
  end
123
130
 
124
131
  def test_class_bug_29
125
- $ff.goto($htmlRoot + "div.html")
126
- div = $ff.div(:class, "blueText")
132
+ goto_page("div.html")
133
+ div = browser.div(:class, "blueText")
127
134
  assert_equal("div2", div.id)
128
135
  end
129
136
 
130
137
  def test_element_using_any_attribute
131
- $ff.goto($htmlRoot + "div.html")
132
- div = $ff.div(:title, "Test1")
138
+ goto_page("div.html")
139
+ div = browser.div(:title, "Test1")
133
140
  assert_equal("div1", div.id)
134
141
  end
135
-
142
+
143
+ tag_method :test_element_using_any_attribute2, :fails_on_ie
136
144
  def test_element_using_any_attribute2
137
- $ff.goto($htmlRoot + "div.html")
138
- div = $ff.div(:attribute, "attribute")
145
+ goto_page("div.html")
146
+ div = browser.div(:attribute, "attribute")
139
147
  assert_equal("div1", div.id)
140
148
  end
141
149
 
150
+ tag_method :test_file_field_bug_20, :fails_on_ie
142
151
  def test_file_field_bug_20
143
- $ff.goto($htmlRoot + "fileupload.html")
152
+ goto_page("fileupload.html")
144
153
  # Enter dummy path.
145
154
  if(RUBY_PLATFORM =~ /.*mswin.*/)
146
- $ff.file_field(:name, "file3").set("c:\\results.txt")
155
+ browser.file_field(:name, "file3").set("c:\\results.txt")
147
156
  else
148
- $ff.file_field(:name, "file3").set("/user/lib/results.txt")
157
+ browser.file_field(:name, "file3").set("/user/lib/results.txt")
149
158
  end
150
- $ff.button(:name, "upload").click()
151
- url = $ff.url
159
+ browser.button(:name, "upload").click()
160
+ url = browser.url
152
161
  assert_match(/.*results.txt&upload=upload$/,url)
153
162
  end
154
163
 
155
164
  def test_button_bug2
156
- $ff.goto($htmlRoot + "buttons1.html")
157
- btn = $ff.button(:id, "b7")
165
+ goto_page("buttons1.html")
166
+ btn = browser.button(:id, "b7")
158
167
  assert_equal("b7", btn.id)
159
168
  end
160
169
 
161
170
  def test_getAllContents_bug25
162
- $ff.goto($htmlRoot + "select_tealeaf.html")
163
- $ff.select_lists.each do |select|
171
+ goto_page("select_tealeaf.html")
172
+ browser.select_lists.each do |select|
164
173
  contents = select.getAllContents().to_s
165
174
  puts contents
166
175
  assert_equal("=<>>=<=", contents)
@@ -168,20 +177,21 @@ class TC_Bugs< Test::Unit::TestCase
168
177
  end
169
178
  end
170
179
 
180
+ tag_method :test_fire_event_bug31, :fails_on_ie
171
181
  def test_fire_event_bug31
172
- $ff.goto($htmlRoot + "div.html")
173
- div = $ff.div(:attribute, "attribute")
182
+ goto_page("div.html")
183
+ div = browser.div(:attribute, "attribute")
174
184
  div.fire_event("ondblclick")
175
- assert("PASS", $ff.text)
176
- $ff.goto($htmlRoot + "div.html")
177
- div = $ff.div(:id, "div1")
185
+ assert("PASS", browser.text)
186
+ goto_page("div.html")
187
+ div = browser.div(:id, "div1")
178
188
  div.fireEvent("ondblclick")
179
- assert("PASS", $ff.text)
189
+ assert("PASS", browser.text)
180
190
  end
181
191
 
182
192
  def test_contains_text_bug37
183
- $ff.goto($htmlRoot + "frame_buttons.html")
184
- frame = $ff.frame(:name, "buttonFrame")
193
+ goto_page("frame_buttons.html")
194
+ frame = browser.frame(:name, "buttonFrame")
185
195
  assert(frame.contains_text("second button"))
186
196
  assert_false(frame.contains_text("second button second"))
187
197
  end
@@ -1,87 +1,88 @@
1
1
  # feature tests for Buttons
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_Buttons_XPath < Test::Unit::TestCase
8
- include FireWatir
8
+
9
9
 
10
10
  def setup
11
- $ff.goto($htmlRoot + "buttons1.html")
11
+ goto_page("buttons1.html")
12
12
  end
13
13
 
14
14
  def test_properties
15
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:xpath, "//input[@name='noName']").id }
16
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:xpath, "//input[@name='noName']").name }
17
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:xpath, "//input[@name='noName']").disabled }
18
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:xpath, "//input[@name='noName']").type }
19
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:xpath, "//input[@name='noName']").value }
15
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").id }
16
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").name }
17
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").disabled }
18
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").type }
19
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").value }
20
20
 
21
- assert_equal("b1" , $ff.button(:xpath, "//input[@id='b2']").name )
22
- assert_equal("b2" , $ff.button(:xpath, "//input[@id='b2']").id )
23
- assert_equal("button" , $ff.button(:xpath, "//input[@id='b2']").type )
21
+ assert_equal("b1" , browser.button(:xpath, "//input[@id='b2']").name )
22
+ assert_equal("b2" , browser.button(:xpath, "//input[@id='b2']").id )
23
+ assert_equal("button" , browser.button(:xpath, "//input[@id='b2']").type )
24
24
  end
25
25
 
26
26
  def test_button_using_default
27
27
  # since most of the time, a button will be accessed based on its caption, there is a default way of accessing it....
28
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:xpath, "//input[@value='Missing Caption']").click }
28
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@value='Missing Caption']").click }
29
29
 
30
- $ff.button(:xpath, "//input[@value='Click Me']").click
31
- assert($ff.text.include?("PASS") )
30
+ browser.button(:xpath, "//input[@value='Click Me']").click
31
+ assert(browser.text.include?("PASS") )
32
32
  end
33
33
 
34
34
  def test_Button_click_only
35
- $ff.button(:xpath, "//input[@value='Click Me']").click
36
- assert($ff.text.include?("PASS") )
35
+ browser.button(:xpath, "//input[@value='Click Me']").click
36
+ assert(browser.text.include?("PASS") )
37
37
  end
38
38
 
39
39
  def test_button_click
40
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:xpath, "//input[@value='Missing Caption']").click }
41
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:xpath, "//input[@id='MissingId']").click }
40
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@value='Missing Caption']").click }
41
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@id='MissingId']").click }
42
42
 
43
- assert_raises(ObjectDisabledException , "ObjectDisabledException was supposed to be thrown" ) { $ff.button(:xpath, "//input[@value='Disabled Button']").click }
43
+ assert_raises(ObjectDisabledException , "ObjectDisabledException was supposed to be thrown" ) { browser.button(:xpath, "//input[@value='Disabled Button']").click }
44
44
 
45
- $ff.button(:xpath, "//input[@value='Click Me']").click
46
- assert($ff.text.include?("PASS") )
45
+ browser.button(:xpath, "//input[@value='Click Me']").click
46
+ assert(browser.text.include?("PASS") )
47
47
  end
48
48
 
49
49
  def test_Button_Exists
50
- assert($ff.button(:xpath, "//input[@value='Click Me']").exists?)
51
- assert($ff.button(:xpath, "//input[@value='Submit']").exists?)
52
- assert($ff.button(:xpath, "//input[@name='b1']").exists?)
53
- assert($ff.button(:xpath, "//input[@id='b2']").exists?)
50
+ assert(browser.button(:xpath, "//input[@value='Click Me']").exists?)
51
+ assert(browser.button(:xpath, "//input[@value='Submit']").exists?)
52
+ assert(browser.button(:xpath, "//input[@name='b1']").exists?)
53
+ assert(browser.button(:xpath, "//input[@id='b2']").exists?)
54
54
 
55
- assert_false($ff.button(:xpath, "//input[@value='Missing Caption']").exists?)
56
- assert_false($ff.button(:xpath, "//input[@name='missingname']").exists?)
57
- assert_false($ff.button(:xpath, "//input[@id='missingid']").exists?)
55
+ assert_false(browser.button(:xpath, "//input[@value='Missing Caption']").exists?)
56
+ assert_false(browser.button(:xpath, "//input[@name='missingname']").exists?)
57
+ assert_false(browser.button(:xpath, "//input[@id='missingid']").exists?)
58
58
  end
59
59
 
60
+ tag_method :test_element_by_xpath_class, :fails_on_ie
60
61
  def test_element_by_xpath_class
61
- element = $ff.element_by_xpath("//input[@value='Click Me']")
62
- assert(element.instance_of?(Button),"element class should be #{Button}; got #{element.class}")
63
- element = $ff.element_by_xpath("//input[@value='Submit']")
64
- assert(element.instance_of?(Button),"element class should be #{Button}; got #{element.class}")
65
- element = $ff.element_by_xpath("//input[@name='b1']")
66
- assert(element.instance_of?(Button),"element class should be #{Button}; got #{element.class}")
67
- element = $ff.element_by_xpath("//input[@id='b2']")
68
- assert(element.instance_of?(Button),"element class should be #{Button}; got #{element.class}")
62
+ element = browser.element_by_xpath("//input[@value='Click Me']")
63
+ assert_class element, 'Button'
64
+ element = browser.element_by_xpath("//input[@value='Submit']")
65
+ assert_class element, 'Button'
66
+ element = browser.element_by_xpath("//input[@name='b1']")
67
+ assert_class element, 'Button'
68
+ element = browser.element_by_xpath("//input[@id='b2']")
69
+ assert_class element, 'Button'
69
70
  # TODO: If object is not there this should return null
70
- #element = $ff.element_by_xpath("//input[@value='Missing Caption']")
71
+ #element = browser.element_by_xpath("//input[@value='Missing Caption']")
71
72
  #assert(element.instance_of?(Button),"element class should be #{Button}; got #{element.class}")
72
- #element = $ff.element_by_xpath("//input[@name='missingname']")
73
+ #element = browser.element_by_xpath("//input[@name='missingname']")
73
74
  #assert(element.instance_of?(Button),"element class should be #{Button}; got #{element.class}")
74
- #element = $ff.element_by_xpath("//input[@id='missingid']")
75
+ #element = browser.element_by_xpath("//input[@id='missingid']")
75
76
  #assert(element.instance_of?(Button),"element class should be #{Button}; got #{element.class}")
76
77
  end
77
78
 
78
79
  def test_Button_Enabled
79
- assert($ff.button(:xpath, "//input[@value='Click Me']").enabled?)
80
- assert_false($ff.button(:xpath, "//input[@value='Disabled Button']").enabled?)
81
- assert_false($ff.button(:xpath, "//input[@name='b4']").enabled?)
82
- assert_false($ff.button(:xpath, "//input[@id='b5']").enabled?)
80
+ assert(browser.button(:xpath, "//input[@value='Click Me']").enabled?)
81
+ assert_false(browser.button(:xpath, "//input[@value='Disabled Button']").enabled?)
82
+ assert_false(browser.button(:xpath, "//input[@name='b4']").enabled?)
83
+ assert_false(browser.button(:xpath, "//input[@id='b5']").enabled?)
83
84
 
84
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:xpath, "//input[@name='noName']").enabled? }
85
+ assert_raises(UnknownObjectException) { browser.button(:xpath, "//input[@name='noName']").enabled? }
85
86
  end
86
87
  end
87
88