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,215 +0,0 @@
1
- # feature tests for Buttons of type <input type = "button">
2
- # revision: $Revision: 1.0 $
3
-
4
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__
5
- require 'unittests/setup'
6
-
7
- class TC_Buttons < Test::Unit::TestCase
8
- include FireWatir
9
-
10
- def setup
11
- $ff.goto($htmlRoot + "buttons1.html")
12
- end
13
-
14
- def goto_frames_page()
15
- $ff.goto($htmlRoot + "frame_buttons.html")
16
- end
17
-
18
- #def test_Spinner
19
- # s = Spinner.new
20
- # i = 0
21
- # while(i < 100)
22
- # sleep 0.05
23
- # print s.next
24
- # i+=1
25
- # end
26
- # s = nil
27
- #end
28
-
29
- def test_Button_to_s
30
- # i think the tests for to_s should be dropped. The output is not in a nice format to be tested, and the
31
- # individual properties are tested in the test_properties method
32
-
33
- b4 = ['name: b4',
34
- 'type: button',
35
- 'id: b5',
36
- 'value: Disabled Button',
37
- 'disabled: true']
38
- b1 = ['name: b1',
39
- 'type: button',
40
- 'id: b2',
41
- 'value: Click Me',
42
- 'disabled: false']
43
-
44
- assert_equal(b4, $ff.button(:name, "b4").to_s)
45
- assert_equal(b1, $ff.button(:caption, "Click Me").to_s)
46
- assert_equal(b1, $ff.button(:index, 1).to_s)
47
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:name, "noName").to_s }
48
- end
49
-
50
- def test_properties
51
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:name, "noName").id }
52
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:name, "noName").name }
53
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:name, "noName").disabled }
54
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:name, "noName").type }
55
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:name, "noName").value }
56
-
57
- assert_equal("b1" , $ff.button(:index, 1).name )
58
- assert_equal("b2" , $ff.button(:index, 1).id )
59
- assert_equal("button" , $ff.button(:index, 1).type )
60
- assert_equal("Click Me" , $ff.button(:index, 1).value )
61
- assert_equal(false , $ff.button(:index, 1).disabled )
62
- assert_equal("italic_button" , $ff.button(:name, "b1").class_name )
63
- assert_equal("" , $ff.button(:name , "b4").class_name )
64
-
65
-
66
- assert_equal("b1" , $ff.button(:id, "b2").name )
67
- assert_equal("b2" , $ff.button(:id, "b2").id )
68
- assert_equal("button" , $ff.button(:id, "b2").type )
69
-
70
- assert_equal("b4" , $ff.button(:index, 2).name )
71
- assert_equal("b5" , $ff.button(:index, 2).id )
72
- assert_equal("button" , $ff.button(:index, 2).type )
73
- assert_equal("Disabled Button" , $ff.button(:index, 2).value )
74
- assert_equal(true , $ff.button(:index, 2).disabled )
75
-
76
- assert_equal( "" , $ff.button(:index, 2).title )
77
- assert_equal( "this is button1" , $ff.button(:index, 1).title )
78
- end
79
-
80
-
81
- def test_button_using_default
82
- # since most of the time, a button will be accessed based on its caption, there is a default way of accessing it....
83
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button( "Missing Caption").click }
84
-
85
- $ff.button("Click Me").click
86
- assert($ff.text.include?("PASS") )
87
- end
88
-
89
- def test_Button_click_only
90
- $ff.button(:caption, "Click Me").click
91
- assert($ff.text.include?("PASS") )
92
- end
93
-
94
- def test_button_click
95
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:caption, "Missing Caption").click }
96
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:id, "missingID").click }
97
-
98
- assert_raises(ObjectDisabledException , "ObjectDisabledException was supposed to be thrown" ) { $ff.button(:caption, "Disabled Button").click }
99
-
100
- $ff.button(:caption, "Click Me").click
101
- assert($ff.text.include?("PASS") )
102
- end
103
-
104
- def test_Button_Exists
105
- assert($ff.button(:caption, "Click Me").exists?)
106
- assert($ff.button(:caption, "Submit").exists?)
107
- assert($ff.button(:name, "b1").exists?)
108
- assert($ff.button(:id, "b2").exists?)
109
- assert($ff.button(:caption, /sub/i).exists?)
110
-
111
- assert_false($ff.button(:caption, "missingcaption").exists?)
112
- assert_false($ff.button(:name, "missingname").exists?)
113
- assert_false($ff.button(:id, "missingid").exists?)
114
- assert_false($ff.button(:caption, /missing/i).exists?)
115
- end
116
-
117
- def test_Button_Enabled
118
- assert($ff.button(:caption, "Click Me").enabled?)
119
- assert_false($ff.button(:caption, "Disabled Button").enabled?)
120
- assert_false($ff.button(:name, "b4").enabled?)
121
- assert_false($ff.button(:id, "b5").enabled?)
122
-
123
- assert_raises(UnknownObjectException , "UnknownObjectException was supposed to be thrown" ) { $ff.button(:name, "noName").enabled? }
124
- end
125
-
126
- def test_button2
127
- assert($ff.button(:caption, "Click Me2").exists?, 'Can\'t find Button with caption "Click Me2"')
128
-
129
- assert($ff.button(:caption, "Disabled Button2").exists?, 'Can\'t find Button with caption "Disabled Button2"')
130
- assert($ff.button(:caption, "Sign In").exists?, 'Can\'t find Button with caption "Sign In"')
131
-
132
- assert_equal("b6" , $ff.button(:id, "b7").name )
133
- assert_equal("b7" , $ff.button(:name, "b6").id )
134
- assert_equal("Click Me2" , $ff.button(:id, "b7").value )
135
- assert_equal(false , $ff.button(:id, "b7").disabled )
136
- assert_equal("italic_button" , $ff.button(:name, "b6").class_name )
137
-
138
- assert_equal("b8" , $ff.button(:id, "b9").name )
139
- assert_equal("b9" , $ff.button(:name, "b8").id )
140
- assert_equal("Disabled Button2" , $ff.button(:id, "b9").value )
141
- assert_equal(false , $ff.button(:id, "b9").enabled?)
142
- assert_equal("" , $ff.button(:name, "b8").class_name )
143
- assert_equal("Sign In", $ff.button(:caption, "Sign In").value)
144
-
145
- assert($ff.button(:caption, "Click Me").enabled?, 'Button wih caption "Click Me" should be enabled')
146
-
147
- assert_false($ff.button(:caption, "Disabled Button2").enabled?, 'Button wih caption "Disabled Button2" should be disabled')
148
-
149
-
150
- assert_raises(ObjectDisabledException , "ObjectDisabledException was supposed to be thrown" ) { $ff.button(:caption, "Disabled Button2").click }
151
-
152
- $ff.button(:caption, "Click Me2").click
153
- assert($ff.text.include?("PASS"), 'Clicking on "Click Me2" button should\'ve taken to the "PASS" page')
154
-
155
- end
156
-
157
- def test_frame
158
- goto_frames_page()
159
- f = $ff.frame("buttonFrame")
160
- assert(f.button(:caption, "Click Me").enabled?)
161
- #assert_raises( UnknownObjectException , "UnknownObjectException was supposed to be thrown ( no frame name supplied) " ) { $ff.button(:caption, "Disabled Button").enabled?}
162
- end
163
-
164
- def test_buttons
165
- arrButtons = $ff.buttons
166
- assert_equal(7, arrButtons.length)
167
- #arrButtons.each do |button|
168
- #puts button.to_s
169
- #end
170
- assert_equal("b2", arrButtons[1].id)
171
- assert_equal("b5", arrButtons[2].id)
172
- assert_equal("Submit", arrButtons[3].value)
173
- assert_equal("sub3", arrButtons[4].name)
174
- assert_equal("b7", arrButtons[5].id)
175
- assert_equal("b9", arrButtons[6].id)
176
- assert_equal("Sign In", arrButtons[7].value)
177
- end
178
-
179
- # Tests collection class
180
- def test_class_buttons
181
- arr_buttons = $ff.buttons
182
- arr_buttons.each do |b|
183
- assert(b.instance_of?(Button),"element class should be #{Button}; got #{b.class}")
184
- end
185
- # test properties
186
- assert_equal("b2", arr_buttons[1].id)
187
- assert_equal("b1", arr_buttons[1].name)
188
- assert_equal("button", arr_buttons[1].type)
189
- assert_equal("Click Me", arr_buttons[1].value)
190
- assert_equal(false, arr_buttons[1].disabled)
191
- assert_equal("italic_button", arr_buttons[1].class_name)
192
- assert_equal( "this is button1", arr_buttons[1].title)
193
-
194
- assert_equal("b5", arr_buttons[2].id)
195
- assert_equal("b4", arr_buttons[2].name)
196
- assert_equal("button", arr_buttons[2].type)
197
- assert_equal("Disabled Button", arr_buttons[2].value)
198
- assert_equal(true, arr_buttons[2].disabled)
199
- assert_equal( "", arr_buttons[2].title)
200
- assert_equal("", arr_buttons[2].class_name)
201
-
202
- assert_equal("Submit", arr_buttons[3].value)
203
- assert_equal("sub3", arr_buttons[4].name)
204
- assert_equal("b7", arr_buttons[5].id)
205
- assert_equal("b9", arr_buttons[6].id)
206
- assert_equal("Sign In", arr_buttons[7].value)
207
-
208
-
209
-
210
-
211
- end
212
-
213
-
214
- end
215
-