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
@@ -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__), '..') 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_CheckBox < Test::Unit::TestCase
8
- include FireWatir
8
+
9
9
 
10
10
  def setup()
11
- $ff.goto($htmlRoot + "checkboxes1.html")
11
+ goto_page("checkboxes1.html")
12
12
  end
13
13
 
14
14
  def test_checkbox_properties
15
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.checkbox(:name, "noName").id }
16
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.checkbox(:name, "noName").name }
17
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.checkbox(:name, "noName").disabled }
18
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.checkbox(:name, "noName").type }
19
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.checkbox(:name, "noName").value }
20
-
21
- assert_equal("box1" , $ff.checkbox(:index, 1).name )
22
- assert_instance_of(CheckBox,$ff.checkbox(:index,1))
23
- assert_equal("" , $ff.checkbox(:index, 1).id )
24
- assert_equal("checkbox" , $ff.checkbox(:index, 1).type )
25
- assert_equal("on" , $ff.checkbox(:index, 1).value )
26
- assert_equal(false , $ff.checkbox(:index, 1).disabled )
27
-
28
- assert_equal("check_box_style" , $ff.checkbox(:name, "box1").class_name)
29
- assert_equal("" , $ff.checkbox(:name, "box2").class_name)
30
-
31
- assert_equal("1" , $ff.checkbox(:name,"box4").value )
32
- assert_equal("3" , $ff.checkbox(:name,"box4" , 3).value )
33
- assert_equal("checkbox" , $ff.checkbox(:name,"box4" , 3).type )
34
- assert_equal(false , $ff.checkbox(:name,"box4" , 3).disabled )
35
- assert_equal("" , $ff.checkbox(:name,"box4" , 3).id )
36
-
37
- assert_equal("box4-value5" , $ff.checkbox(:name,"box4" , 5).title)
38
- assert_equal("" , $ff.checkbox(:name,"box4" , 4).title)
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($ff.button(:value , "foo").enabled?)
43
- $ff.checkbox(:name, "box5").set
44
- assert($ff.button(:value , "foo").enabled?)
43
+ assert_false(browser.button(:value , "foo").enabled?)
44
+ browser.checkbox(:name, "box5").set
45
+ assert(browser.button(:value , "foo").enabled?)
45
46
 
46
- $ff.checkbox(:name, "box5").clear
47
- assert_false($ff.button(:value , "foo").enabled?)
47
+ browser.checkbox(:name, "box5").clear
48
+ assert_false(browser.button(:value , "foo").enabled?)
48
49
 
49
- $ff.checkbox(:name, "box5").clear
50
- assert_false($ff.button(:value , "foo").enabled?)
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($ff.checkbox(:name, "box1").exists?)
55
- assert_false($ff.checkbox(:name, "missing").exists?)
55
+ assert(browser.checkbox(:name, "box1").exists?)
56
+ assert_false(browser.checkbox(:name, "missing").exists?)
56
57
 
57
- assert($ff.checkbox(:name, "box4" , 1).exists?)
58
- assert_false($ff.checkbox(:name, "box4" , 22).exists?)
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) { $ff.checkbox(:name, "noName").enabled? }
63
- # assert_raises(UnknownObjectException) { $ff.checkbox(:id, "noName").enabled? }
64
- # assert_raises(UnknownObjectException) { $ff.checkbox(:name, "box4" , 6).enabled? }
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($ff.checkbox(:name, "box1").enabled?)
67
- # assert_false($ff.checkbox(:name, "box2").enabled?)
67
+ # assert(browser.checkbox(:name, "box1").enabled?)
68
+ # assert_false(browser.checkbox(:name, "box2").enabled?)
68
69
  #
69
- # assert($ff.checkbox(:name, "box4", 4).enabled?)
70
- # assert_false($ff.checkbox(:name, "box4" , 5 ).enabled?)
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 ) { $ff.checkbox(:name, "noName").isSet? }
75
+ assert_raises(UnknownObjectException ) { browser.checkbox(:name, "noName").isSet? }
75
76
 
76
- assert_false($ff.checkbox(:name, "box1").isSet?)
77
- assert_false($ff.checkbox(:name, "box2").isSet?)
78
- assert($ff.checkbox(:name, "box3").isSet?)
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($ff.checkbox(:name, "box4" , 2 ).isSet?)
81
- assert($ff.checkbox(:name, "box4" , 1 ).isSet?)
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) { $ff.checkbox(:name, "noName").clear }
86
- $ff.checkbox(:name, "box1").clear
87
- assert_false($ff.checkbox(:name, "box1").isSet?)
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) { $ff.checkbox(:name, "box2").clear }
90
- assert_false($ff.checkbox(:name, "box2").isSet?)
90
+ assert_raises(ObjectDisabledException) { browser.checkbox(:name, "box2").clear }
91
+ assert_false(browser.checkbox(:name, "box2").isSet?)
91
92
 
92
- $ff.checkbox(:name, "box3").clear
93
- assert_false($ff.checkbox(:name, "box3").isSet?)
93
+ browser.checkbox(:name, "box3").clear
94
+ assert_false(browser.checkbox(:name, "box3").isSet?)
94
95
 
95
- $ff.checkbox(:name, "box4" , 1).clear
96
- assert_false($ff.checkbox(:name, "box4" , 1).isSet?)
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) { $ff.checkbox(:name, "noName").getState }
101
- assert_equal( false , $ff.checkbox(:name, "box1").getState )
102
- assert_equal( true , $ff.checkbox(:name, "box3").getState)
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 , $ff.checkbox(:name, "box4" , 2).getState )
106
- assert_equal( true , $ff.checkbox(:name, "box4" , 1).getState)
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) { $ff.checkbox(:name, "noName").set }
111
- $ff.checkbox(:name, "box1").set
112
- assert($ff.checkbox(:name, "box1").isSet?)
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) { $ff.checkbox(:name, "box2").set }
115
+ assert_raises(ObjectDisabledException) { browser.checkbox(:name, "box2").set }
115
116
 
116
- $ff.checkbox(:name, "box3").set
117
- assert($ff.checkbox(:name, "box3").isSet?)
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
- $ff.checkbox(:name, "box4" , 3).set
121
- assert($ff.checkbox(:name, "box4" , 3).isSet?)
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
- $ff.checkbox(:name, "box1").set( false )
126
- assert_false($ff.checkbox(:name, "box1").isSet?)
126
+ browser.checkbox(:name, "box1").set( false )
127
+ assert_false(browser.checkbox(:name, "box1").isSet?)
127
128
 
128
- $ff.checkbox(:name, "box1").set( true )
129
- assert($ff.checkbox(:name, "box1").isSet?)
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, $ff.checkboxes.length)
139
- assert_equal("box1" , $ff.checkboxes[1].name )
139
+ assert_equal(11, browser.checkboxes.length)
140
+ assert_equal("box1" , browser.checkboxes[1].name )
140
141
 
141
142
  index=1
142
- $ff.checkboxes.each do |c|
143
- assert_equal( $ff.checkbox(:index, index).name , c.name )
144
- assert_equal( $ff.checkbox(:index, index).id, c.id )
145
- assert_equal( $ff.checkbox(:index, index).value, c.value )
146
- assert_equal( $ff.checkbox(:index, index).isSet?, c.isSet? )
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, $ff.checkboxes.length)
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__), '..') 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_CheckBox_XPath < Test::Unit::TestCase
8
- include FireWatir
8
+
9
9
 
10
10
  def setup
11
- $ff.goto($htmlRoot + "checkboxes1.html")
11
+ goto_page("checkboxes1.html")
12
12
  end
13
13
 
14
14
  def test_checkbox_properties
15
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.checkbox(:xpath , "//input[@name='noName']").id }
16
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.checkbox(:xpath , "//input[@name='noName']").name }
17
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.checkbox(:xpath , "//input[@name='noName']").disabled }
18
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.checkbox(:xpath , "//input[@name='noName']").type }
19
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.checkbox(:xpath , "//input[@name='noName']").value }
20
-
21
- assert_equal("1" , $ff.checkbox(:xpath , "//input[@name='box4']").value )
22
- assert_equal("3" , $ff.checkbox(:xpath , "//input[@name='box4' and @value='3']").value )
23
- assert_equal("checkbox" , $ff.checkbox(:xpath , "//input[@name='box4' and @value='3']").type )
24
- assert_equal(false , $ff.checkbox(:xpath , "//input[@name='box4' and @value='3']").disabled )
25
- assert_equal("" , $ff.checkbox(:xpath , "//input[@name='box4' and @value='3']").id )
26
-
27
- assert_equal("box4-value5" , $ff.checkbox(:xpath , "//input[@name='box4' and @value='5']").title)
28
- assert_equal("" , $ff.checkbox(:xpath , "//input[@name='box4' and @value='4']").title)
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($ff.checkbox(:xpath , "//input[@name='box4' and @value='1']").exists?)
33
- assert_false($ff.checkbox(:xpath , "//input[@name='box4' and @value='22']").exists?)
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) { $ff.checkbox(:xpath , "//input[@name='noName']").enabled? }
38
- assert_raises(UnknownObjectException) { $ff.checkbox(:xpath , "//input[@id='noName']").enabled? }
39
- assert_raises(UnknownObjectException) { $ff.checkbox(:xpath , "//input[@name='box4' and @value='6']").enabled? }
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($ff.checkbox(:xpath , "//input[@name='box1']").enabled?)
42
- assert_false($ff.checkbox(:xpath , "//input[@name='box2']").enabled?)
41
+ assert(browser.checkbox(:xpath , "//input[@name='box1']").enabled?)
42
+ assert_false(browser.checkbox(:xpath , "//input[@name='box2']").enabled?)
43
43
 
44
- assert($ff.checkbox(:xpath , "//input[@name='box4' and @value='4']").enabled?)
45
- assert_false($ff.checkbox(:xpath , "//input[@name='box4' and @value='5']").enabled?)
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 ) { $ff.checkbox(:xpath , "//input[@name='noName']").isSet? }
49
+ assert_raises(UnknownObjectException ) { browser.checkbox(:xpath , "//input[@name='noName']").isSet? }
50
50
 
51
- assert_false($ff.checkbox(:xpath , "//input[@name='box1']").isSet?)
52
- assert_false($ff.checkbox(:xpath , "//input[@name='box2']").isSet?)
53
- assert($ff.checkbox(:xpath , "//input[@name='box3']").isSet?)
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($ff.checkbox(:xpath , "//input[@name='box4' and @value='2']").isSet?)
56
- assert($ff.checkbox(:xpath , "//input[@name='box4' and @value='1']").isSet?)
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) { $ff.checkbox(:xpath , "//input[@name='noName']").clear }
61
- $ff.checkbox(:xpath , "//input[@name='box1']").clear
62
- assert_false($ff.checkbox(:xpath , "//input[@name='box1']").isSet?)
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) { $ff.checkbox(:xpath , "//input[@name='box2']").clear }
65
- assert_false($ff.checkbox(:xpath , "//input[@name='box2']").isSet?)
64
+ assert_raises(ObjectDisabledException) { browser.checkbox(:xpath , "//input[@name='box2']").clear }
65
+ assert_false(browser.checkbox(:xpath , "//input[@name='box2']").isSet?)
66
66
 
67
- $ff.checkbox(:xpath , "//input[@name='box3']").clear
68
- assert_false($ff.checkbox(:xpath , "//input[@name='box3']").isSet?)
67
+ browser.checkbox(:xpath , "//input[@name='box3']").clear
68
+ assert_false(browser.checkbox(:xpath , "//input[@name='box3']").isSet?)
69
69
 
70
- $ff.checkbox(:xpath , "//input[@name='box4' and @value='1']").clear
71
- assert_false($ff.checkbox(:xpath , "//input[@name='box4' and @value='1']").isSet?)
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) { $ff.checkbox(:xpath , "//input[@name='noName']").getState }
76
- assert_equal( false , $ff.checkbox(:xpath , "//input[@name='box1']").getState )
77
- assert_equal( true , $ff.checkbox(:xpath , "//input[@name='box3']").getState)
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 , $ff.checkbox(:xpath , "//input[@name='box4' and @value='2']").getState )
81
- assert_equal( true , $ff.checkbox(:xpath , "//input[@name='box4' and @value='1']").getState)
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) { $ff.checkbox(:xpath , "//input[@name='noName']").set }
86
- $ff.checkbox(:xpath , "//input[@name='box1']").set
87
- assert($ff.checkbox(:xpath , "//input[@name='box1']").isSet?)
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) { $ff.checkbox(:xpath , "//input[@name='box2']").set }
89
+ assert_raises(ObjectDisabledException) { browser.checkbox(:xpath , "//input[@name='box2']").set }
90
90
 
91
- $ff.checkbox(:xpath , "//input[@name='box3']").set
92
- assert($ff.checkbox(:xpath , "//input[@name='box3']").isSet?)
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
- $ff.checkbox(:xpath , "//input[@name='box4' and @value='3']").set
96
- assert($ff.checkbox(:xpath , "//input[@name='box4' and @value='3']").isSet?)
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
- $ff.checkbox(:xpath , "//input[@name='box1']").set( false )
101
- assert_false($ff.checkbox(:xpath , "//input[@name='box1']").isSet?)
100
+ browser.checkbox(:xpath , "//input[@name='box1']").set( false )
101
+ assert_false(browser.checkbox(:xpath , "//input[@name='box1']").isSet?)
102
102
 
103
- $ff.checkbox(:xpath , "//input[@name='box1']").set( true )
104
- assert($ff.checkbox(:xpath , "//input[@name='box1']").isSet?)
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
@@ -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__), '..') 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_Divs < Test::Unit::TestCase
8
- include FireWatir
8
+
9
9
 
10
10
  def setup
11
- $ff.goto($htmlRoot + "div.html")
11
+ goto_page("div.html")
12
12
  end
13
13
 
14
14
  def test_divs
15
- assert_raises(UnknownObjectException) {$ff.div(:id , "div77").click }
16
- assert_raises(UnknownObjectException) {$ff.div(:title , "div77").click }
15
+ assert_raises(UnknownObjectException) {browser.div(:id , "div77").click }
16
+ assert_raises(UnknownObjectException) {browser.div(:title , "div77").click }
17
17
 
18
- assert($ff.text_field(:name, "text1").verify_contains("0") )
19
- $ff.div(:id , "div3").click
20
- assert($ff.text_field(:name, "text1").verify_contains("1") )
21
- $ff.div(:id , "div4").click
22
- assert($ff.text_field(:name, "text1").verify_contains("0") )
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, $ff.show_all_objects.length)
27
- assert_equal(3,$ff.div(:id,"text_fields1").show_all_objects.length)
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,$ff.text_fields.length)
30
- assert_equal(3,$ff.div(:id,"text_fields1").text_fields.length)
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) {$ff.div(:id , "div77").text }
35
- assert_raises(UnknownObjectException) {$ff.div(:title , "div77").text }
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", $ff.div(:id , "div3").text.strip )
38
- assert_equal("This text is in a div with an id of div1 and title of test1",$ff.div(:title , "Test1").text.strip )
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) {$ff.div(:id , "div77").class_name }
41
- assert_equal("blueText" , $ff.div(:id , "div2").class_name )
42
- assert_equal("" , $ff.div(:id , "div1").class_name )
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) {$ff.div(:index , 44).class_name }
45
- assert_equal("div1" , $ff.div(:index , 1).id )
46
- assert_equal("" , $ff.div(:index , 1).class_name )
47
- assert_equal("blueText" , $ff.div(:index , 2).class_name )
48
- assert_equal("" , $ff.div(:index , 2).value)
49
- #assert_equal(false , $ff.div(:index , 2).disabled)
50
- assert_equal("" , $ff.div(:index , 2).name)
51
- assert_equal("div2", $ff.div(:index , 2).id)
52
- #puts $ff.div(:id,"text_fields1").to_s
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 , $ff.divs.length)
57
- assert_equal( "div1" , $ff.divs[1].id )
57
+ assert_equal( 7 , browser.divs.length)
58
+ assert_equal( "div1" , browser.divs[1].id )
58
59
 
59
60
  index =1
60
- $ff.divs.each do |s|
61
+ browser.divs.each do |s|
61
62
  # puts "each - div= " + s.to_s
62
- assert_equal($ff.div(:index, index ).name , s.name )
63
- assert_equal($ff.div(:index, index ).id , s.id )
64
- assert_equal($ff.div(:index, index ).class_name , s.class_name )
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, $ff.divs.length) # -1 as we add 1 at the end of the loop
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($ff.div(:id, 'buttons1').button(:index,1).exists? )
72
- assert(!$ff.div(:id, 'buttons1').button(:index,3).exists? )
73
- assert($ff.div(:id, 'buttons1').button(:name,'b1').exists? )
74
- $ff.div(:id, 'buttons1').button(:name,'b1').click
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($ff.div(:id, 'buttons2').button(:index,1).exists? )
77
- assert($ff.div(:id, 'buttons2').button(:index,2).exists? )
78
- assert(!$ff.div(:id, 'buttons1').button(:index,3).exists? )
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
- $ff.div(:id, 'buttons1').button(:index,1).click
81
+ browser.div(:id, 'buttons1').button(:index,1).click
81
82
 
82
- assert_equal( 'button1' , $ff.div(:id , 'text_fields1').text_field(:index,1).value)
83
+ assert_equal( 'button1' , browser.div(:id , 'text_fields1').text_field(:index,1).value)
83
84
 
84
- #assert_equal( 3 , $ff.div(:id , 'text_fields1').text_fields.length )
85
- $ff.div(:id, 'text_fields1').text_field(:name, 'div_text1').set("drink me")
86
- assert_equal("drink me", $ff.div(:id, 'text_fields1').text_field(:name, 'div_text1').getContents)
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) {$ff.span(:id , "span77").click }
92
- assert_raises(UnknownObjectException) {$ff.span(:title , "span77").click }
92
+ assert_raises(UnknownObjectException) {browser.span(:id , "span77").click }
93
+ assert_raises(UnknownObjectException) {browser.span(:title , "span77").click }
93
94
 
94
- assert($ff.text_field(:name, "text2").verify_contains("0") )
95
- $ff.span(:id , "span3").click
96
- assert($ff.text_field(:name, "text2").verify_contains("1") )
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
- $ff.span(:id , "span4").click
99
- assert($ff.text_field(:name, "text2").verify_contains("0") )
99
+ browser.span(:id , "span4").click
100
+ assert(browser.text_field(:name, "text2").verify_contains("0") )
100
101
 
101
- #puts $ff.span(:id,"text_fields1").to_s
102
+ #puts browser.span(:id,"text_fields1").to_s
102
103
  end
103
104
 
104
105
  def test_span_properties
105
- assert_raises(UnknownObjectException) {$ff.span(:id , "span77").text }
106
- assert_raises(UnknownObjectException) {$ff.span(:title , "span77").text }
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" , $ff.span(:id , "span3").text.strip )
109
- assert_equal("This text is in a span with an id of span1 and title of test2" , $ff.span(:title , "Test2").text.strip )
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) {$ff.span(:id , "span77").class_name }
112
- assert_equal("blueText" , $ff.span(:id , "span2").class_name )
113
- assert_equal("" , $ff.span(:id , "span1").class_name )
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) {$ff.span(:index , 44).class_name }
116
- assert_equal("span1" , $ff.span(:index , 1).id )
117
- assert_equal("" , $ff.span(:index , 1).class_name )
118
- assert_equal("blueText" , $ff.span(:index , 2).class_name )
119
- assert_equal("" , $ff.span(:index , 2).value)
120
- #assert_equal(false , $ff.span(:index , 2).disabled)
121
- assert_equal("" , $ff.span(:index , 2).name)
122
- assert_equal("span2", $ff.span(:index , 2).id)
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, $ff.spans.length)
127
- assert_equal("span1", $ff.spans[1].id)
127
+ assert_equal(7, browser.spans.length)
128
+ assert_equal("span1", browser.spans[1].id)
128
129
 
129
130
  index = 1
130
- $ff.spans.each do |s|
131
+ browser.spans.each do |s|
131
132
  # puts "each - span = " + s.to_s
132
- assert_equal($ff.span(:index, index ).name , s.name )
133
- assert_equal($ff.span(:index, index ).id , s.id )
134
- assert_equal($ff.span(:index, index ).class_name , s.class_name )
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, $ff.spans.length) # -1 as we add 1 at the end of the loop
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($ff.span(:id, 'buttons1').button(:index,1).exists? )
142
- assert(!$ff.span(:id, 'buttons1').button(:index,3).exists? )
143
- assert($ff.span(:id, 'buttons1').button(:name,'b1').exists? )
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($ff.span(:id, 'buttons2').button(:index,1).exists? )
146
- assert($ff.span(:id, 'buttons2').button(:index,2).exists? )
147
- assert(!$ff.span(:id, 'buttons1').button(:index,3).exists? )
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
- $ff.span(:id, 'buttons1').button(:index,1).click
150
+ browser.span(:id, 'buttons1').button(:index,1).click
150
151
 
151
- assert_equal( 'button1' , $ff.span(:id , 'text_fields1').text_field(:index,1).value)
152
- $ff.span(:id , 'text_fields1').text_field(:index,1).set('text box inside span')
153
- assert_equal( 'text box inside span' , $ff.span(:id , 'text_fields1').text_field(:index,1).value)
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 , $ff.span(:id , 'text_fields1').text_fields.length )
156
+ #assert_equal( 3 , browser.span(:id , 'text_fields1').text_fields.length )
156
157
  end
157
158
 
158
159
  def test_p
159
- assert($ff.p(:id, 'number1').exists?)
160
- assert($ff.p(:index, 3).exists?)
161
- assert($ff.p(:title, 'test_3').exists?)
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
- assert(!$ff.p(:id, 'missing').exists?)
164
- assert(!$ff.p(:index, 8).exists?)
165
- assert(!$ff.p(:title, 'test_55').exists?)
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) {$ff.p(:id , 'missing').class_name }
168
- assert_raises( UnknownObjectException) {$ff.p(:id , 'missing').text }
169
- assert_raises( UnknownObjectException) {$ff.p(:id , 'missing').title }
170
- assert_raises( UnknownObjectException) {$ff.p(:id , 'missing').to_s }
171
- assert_raises( UnknownObjectException) {$ff.p(:id , 'missing').disabled }
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' , $ff.p(:index,1).class_name)
174
- assert_equal( 'P_tag_1' , $ff.p(:index,1).title)
175
- assert_equal( 'This text is in a p with an id of number2' , $ff.p(:index,2).text)
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, $ff.ps.length)
180
- assert_equal( 'italicText', $ff.ps[2].class_name)
181
- assert_equal( 'number3', $ff.ps[3].id)
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
- $ff.ps.each do |p|
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 , $ff.ps.length)
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
- include FireWatir
194
+
194
195
  include MockStdoutTestCase
195
196
 
197
+ tag_method :test_showDivs, :fails_on_ie
196
198
  def test_showDivs
197
- $ff.goto($htmlRoot + "div.html")
199
+ goto_page("div.html")
198
200
  $stdout = @mockout
199
- $ff.showDivs
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
- $ff.goto($htmlRoot + "div.html")
241
+ goto_page("div.html")
240
242
  $stdout = @mockout
241
- $ff.showSpans
243
+ browser.showSpans
242
244
  assert_equal(<<END_OF_MESSAGE, @mockout)
243
245
  There are 7 spans
244
246
  span: name: