marekj-watirloo 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/watirloo.rb'}"
9
+ puts "Loading watirloo gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
@@ -0,0 +1 @@
1
+ @ruby script/console %*
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1 @@
1
+ @ruby script/destroy %*
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1 @@
1
+ @ruby script/generate %*
data/script/reflect.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'watirloo'
2
+ # simple implementation of reflector. Just reflect everything on the page.
3
+
4
+ ie = Watir::IE.attach(:url, //)
5
+
6
+ ie.reflect(:all).each do |r|
7
+ puts r
8
+ end
@@ -0,0 +1,68 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class CheckboxGroupPage < Watirloo::Page
4
+ # semantic wrapper for the radio group object
5
+ def pets
6
+ @b.checkbox_group('pets')
7
+ end
8
+ end
9
+
10
+
11
+ describe 'CheckboxGroup class' do
12
+
13
+ before do
14
+ @page = CheckboxGroupPage.new
15
+ @page.b.goto testfile('checkbox_group1.html')
16
+ end
17
+
18
+ # let's check explicitly for test purpose what Class is we are dealing with
19
+ # if IE then Watir::CheckboxGroup
20
+ # if FF then FireWatir::CheckboxGroup
21
+ it 'checkbox_group container method returns CheckboxGroup class' do
22
+ if @page.b.kind_of?(FireWatir::Firefox)
23
+ @page.pets.kind_of?(FireWatir::CheckboxGroup).should == true
24
+
25
+ elsif @page.b.kind_of?(Watir::IE)
26
+ @page.pets.kind_of?(Watir::CheckboxGroup).should == true
27
+ end
28
+ end
29
+
30
+ it 'size retuns checkboxes as items count in a group' do
31
+ @page.pets.size.should == 5
32
+ end
33
+
34
+ it 'values returns array of value attributes for each checkbox in a group' do
35
+ @page.pets.values.should == ["cat", "dog", "zook", "zebra", "wumpa"]
36
+ end
37
+
38
+ it 'selected_values returns array of value attributes of each selected checkbox' do
39
+ @page.pets.selected.should == nil
40
+ @page.pets.selected_value.should == nil
41
+ @page.pets.selected_values.should == []
42
+ end
43
+
44
+ it 'set String checks the checkbox in a group where value is String' do
45
+ @page.pets.set 'dog'
46
+ @page.pets.selected.should == 'dog'
47
+ @page.pets.selected_value.should == 'dog'
48
+ @page.pets.selected_values.should == ['dog']
49
+ end
50
+
51
+ it 'set String array checks each checkbox by hidden value String' do
52
+ @page.pets.set ['dog', 'zebra', 'cat'] # not in order
53
+ @page.pets.selected.should == ['cat', 'dog', 'zebra']
54
+ @page.pets.selected_value.should == ['cat', 'dog', 'zebra'] # bypass filter
55
+ @page.pets.selected_values.should == ['cat', 'dog', 'zebra']
56
+ end
57
+
58
+ it 'set Fixnum checks checkbox by position in a group. Position is 1 based' do
59
+ @page.pets.set 3
60
+ @page.pets.selected_values.should == ['zook']
61
+ end
62
+
63
+ it 'set array of Fixnums checks each checkbox by position' do
64
+ @page.pets.set [4,1,2] # not in order
65
+ @page.pets.selected_values.should == ["cat", "dog", "zebra"]
66
+ end
67
+
68
+ end
@@ -0,0 +1,46 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ describe 'setting and getting values for individual checkboxes with value attributes in face definitions' do
4
+
5
+ before do
6
+ @page = Watirloo::Page.new
7
+ @page.goto testfile('checkbox_group1.html')
8
+ @page.add_face(
9
+ :pets_cat => [:checkbox, :name, 'pets', 'cat'],
10
+ :pets_dog => [:checkbox, :name, 'pets', 'dog'],
11
+ :pets_zook => [:checkbox, :name, 'pets', 'zook'],
12
+ :pets_zebra => [:checkbox, :name, 'pets', 'zebra'],
13
+ :pets_wumpa => [:checkbox, :name, 'pets', 'wumpa'])
14
+ end
15
+
16
+ it 'semantic name accesses individual CheckBox' do
17
+ if @page.b.kind_of?(FireWatir::Firefox)
18
+ @page.face(:pets_cat).kind_of?(FireWatir::CheckBox).should == true
19
+
20
+ elsif @page.b.kind_of?(Watir::IE)
21
+ @page.face(:pets_cat).kind_of?(Watir::CheckBox).should == true
22
+ end
23
+ end
24
+
25
+ it 'set individual checkbox does not set other checkboxes sharing the same name' do
26
+ @page.face(:pets_dog).checked?.should == false
27
+ @page.face(:pets_dog).set
28
+ @page.face(:pets_dog).checked?.should == true
29
+ @page.face(:pets_cat).checked?.should == false
30
+ end
31
+
32
+ it 'by default all are false. set each unchecked checkbox should have checked? true' do
33
+ @page.faces.keys.each do |key|
34
+ @page.face(key).checked?.should == false
35
+ end
36
+
37
+ @page.faces.keys.each do |key|
38
+ @page.face(key).set
39
+ end
40
+
41
+ @page.faces.keys.each do |key|
42
+ @page.face(key).checked?.should.be true
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,38 @@
1
+ require File.dirname(__FILE__) + '/../../lib/watirloo/firewatir_ducktape'
2
+
3
+ # TESTS FIXME kill all browsers before and after the test
4
+ require 'test/spec'
5
+
6
+ describe 'firefox.new has option key :attach that does not start new browser' do
7
+
8
+ before :each do
9
+ @b = FireWatir::Firefox.start 'file:///' + File.dirname(__FILE__) + '/../html/person.html'
10
+ sleep 5
11
+ end
12
+
13
+ after :each do
14
+ @b.close
15
+ sleep 5
16
+ end
17
+
18
+ it 'new with option :atach => true attaches to existing window and does not start new window' do
19
+ @b.title.should == 'Person'
20
+ b = FireWatir::Firefox.new :attach => true
21
+ b.title.should == 'Person'
22
+ end
23
+
24
+ it 'why does attach instance method throw exception when only one window exists on the desktop' do
25
+ assert_raise(Watir::Exception::NoMatchingWindowFoundException) do
26
+ b = @b.attach :title, 'Person'
27
+ end
28
+ end
29
+
30
+ it 'why does attach instance method throw exception when attaching to original window while another exists' do
31
+ b = FireWatir::Firefox.start 'file:///' + File.dirname(__FILE__) + '/../html/census.html'
32
+ sleep 3
33
+ assert_raise(Watir::Exception::NoMatchingWindowFoundException) do
34
+ c = b.attach :title, 'Person' #attach to the setup window
35
+ end
36
+ end
37
+
38
+ end
@@ -0,0 +1,332 @@
1
+ <!--
2
+ Document : census
3
+ -->
4
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5
+ <html>
6
+ <head>
7
+ <title>Census</title>
8
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
9
+ <style>
10
+ td {font-size: 11px;
11
+ background-color: #eee;}
12
+ </style>
13
+ </head>
14
+ <body>
15
+
16
+ <table id="census" width="800" cellSpacing="1" cellPadding="2" width="100%" border="0">
17
+ <tbody>
18
+ <tr>
19
+ <td class="head" colSpan="8">
20
+ Census
21
+ </td>
22
+ </tr>
23
+
24
+ <tr id="header">
25
+ <td>Emp</td>
26
+ <td>Last Name</td>
27
+ <td>First Name</td>
28
+ <td>DOB (mm/dd/yyyy)</td>
29
+ <td>Age In Years</td>
30
+ <td>Gender</td>
31
+ <td>State</td>
32
+ <td>Status</td>
33
+ </tr>
34
+
35
+ <tr id="row0">
36
+ <td><input type="checkbox" name="census_check0" value="1" />&nbsp;1</td>
37
+ <td><input maxLength="40" size="10" name="last_name0" value="" /></td>
38
+ <td><input maxLength="20" size="10" name="first_name0" value="" /></td>
39
+ <td><input maxLength="10" size="10" name="dob0" value="" /></td>
40
+ <td><input maxLength="3" size="3" name="age0" value="" /></td>
41
+ <td>
42
+ <select name="sex_cd0">
43
+ <option value=" "></option>
44
+ <option value="M">M</option>
45
+ <option value="F">F</option>
46
+ </select>
47
+ </td>
48
+
49
+ <td>
50
+ <select name="state_cd0">
51
+ <option value=""></option>
52
+ <option value="TX">Texas</option>
53
+ <option value="IL">Illinois</option>
54
+ <option value="IN">Indiana</option>
55
+ <option value="OT">Other</option>
56
+ </select>
57
+ </td>
58
+ <td>
59
+ <select name="emp_status0">
60
+ <option selected value="NO"></option><option value="FT">Employed Full Time</option>
61
+ <option value="UN">Unemployed</option>
62
+ <option value="PT">Employed Part Time</option>
63
+ <option value="RT">Retired</option></select>
64
+ </td>
65
+ </tr>
66
+
67
+ <tr id="row1">
68
+ <td><input type="checkbox" name="census_check1" value="2" />&nbsp;2</td>
69
+ <td><input maxLength="40" size="10" name="last_name1" value="" /></td>
70
+ <td><input maxLength="20" size="10" name="first_name1" value="" /></td>
71
+ <td><input maxLength="10" size="10" name="dob1" value="" /></td>
72
+ <td><input maxLength="3" size="3" name="age1" value="" /></td>
73
+ <td>
74
+ <select name="sex_cd1">
75
+ <option value=" "></option>
76
+ <option value="M">M</option>
77
+ <option value="F">F</option>
78
+ </select>
79
+ </td>
80
+
81
+ <td>
82
+ <select name="state_cd1">
83
+ <option value=""></option>
84
+ <option value="TX">Texas</option>
85
+ <option value="IL">Illinois</option>
86
+ <option value="IN">Indiana</option>
87
+ <option value="OT">Other</option>
88
+ </select>
89
+ </td>
90
+ <td>
91
+ <select name="emp_status1">
92
+ <option selected value="NO"></option>
93
+ <option value="FT">Employed Full Time</option>
94
+ <option value="UN">Unemployed</option>
95
+ <option value="PT">Employed Part Time</option>
96
+ <option value="RT">Retired</option></select>
97
+ </td>
98
+ </tr>
99
+
100
+ <tr id="row2">
101
+ <td><input type="checkbox" name="census_check2" value="3" />&nbsp;3</td>
102
+ <td><input maxLength="40" size="10" name="last_name2" value="" /></td>
103
+ <td><input maxLength="20" size="10" name="first_name2" value="" /></td>
104
+ <td><input maxLength="10" size="10" name="dob2" value="" /></td>
105
+ <td><input maxLength="3" size="3" name="age2" value="" /></td>
106
+ <td>
107
+ <select name="sex_cd2">
108
+ <option value=" "></option>
109
+ <option value="M">M</option>
110
+ <option value="F">F</option>
111
+ </select>
112
+ </td>
113
+
114
+ <td>
115
+ <select name="state_cd2">
116
+ <option value=""></option>
117
+ <option value="TX">Texas</option>
118
+ <option value="IL">Illinois</option>
119
+ <option value="IN">Indiana</option>
120
+ <option value="OT">Other</option>
121
+ </select>
122
+ </td>
123
+ <td>
124
+ <select name="emp_status2">
125
+ <option value=""></option>
126
+ <option value="FT">Employed Full Time</option>
127
+ <option value="UN">Unemployed</option>
128
+ <option value="PT">Employed Part Time</option>
129
+ <option value="RT">Retired</option></select>
130
+ </td>
131
+ </tr>
132
+
133
+ <tr id="row3">
134
+ <td><input type="checkbox" name="census_check3" value="4" />&nbsp;4</td>
135
+ <td><input maxLength="40" size="10" name="last_name3" value="" /></td>
136
+ <td><input maxLength="20" size="10" name="first_name3" value="" /></td>
137
+ <td><input maxLength="10" size="10" name="dob3" value="" /></td>
138
+ <td><input maxLength="3" size="3" name="age3" value="" /></td>
139
+ <td>
140
+ <select name="sex_cd3">
141
+ <option value=" "></option>
142
+ <option value="M">M</option>
143
+ <option value="F">F</option>
144
+ </select>
145
+ </td>
146
+
147
+ <td>
148
+ <select name="state_cd3">
149
+ <option value=""></option>
150
+ <option value="TX">Texas</option>
151
+ <option value="IL">Illinois</option>
152
+ <option value="IN">Indiana</option>
153
+ <option value="OT">Other</option>
154
+ </select>
155
+ </td>
156
+ <td>
157
+ <select name="emp_status3">
158
+ <option value=""></option><option value="FT">Employed Full Time</option>
159
+ <option value="UN">Unemployed</option>
160
+ <option value="PT">Employed Part Time</option>
161
+ <option value="RT">Retired</option></select>
162
+ </td>
163
+ </tr>
164
+
165
+ <tr id="row4">
166
+ <td><input type="checkbox" name="census_check4" value="5" />&nbsp;5</td>
167
+ <td><input maxLength="40" size="10" name="last_name4" value="" /></td>
168
+ <td><input maxLength="20" size="10" name="first_name4" value="" /></td>
169
+ <td><input maxLength="10" size="10" name="dob4" value="" /></td>
170
+ <td><input maxLength="3" size="3" name="age4" value="" /></td>
171
+ <td>
172
+ <select name="sex_cd4">
173
+ <option value=" "></option>
174
+ <option value="M">M</option>
175
+ <option value="F">F</option>
176
+ </select>
177
+ </td>
178
+
179
+ <td>
180
+ <select name="state_cd4">
181
+ <option value=""></option>
182
+ <option value="TX">Texas</option>
183
+ <option value="IL">Illinois</option>
184
+ <option value="IN">Indiana</option>
185
+ <option value="OT">Other</option>
186
+ </select>
187
+ </td>
188
+ <td>
189
+ <select name="emp_status4">
190
+ <option value=""></option><option value="FT">Employed Full Time</option>
191
+ <option value="UN">Unemployed</option>
192
+ <option value="PT">Employed Part Time</option>
193
+ <option value="RT">Retired</option></select>
194
+ </td>
195
+ </tr>
196
+
197
+ <tr id="row5">
198
+ <td><input type="checkbox" name="census_check5" value="6" />&nbsp;6</td>
199
+ <td><input maxLength="40" size="10" name="last_name5" value="" /></td>
200
+ <td><input maxLength="20" size="10" name="first_name5" value="" /></td>
201
+ <td><input maxLength="10" size="10" name="dob5" value="" /></td>
202
+ <td><input maxLength="3" size="3" name="age5" value="" /></td>
203
+ <td>
204
+ <select name="sex_cd5">
205
+ <option value=" "></option>
206
+ <option value="M">M</option>
207
+ <option value="F">F</option>
208
+ </select>
209
+ </td>
210
+
211
+ <td>
212
+ <select name="state_cd5">
213
+ <option value=""></option>
214
+ <option value="TX">Texas</option>
215
+ <option value="IL">Illinois</option>
216
+ <option value="IN">Indiana</option>
217
+ <option value="OT">Other</option>
218
+ </select>
219
+ </td>
220
+ <td>
221
+ <select name="emp_status5">
222
+ <option value=""></option><option value="FT">Employed Full Time</option>
223
+ <option value="UN">Unemployed</option>
224
+ <option value="PT">Employed Part Time</option>
225
+ <option value="RT">Retired</option></select>
226
+ </td>
227
+ </tr>
228
+
229
+
230
+ <tr id="row6">
231
+ <td><input type="checkbox" name="census_check6" value="7" />&nbsp;7</td>
232
+ <td><input maxLength="40" size="10" name="last_name6" value="" /></td>
233
+ <td><input maxLength="20" size="10" name="first_name6" value="" /></td>
234
+ <td><input maxLength="10" size="10" name="dob6" value="" /></td>
235
+ <td><input maxLength="3" size="3" name="age6" value="" /></td>
236
+ <td>
237
+ <select name="sex_cd6">
238
+ <option value=" "></option>
239
+ <option value="M">M</option>
240
+ <option value="F">F</option>
241
+ </select>
242
+ </td>
243
+
244
+ <td>
245
+ <select name="state_cd6">
246
+ <option value=""></option>
247
+ <option value="TX">Texas</option>
248
+ <option value="IL">Illinois</option>
249
+ <option value="IN">Indiana</option>
250
+ <option value="OT">Other</option>
251
+ </select>
252
+ </td>
253
+ <td>
254
+ <select name="emp_status6">
255
+ <option value=""></option><option value="FT">Employed Full Time</option>
256
+ <option value="UN">Unemployed</option>
257
+ <option value="PT">Employed Part Time</option>
258
+ <option value="RT">Retired</option></select>
259
+ </td>
260
+ </tr>
261
+
262
+ <tr id="row7">
263
+ <td><input type="checkbox" name="census_check7" value="8" />&nbsp;8</td>
264
+ <td><input maxLength="40" size="10" name="last_name7" value="" /></td>
265
+ <td><input maxLength="20" size="10" name="first_name7" value="" /></td>
266
+ <td><input maxLength="10" size="10" name="dob7" value="" /></td>
267
+ <td><input maxLength="3" size="3" name="age7" value="" /></td>
268
+ <td>
269
+ <select name="sex_cd7">
270
+ <option value=" "></option>
271
+ <option value="M">M</option>
272
+ <option value="F">F</option>
273
+ </select>
274
+ </td>
275
+
276
+ <td>
277
+ <select name="state_cd7">
278
+ <option value=""></option>
279
+ <option value="TX">Texas</option>
280
+ <option value="IL">Illinois</option>
281
+ <option value="IN">Indiana</option>
282
+ <option value="OT">Other</option>
283
+ </select>
284
+ </td>
285
+ <td>
286
+ <select name="emp_status7">
287
+ <option value=""></option><option value="FT">Employed Full Time</option>
288
+ <option value="UN">Unemployed</option>
289
+ <option value="PT">Employed Part Time</option>
290
+ <option value="RT">Retired</option></select>
291
+ </td>
292
+ </tr>
293
+
294
+ <tr id="row8">
295
+ <td><input type="checkbox" name="census_check8" value="9" />&nbsp;9</td>
296
+ <td><input maxLength="40" size="10" name="last_name8" value="" /></td>
297
+ <td><input maxLength="20" size="10" name="first_name8" value="" /></td>
298
+ <td><input maxLength="10" size="10" name="dob8" value="" /></td>
299
+ <td><input maxLength="3" size="3" name="age8" value="" /></td>
300
+ <td>
301
+ <select name="sex_cd8">
302
+ <option value=" "></option>
303
+ <option value="M">M</option>
304
+ <option value="F">F</option>
305
+ </select>
306
+ </td>
307
+
308
+ <td>
309
+ <select name="state_cd8">
310
+ <option value=""></option>
311
+ <option value="TX">Texas</option>
312
+ <option value="IL">Illinois</option>
313
+ <option value="IN">Indiana</option>
314
+ <option value="OT">Other</option>
315
+ </select>
316
+ </td>
317
+ <td>
318
+ <select name="emp_status8">
319
+ <option value=""></option><option value="FT">Employed Full Time</option>
320
+ <option value="UN">Unemployed</option>
321
+ <option value="PT">Employed Part Time</option>
322
+ <option value="RT">Retired</option></select>
323
+ </td>
324
+ </tr>
325
+
326
+
327
+ </tbody>
328
+ </table>
329
+
330
+
331
+ </body>
332
+ </html>