watir 1.6.5 → 1.6.6.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +461 -326
- data/VERSION +1 -0
- data/bin/watir-console +6 -6
- data/lib/changes.rb +3 -3
- data/lib/license.rb +38 -38
- data/lib/readme.rb +140 -140
- data/lib/watir/WindowHelper.rb +49 -49
- data/lib/watir/camel_case.rb +66 -66
- data/lib/watir/clickJSDialog.rb +19 -19
- data/lib/watir/close_all.rb +37 -37
- data/lib/watir/collections.rb +392 -344
- data/lib/watir/container.rb +857 -815
- data/lib/watir/contrib/enabled_popup.rb +20 -20
- data/lib/watir/contrib/ie-new-process.rb +27 -27
- data/lib/watir/contrib/page_checker.rb +29 -29
- data/lib/watir/cookiemanager.rb +55 -55
- data/lib/watir/core.rb +28 -0
- data/lib/watir/core_ext.rb +17 -17
- data/lib/watir/datahandler.rb +107 -107
- data/lib/watir/dialog.rb +46 -46
- data/lib/watir/element.rb +351 -343
- data/lib/watir/element_collections.rb +97 -97
- data/lib/watir/form.rb +170 -170
- data/lib/watir/frame.rb +59 -59
- data/lib/watir/html_element.rb +22 -0
- data/lib/watir/ie-class.rb +1006 -1009
- data/lib/watir/ie-process.rb +39 -39
- data/lib/watir/ie.rb +70 -133
- data/lib/watir/image.rb +130 -130
- data/lib/watir/input_elements.rb +614 -572
- data/lib/watir/irb-history.rb +30 -30
- data/lib/watir/link.rb +64 -64
- data/lib/watir/locator.rb +200 -176
- data/lib/watir/logger.rb +19 -19
- data/lib/watir/modal_dialog.rb +122 -122
- data/lib/watir/module.rb +37 -0
- data/lib/watir/non_control_elements.rb +145 -145
- data/lib/watir/page-container.rb +116 -107
- data/lib/watir/popup.rb +29 -29
- data/lib/watir/process.rb +19 -19
- data/lib/watir/screen_capture.rb +115 -115
- data/lib/watir/setFileDialog.rb +16 -16
- data/lib/watir/table.rb +395 -362
- data/lib/watir/watir_simple.rb +475 -475
- data/lib/watir/win32.rb +35 -35
- data/lib/watir/win32ole.rb +14 -14
- data/lib/watir/winClicker.rb +496 -496
- data/rakefile.rb +70 -0
- data/unittests/all_tests.rb +10 -10
- data/unittests/buttons_xpath_test.rb +69 -69
- data/unittests/checkbox_test.rb +179 -179
- data/unittests/checkbox_xpath_test.rb +107 -107
- data/unittests/click_no_wait_test.rb +21 -0
- data/unittests/core_tests.rb +17 -17
- data/unittests/css_test.rb +42 -35
- data/unittests/defer_test.rb +46 -46
- data/unittests/dialog_test.rb +77 -77
- data/unittests/div2_xpath_test.rb +21 -21
- data/unittests/div_test.rb +188 -188
- data/unittests/div_xpath_test.rb +96 -96
- data/unittests/element_test.rb +49 -0
- data/unittests/errorchecker_test.rb +32 -22
- data/unittests/filefield_test.rb +39 -39
- data/unittests/filefield_xpath_test.rb +33 -33
- data/unittests/form_test.rb +280 -280
- data/unittests/form_xpath_test.rb +252 -252
- data/unittests/frame_test.rb +155 -155
- data/unittests/google_form_test.rb +15 -15
- data/unittests/html/JavascriptClick.html +39 -39
- data/unittests/html/blankpage.html +11 -11
- data/unittests/html/buttons1.html +40 -40
- data/unittests/html/checkboxes1.html +89 -89
- data/unittests/html/click_no_wait.html +14 -0
- data/unittests/html/complex_table.html +36 -36
- data/unittests/html/cssTest.html +42 -42
- data/unittests/html/depot_store.html +59 -59
- data/unittests/html/div.html +93 -93
- data/unittests/html/div_xml.html +20 -20
- data/unittests/html/fileupload.html +45 -45
- data/unittests/html/formTest1.html +38 -38
- data/unittests/html/forms2.html +44 -44
- data/unittests/html/forms3.html +131 -131
- data/unittests/html/forms4.html +27 -27
- data/unittests/html/frame_buttons.html +3 -3
- data/unittests/html/frame_links.html +3 -3
- data/unittests/html/frame_multi.html +4 -4
- data/unittests/html/google_india.html +119 -119
- data/unittests/html/iframeTest.html +12 -12
- data/unittests/html/iframeTest1.html +6 -6
- data/unittests/html/iframeTest2.html +5 -5
- data/unittests/html/images1.html +66 -66
- data/unittests/html/javascriptevents.html +35 -35
- data/unittests/html/link_pass.html +10 -10
- data/unittests/html/links1.html +38 -38
- data/unittests/html/links2.html +10 -10
- data/unittests/html/links_multi.html +14 -14
- data/unittests/html/list_matters.html +720 -720
- data/unittests/html/lists.html +17 -17
- data/unittests/html/map_test.html +31 -31
- data/unittests/html/modal_dialog.html +10 -10
- data/unittests/html/modal_dialog_launcher.html +11 -11
- data/unittests/html/nestedFrames.html +6 -6
- data/unittests/html/new_browser.html +16 -16
- data/unittests/html/pass.html +12 -12
- data/unittests/html/popups1.html +59 -59
- data/unittests/html/pre.html +27 -27
- data/unittests/html/radioButtons1.html +71 -71
- data/unittests/html/select_tealeaf.html +54 -54
- data/unittests/html/selectboxes1.html +52 -52
- data/unittests/html/simple_table.html +26 -26
- data/unittests/html/simple_table_buttons.html +104 -104
- data/unittests/html/simple_table_columns.html +76 -76
- data/unittests/html/table1.html +181 -181
- data/unittests/html/tableCell_using_xpath.html +19 -19
- data/unittests/html/table_and_tablerow_to_a.html +174 -0
- data/unittests/html/textarea.html +30 -30
- data/unittests/html/textfields1.html +88 -88
- data/unittests/html/textsearch.html +44 -44
- data/unittests/html/wallofcheckboxes.html +1003 -1003
- data/unittests/html/xpath_nbsp.html +12 -12
- data/unittests/ie_exists_test.rb +33 -33
- data/unittests/ie_mock.rb +94 -94
- data/unittests/ie_test.rb +51 -51
- data/unittests/images_test.rb +157 -157
- data/unittests/images_xpath_test.rb +91 -91
- data/unittests/links_multi_test.rb +48 -48
- data/unittests/links_test.rb +175 -175
- data/unittests/links_xpath_test.rb +39 -39
- data/unittests/lists_test.rb +32 -32
- data/unittests/map_test.rb +98 -98
- data/unittests/minmax_test.rb +31 -31
- data/unittests/navigate_test.rb +39 -39
- data/unittests/nbsp_xpath_test.rb +16 -16
- data/unittests/non_core_tests.rb +12 -12
- data/unittests/other/WindowLogonExample.rb +27 -27
- data/unittests/other/WindowLogonExtra.rb +6 -6
- data/unittests/other/all_tests_concurrent.rb +57 -57
- data/unittests/other/jscriptExtraAlert.rb +6 -6
- data/unittests/other/jscriptExtraConfirmCancel.rb +6 -6
- data/unittests/other/jscriptExtraConfirmOk.rb +6 -6
- data/unittests/other/jscriptPushButton.rb +6 -6
- data/unittests/other/jscript_test.rb +63 -63
- data/unittests/other/navigate_exception_test.rb +24 -24
- data/unittests/other/rexml_unit_test.rb +27 -27
- data/unittests/other/screen_capture_test.rb +54 -54
- data/unittests/other/testcase_method_order_test.rb +35 -35
- data/unittests/other/testcase_verify_test.rb +24 -24
- data/unittests/other/wait_until_test.rb +99 -99
- data/unittests/pagecontainstext_test.rb +69 -69
- data/unittests/parent_child_test.rb +43 -43
- data/unittests/perf_test.rb +20 -20
- data/unittests/popups_test.rb +43 -43
- data/unittests/pre_test.rb +53 -53
- data/unittests/radios_test.rb +212 -212
- data/unittests/radios_xpath_test.rb +101 -101
- data/unittests/security_setting_test.rb +23 -23
- data/unittests/selectbox_test.rb +148 -148
- data/unittests/selectbox_xpath_test.rb +113 -113
- data/unittests/setup.rb +87 -77
- data/unittests/speed_settings_test.rb +67 -67
- data/unittests/table_and_tablerow_to_a_test.rb +117 -0
- data/unittests/table_cell_using_xpath_test.rb +35 -35
- data/unittests/table_test.rb +376 -376
- data/unittests/table_xpath_test.rb +110 -110
- data/unittests/test_tests.rb +9 -9
- data/unittests/textarea_test.rb +92 -92
- data/unittests/textarea_xpath_test.rb +78 -78
- data/unittests/textfield_for_ch_char_test.rb +31 -31
- data/unittests/textfields_test.rb +218 -218
- data/unittests/textfields_xpath_test.rb +111 -111
- data/unittests/window_tests.rb +10 -10
- data/unittests/windows/attach_to_existing_window_test.rb +53 -53
- data/unittests/windows/attach_to_new_window_test.rb +83 -83
- data/unittests/windows/close_window_test.rb +20 -20
- data/unittests/windows/frame_links_test.rb +25 -25
- data/unittests/windows/ie-each_test.rb +47 -47
- data/unittests/windows/iedialog_test.rb +54 -54
- data/unittests/windows/js_events_test.rb +42 -55
- data/unittests/windows/modal_dialog_test.rb +128 -128
- data/unittests/windows/new_test.rb +57 -57
- data/unittests/windows/open_close_test.rb +18 -18
- data/unittests/windows/send_keys_test.rb +33 -33
- data/unittests/xpath_tests.rb +10 -10
- metadata +85 -31
- data/lib/watir/utils.rb +0 -20
- data/lib/watir/version.rb +0 -5
data/lib/watir/container.rb
CHANGED
@@ -1,815 +1,857 @@
|
|
1
|
-
module Watir
|
2
|
-
# This module contains the factory methods that are used to access most html objects
|
3
|
-
#
|
4
|
-
# For example, to access a button on a web page that has the following html
|
5
|
-
# <input type
|
6
|
-
#
|
7
|
-
# the following watir code could be used
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# or
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
# there are many methods available to the Button object
|
16
|
-
|
17
|
-
# Is includable for classes that have @container, document and ole_inner_elements
|
18
|
-
module Container
|
19
|
-
include Watir::Exception
|
20
|
-
|
21
|
-
# Note: @container is the container of this object, i.e. the container
|
22
|
-
# of this container.
|
23
|
-
# In other words, for
|
24
|
-
# container of this_thing is the table.
|
25
|
-
|
26
|
-
# This is used to change the typing speed when entering text on a page.
|
27
|
-
attr_accessor :typingspeed
|
28
|
-
attr_accessor :type_keys
|
29
|
-
# The color we want to use for the active object. This can be any valid web-friendly color.
|
30
|
-
attr_accessor :activeObjectHighLightColor
|
31
|
-
# The PageContainer object containing this element
|
32
|
-
attr_accessor :page_container
|
33
|
-
|
34
|
-
def copy_test_config(container) # only used by form and frame
|
35
|
-
@typingspeed = container.typingspeed
|
36
|
-
@type_keys = container.type_keys
|
37
|
-
@activeObjectHighLightColor = container.activeObjectHighLightColor
|
38
|
-
end
|
39
|
-
private :copy_test_config
|
40
|
-
|
41
|
-
# Write the specified string to the log.
|
42
|
-
def log(what)
|
43
|
-
@container.logger.debug(what) if @logger
|
44
|
-
end
|
45
|
-
|
46
|
-
# Wait until
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
#
|
108
|
-
#
|
109
|
-
# *
|
110
|
-
#
|
111
|
-
#
|
112
|
-
#
|
113
|
-
#
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
#
|
122
|
-
# :index
|
123
|
-
# :
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
#
|
129
|
-
#
|
130
|
-
#
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
#
|
138
|
-
#
|
139
|
-
#
|
140
|
-
#
|
141
|
-
#
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
#
|
149
|
-
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
#
|
162
|
-
#
|
163
|
-
#
|
164
|
-
#
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
#
|
175
|
-
#
|
176
|
-
#
|
177
|
-
#
|
178
|
-
#
|
179
|
-
#
|
180
|
-
#
|
181
|
-
#
|
182
|
-
#
|
183
|
-
#
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
#
|
192
|
-
#
|
193
|
-
#
|
194
|
-
#
|
195
|
-
#
|
196
|
-
#
|
197
|
-
#
|
198
|
-
#
|
199
|
-
#
|
200
|
-
#
|
201
|
-
#
|
202
|
-
#
|
203
|
-
#
|
204
|
-
#
|
205
|
-
#
|
206
|
-
#
|
207
|
-
#
|
208
|
-
#
|
209
|
-
#
|
210
|
-
#
|
211
|
-
#
|
212
|
-
#
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
#
|
221
|
-
#
|
222
|
-
#
|
223
|
-
#
|
224
|
-
#
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
#
|
232
|
-
#
|
233
|
-
# :
|
234
|
-
# :
|
235
|
-
#
|
236
|
-
#
|
237
|
-
#
|
238
|
-
#
|
239
|
-
#
|
240
|
-
#
|
241
|
-
#
|
242
|
-
#
|
243
|
-
#
|
244
|
-
#
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
#
|
252
|
-
#
|
253
|
-
#
|
254
|
-
#
|
255
|
-
#
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
#
|
263
|
-
#
|
264
|
-
#
|
265
|
-
#
|
266
|
-
#
|
267
|
-
#
|
268
|
-
#
|
269
|
-
#
|
270
|
-
#
|
271
|
-
#
|
272
|
-
#
|
273
|
-
#
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
#
|
282
|
-
#
|
283
|
-
#
|
284
|
-
#
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
#
|
293
|
-
#
|
294
|
-
#
|
295
|
-
#
|
296
|
-
#
|
297
|
-
#
|
298
|
-
#
|
299
|
-
#
|
300
|
-
#
|
301
|
-
#
|
302
|
-
#
|
303
|
-
#
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
#
|
312
|
-
#
|
313
|
-
#
|
314
|
-
#
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
#
|
323
|
-
#
|
324
|
-
#
|
325
|
-
#
|
326
|
-
#
|
327
|
-
#
|
328
|
-
#
|
329
|
-
#
|
330
|
-
#
|
331
|
-
#
|
332
|
-
#
|
333
|
-
#
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
#
|
342
|
-
#
|
343
|
-
#
|
344
|
-
#
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
#
|
353
|
-
#
|
354
|
-
#
|
355
|
-
#
|
356
|
-
#
|
357
|
-
#
|
358
|
-
#
|
359
|
-
#
|
360
|
-
#
|
361
|
-
#
|
362
|
-
#
|
363
|
-
#
|
364
|
-
#
|
365
|
-
#
|
366
|
-
#
|
367
|
-
#
|
368
|
-
#
|
369
|
-
#
|
370
|
-
#
|
371
|
-
#
|
372
|
-
#
|
373
|
-
#
|
374
|
-
#
|
375
|
-
#
|
376
|
-
#
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
#
|
385
|
-
#
|
386
|
-
#
|
387
|
-
#
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
#
|
396
|
-
#
|
397
|
-
#
|
398
|
-
#
|
399
|
-
#
|
400
|
-
#
|
401
|
-
#
|
402
|
-
#
|
403
|
-
#
|
404
|
-
#
|
405
|
-
#
|
406
|
-
#
|
407
|
-
#
|
408
|
-
#
|
409
|
-
#
|
410
|
-
#
|
411
|
-
#
|
412
|
-
#
|
413
|
-
#
|
414
|
-
#
|
415
|
-
#
|
416
|
-
#
|
417
|
-
#
|
418
|
-
#
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
#
|
427
|
-
#
|
428
|
-
#
|
429
|
-
#
|
430
|
-
#
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
#
|
439
|
-
#
|
440
|
-
#
|
441
|
-
#
|
442
|
-
#
|
443
|
-
#
|
444
|
-
#
|
445
|
-
#
|
446
|
-
#
|
447
|
-
#
|
448
|
-
#
|
449
|
-
#
|
450
|
-
#
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
#
|
459
|
-
#
|
460
|
-
#
|
461
|
-
#
|
462
|
-
#
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
#
|
471
|
-
#
|
472
|
-
#
|
473
|
-
#
|
474
|
-
#
|
475
|
-
#
|
476
|
-
#
|
477
|
-
#
|
478
|
-
#
|
479
|
-
#
|
480
|
-
#
|
481
|
-
#
|
482
|
-
#
|
483
|
-
#
|
484
|
-
|
485
|
-
#
|
486
|
-
#
|
487
|
-
|
488
|
-
#
|
489
|
-
#
|
490
|
-
#
|
491
|
-
#
|
492
|
-
#
|
493
|
-
#
|
494
|
-
#
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
#
|
504
|
-
#
|
505
|
-
#
|
506
|
-
#
|
507
|
-
#
|
508
|
-
#
|
509
|
-
#
|
510
|
-
#
|
511
|
-
#
|
512
|
-
#
|
513
|
-
#
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
#
|
522
|
-
#
|
523
|
-
#
|
524
|
-
#
|
525
|
-
#
|
526
|
-
#
|
527
|
-
#
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
#
|
536
|
-
#
|
537
|
-
#
|
538
|
-
#
|
539
|
-
#
|
540
|
-
#
|
541
|
-
#
|
542
|
-
#
|
543
|
-
#
|
544
|
-
#
|
545
|
-
#
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
#
|
554
|
-
#
|
555
|
-
#
|
556
|
-
#
|
557
|
-
#
|
558
|
-
#
|
559
|
-
#
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
#
|
568
|
-
#
|
569
|
-
#
|
570
|
-
#
|
571
|
-
#
|
572
|
-
#
|
573
|
-
#
|
574
|
-
#
|
575
|
-
#
|
576
|
-
#
|
577
|
-
#
|
578
|
-
#
|
579
|
-
#
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
#
|
588
|
-
#
|
589
|
-
#
|
590
|
-
#
|
591
|
-
#
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
#
|
607
|
-
#
|
608
|
-
#
|
609
|
-
#
|
610
|
-
#
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
#
|
619
|
-
#
|
620
|
-
#
|
621
|
-
#
|
622
|
-
#
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
#
|
631
|
-
#
|
632
|
-
#
|
633
|
-
#
|
634
|
-
#
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
#
|
643
|
-
#
|
644
|
-
#
|
645
|
-
#
|
646
|
-
#
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
#
|
655
|
-
#
|
656
|
-
#
|
657
|
-
#
|
658
|
-
#
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
#
|
667
|
-
#
|
668
|
-
#
|
669
|
-
#
|
670
|
-
#
|
671
|
-
#
|
672
|
-
#
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
#
|
681
|
-
#
|
682
|
-
#
|
683
|
-
#
|
684
|
-
#
|
685
|
-
#
|
686
|
-
#
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
#
|
696
|
-
#
|
697
|
-
#
|
698
|
-
#
|
699
|
-
#
|
700
|
-
#
|
701
|
-
#
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
#
|
710
|
-
#
|
711
|
-
#
|
712
|
-
#
|
713
|
-
#
|
714
|
-
#
|
715
|
-
#
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
#
|
724
|
-
#
|
725
|
-
#
|
726
|
-
#
|
727
|
-
#
|
728
|
-
#
|
729
|
-
#
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
#
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
#
|
746
|
-
#
|
747
|
-
#
|
748
|
-
#
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
# This method
|
780
|
-
#
|
781
|
-
#
|
782
|
-
#
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
end
|
806
|
-
|
807
|
-
#
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
1
|
+
module Watir
|
2
|
+
# This module contains the factory methods that are used to access most html objects
|
3
|
+
#
|
4
|
+
# For example, to access a button on a web page that has the following html
|
5
|
+
# <input type=button name='b1' value='Click Me' onClick='javascript:doSomething()'>
|
6
|
+
#
|
7
|
+
# the following watir code could be used to click the button
|
8
|
+
#
|
9
|
+
# browser.button(:name, 'b1').click
|
10
|
+
#
|
11
|
+
# or to find the name attribute
|
12
|
+
#
|
13
|
+
# browser.button(:value, 'Click Me').name
|
14
|
+
#
|
15
|
+
# there are many methods available to the Button object
|
16
|
+
#--
|
17
|
+
# Is includable for classes that have @container, document and ole_inner_elements
|
18
|
+
module Container
|
19
|
+
include Watir::Exception
|
20
|
+
|
21
|
+
# Note: @container is the container of this object, i.e. the container
|
22
|
+
# of this container.
|
23
|
+
# In other words, for browser.table().this_thing().text_field().set,
|
24
|
+
# container of this_thing is the table.
|
25
|
+
|
26
|
+
# This is used to change the typing speed when entering text on a page.
|
27
|
+
attr_accessor :typingspeed
|
28
|
+
attr_accessor :type_keys
|
29
|
+
# The color we want to use for the active object. This can be any valid web-friendly color.
|
30
|
+
attr_accessor :activeObjectHighLightColor
|
31
|
+
# The PageContainer object containing this element
|
32
|
+
attr_accessor :page_container
|
33
|
+
|
34
|
+
def copy_test_config(container) # only used by form and frame
|
35
|
+
@typingspeed = container.typingspeed
|
36
|
+
@type_keys = container.type_keys
|
37
|
+
@activeObjectHighLightColor = container.activeObjectHighLightColor
|
38
|
+
end
|
39
|
+
private :copy_test_config
|
40
|
+
|
41
|
+
# Write the specified string to the log.
|
42
|
+
def log(what)
|
43
|
+
@container.logger.debug(what) if @logger
|
44
|
+
end
|
45
|
+
|
46
|
+
# Wait until Browser has finished loading the page.
|
47
|
+
#--
|
48
|
+
# called explicitly by most click and set methods
|
49
|
+
def wait(no_sleep=false)
|
50
|
+
@container.wait(no_sleep)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Determine the how and what when defaults are possible.
|
54
|
+
def process_default(default_attribute, how, what)
|
55
|
+
if what.nil? && String === how
|
56
|
+
what = how
|
57
|
+
how = default_attribute
|
58
|
+
end
|
59
|
+
return how, what
|
60
|
+
end
|
61
|
+
private :process_default
|
62
|
+
|
63
|
+
def set_container container #:nodoc:
|
64
|
+
@container = container
|
65
|
+
@page_container = container.page_container
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
def self.def_creator(method_name, klass_name=nil)
|
70
|
+
klass_name ||= method_name.to_s.capitalize
|
71
|
+
class_eval "def #{method_name}(how, what=nil)
|
72
|
+
#{klass_name}.new(self, how, what)
|
73
|
+
end"
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.def_creator_with_default(method_name, default_symbol)
|
77
|
+
klass_name = method_name.to_s.capitalize
|
78
|
+
class_eval "def #{method_name}(how, what=nil)
|
79
|
+
how, what = process_default :#{default_symbol}, how, what
|
80
|
+
#{klass_name}.new(self, how, what)
|
81
|
+
end"
|
82
|
+
end
|
83
|
+
|
84
|
+
#--
|
85
|
+
# Factory Methods
|
86
|
+
#++
|
87
|
+
public
|
88
|
+
|
89
|
+
# this method is the main way of accessing a frame
|
90
|
+
# * how - how the frame is accessed. This can also just be the name of the frame.
|
91
|
+
# * what - what we want to access.
|
92
|
+
#
|
93
|
+
# Valid values for 'how' are listed in the Watir Wiki - http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
|
94
|
+
#
|
95
|
+
# returns a Frame object
|
96
|
+
#
|
97
|
+
# Typical usage:
|
98
|
+
#
|
99
|
+
# browser.frame(:index, 1)
|
100
|
+
# browser.frame(:name, 'main_frame')
|
101
|
+
# browser.frame('main_frame') # in this case, just a name is supplied
|
102
|
+
def frame(how, what=nil)
|
103
|
+
how, what = process_default :name, how, what
|
104
|
+
Frame.new(self, how, what)
|
105
|
+
end
|
106
|
+
|
107
|
+
# this method is used to access a form.
|
108
|
+
# available ways of accessing it are, :index, :name, :id, :method, :action, :xpath
|
109
|
+
# * how - symbol - What mecahnism we use to find the form, one of
|
110
|
+
# the above. NOTE if what is not supplied this parameter is the NAME of the form
|
111
|
+
# * what - String - the text associated with the symbol
|
112
|
+
#
|
113
|
+
# Valid values for 'how' are listed in the Watir Wiki - http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
|
114
|
+
#
|
115
|
+
# returns a Form object
|
116
|
+
def form(how, what=nil)
|
117
|
+
how, what = process_default :name, how, what
|
118
|
+
Form.new(self, how, what)
|
119
|
+
end
|
120
|
+
|
121
|
+
# This method is used to get a table from the page.
|
122
|
+
# :index (1 based counting) and :id are supported.
|
123
|
+
# NOTE :name is not supported, as the table tag does not have a name attribute. It is not part of the DOM.
|
124
|
+
# :index can be used when there are multiple tables on a page.
|
125
|
+
# :xpath can be used to select table using XPath query.
|
126
|
+
# The first form can be accessed with :index 1, the second :index 2, etc.
|
127
|
+
# * how - symbol - how we access the table, :index, :id, :xpath etc
|
128
|
+
# * what - string the thing we are looking for, ex. id, index or xpath query, of the object we are looking for
|
129
|
+
#
|
130
|
+
# Valid values for 'how' are listed in the Watir Wiki - http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
|
131
|
+
#
|
132
|
+
# returns a Table object
|
133
|
+
def table(how, what=nil)
|
134
|
+
Table.new(self, how, what)
|
135
|
+
end
|
136
|
+
|
137
|
+
# this is the main method for accessing the tables iterator. It returns a Tables object
|
138
|
+
#
|
139
|
+
# Typical usage:
|
140
|
+
#
|
141
|
+
# browser.tables.each { |t| puts t.to_s } # iterate through all the tables on the page
|
142
|
+
# browser.tables[1].to_s # goto the first table on the page
|
143
|
+
# browser.tables.length # show how many tables are on the page. Tables that are nested will be included in this
|
144
|
+
def tables
|
145
|
+
Tables.new(self)
|
146
|
+
end
|
147
|
+
|
148
|
+
# this method accesses a table cell.
|
149
|
+
# how - symbol - how we access the cell, valid values are
|
150
|
+
# :id - find the table cell with given id.
|
151
|
+
# :xpath - find the table cell using xpath query.
|
152
|
+
#
|
153
|
+
# returns a TableCell Object
|
154
|
+
def cell(how, what=nil)
|
155
|
+
TableCell.new(self, how, what)
|
156
|
+
end
|
157
|
+
def cells
|
158
|
+
TableCells.new(self)
|
159
|
+
end
|
160
|
+
|
161
|
+
# this method accesses a table row.
|
162
|
+
# how - symbol - how we access the row, valid values are
|
163
|
+
# :id - find the table row with given id.
|
164
|
+
# :xpath - find the table row using xpath query.
|
165
|
+
#
|
166
|
+
# returns a TableRow object
|
167
|
+
def row(how, what=nil)
|
168
|
+
TableRow.new(self, how, what)
|
169
|
+
end
|
170
|
+
def rows
|
171
|
+
TableRows.new(self)
|
172
|
+
end
|
173
|
+
|
174
|
+
# Access a modal web dialog, which is a PageContainer, like IE or Frame.
|
175
|
+
# Returns a ModalDialog object.
|
176
|
+
#
|
177
|
+
# Typical Usage
|
178
|
+
# browser.modal_dialog # access the modal dialog of ie
|
179
|
+
# browser.modal_dialog(:title, 'Title') # access the modal dialog by title
|
180
|
+
# browser.modal_dialog.modal_dialog # access a modal dialog's modal dialog XXX untested!
|
181
|
+
#
|
182
|
+
# This method will not work when
|
183
|
+
# Watir/Ruby is run under a service (instead of a user).
|
184
|
+
# Note: unlike Watir.attach, this returns before the page is assured to have
|
185
|
+
# loaded.
|
186
|
+
|
187
|
+
def modal_dialog(how=nil, what=nil)
|
188
|
+
ModalDialog.new(self, how, what)
|
189
|
+
end
|
190
|
+
|
191
|
+
# This is the main method for accessing a button. Often declared as an <tt><input type = submit></tt> tag.
|
192
|
+
# * how - symbol - how we access the button, :index, :id, :name etc
|
193
|
+
# * what - string, integer or regular expression - what we are looking for,
|
194
|
+
#
|
195
|
+
# Valid values for 'how' are listed in the Watir Wiki - http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
|
196
|
+
#
|
197
|
+
# Returns a Button object.
|
198
|
+
#
|
199
|
+
# Typical usage
|
200
|
+
#
|
201
|
+
# browser.button(:id, 'b_1') # access the button with an ID of b_1
|
202
|
+
# browser.button(:name, 'verify_data') # access the button with a name of verify_data
|
203
|
+
# browser.button(:value, 'Login') # access the button with a value (the text displayed on the button) of Login
|
204
|
+
# browser.button(:caption, 'Login') # same as above
|
205
|
+
# browser.button(:value, /Log/) # access the button that has text matching /Log/
|
206
|
+
# browser.button(:index, 2) # access the second button on the page (1 based, so the first button is accessed with :index,1)
|
207
|
+
# browser.button(:class, 'my_custom_button_class') # access the button with a class of my_custom_button_class
|
208
|
+
# browser.button(:xpath, "//input[@value='Click Me']/") # access the button with a value of Click Me
|
209
|
+
#
|
210
|
+
# Accessing a Button nested within another element
|
211
|
+
# browser.div(:class, 'xyz').button(:index, 2) # access a div of class xyz, and the 2nd button within that div
|
212
|
+
#
|
213
|
+
# If only a single parameter is supplied, then :value is used
|
214
|
+
# browser.button('Click Me') # access the button with a value of Click Me
|
215
|
+
def button(how, what=nil)
|
216
|
+
how, what = process_default :value, how, what
|
217
|
+
Button.new(self, how, what)
|
218
|
+
end
|
219
|
+
|
220
|
+
# this is the main method for accessing the buttons iterator. It returns a Buttons object
|
221
|
+
#
|
222
|
+
# Typical usage:
|
223
|
+
#
|
224
|
+
# browser.buttons.each { |b| puts b.to_s } # iterate through all the buttons on the page
|
225
|
+
# browser.buttons[1].to_s # goto the first button on the page
|
226
|
+
# browser.buttons.length # show how many buttons are on the page.
|
227
|
+
def buttons
|
228
|
+
Buttons.new(self)
|
229
|
+
end
|
230
|
+
|
231
|
+
# This is the main method for accessing a file field. Usually an <tt><input type = file></tt> HTML tag.
|
232
|
+
# * how - symbol - how we access the field, valid values are
|
233
|
+
# :index - find the file field using index
|
234
|
+
# :id - find the file field using id attribute
|
235
|
+
# :name - find the file field using name attribute
|
236
|
+
# :xpath - find the file field using xpath query
|
237
|
+
# * what - string, integer, regular expression, or xpath query - what we are looking for,
|
238
|
+
#
|
239
|
+
# returns a FileField object
|
240
|
+
#
|
241
|
+
# Typical Usage
|
242
|
+
#
|
243
|
+
# browser.file_field(:id, 'up_1') # access the file upload field with an ID of up_1
|
244
|
+
# browser.file_field(:name, 'upload') # access the file upload field with a name of upload
|
245
|
+
# browser.file_field(:index, 2) # access the second file upload on the page (1 based, so the first field is accessed with :index,1)
|
246
|
+
#
|
247
|
+
def file_field(how, what=nil)
|
248
|
+
FileField.new(self, how, what)
|
249
|
+
end
|
250
|
+
|
251
|
+
# this is the main method for accessing the file_fields iterator. It returns a FileFields object
|
252
|
+
#
|
253
|
+
# Typical usage:
|
254
|
+
#
|
255
|
+
# browser.file_fields.each { |f| puts f.to_s } # iterate through all the file fields on the page
|
256
|
+
# browser.file_fields[1].to_s # goto the first file field on the page
|
257
|
+
# browser.file_fields.length # show how many file fields are on the page.
|
258
|
+
def file_fields
|
259
|
+
FileFields.new(self)
|
260
|
+
end
|
261
|
+
|
262
|
+
# This is the main method for accessing a text field. Usually an <tt><input type=text></tt> HTML tag.
|
263
|
+
# or a text area - a <tt><textarea></tt> tag
|
264
|
+
# * how - symbol - how we access the field, :index, :id, :name etc
|
265
|
+
# * what - string, integer or regular expression - what we are looking for,
|
266
|
+
#
|
267
|
+
# Valid values for 'how' are listed in the Watir Wiki - http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
|
268
|
+
#
|
269
|
+
# returns a TextField object
|
270
|
+
#
|
271
|
+
# Typical Usage
|
272
|
+
#
|
273
|
+
# browser.text_field(:id, 'user_name') # access the text field with an ID of user_name
|
274
|
+
# browser.text_field(:name, 'address') # access the text field with a name of address
|
275
|
+
# browser.text_field(:index, 2) # access the second text field on the page (1 based, so the first field is accessed with :index,1)
|
276
|
+
# browser.text_field(:xpath, "//textarea[@id='user_name']/") # access the text field with an ID of user_name
|
277
|
+
def text_field(how, what=nil)
|
278
|
+
TextField.new(self, how, what)
|
279
|
+
end
|
280
|
+
|
281
|
+
# this is the method for accessing the text_fields iterator. It returns a Text_Fields object
|
282
|
+
#
|
283
|
+
# Typical usage:
|
284
|
+
#
|
285
|
+
# browser.text_fields.each { |t| puts t.to_s } # iterate through all the text fields on the page
|
286
|
+
# browser.text_fields[1].to_s # goto the first text field on the page
|
287
|
+
# browser.text_fields.length # show how many text field are on the page.
|
288
|
+
def text_fields
|
289
|
+
TextFields.new(self)
|
290
|
+
end
|
291
|
+
|
292
|
+
# This is the main method for accessing a hidden field. Usually an <tt><input type = hidden></tt> HTML tag
|
293
|
+
#
|
294
|
+
# * how - symbol - how we access the hidden field, :index, :id, :name etc
|
295
|
+
# * what - string, integer or regular expression - what we are looking for,
|
296
|
+
#
|
297
|
+
# Valid values for 'how' are listed in the Watir Wiki - http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
|
298
|
+
#
|
299
|
+
# returns a Hidden object
|
300
|
+
#
|
301
|
+
# Typical usage
|
302
|
+
#
|
303
|
+
# browser.hidden(:id, 'session_id') # access the hidden field with an ID of session_id
|
304
|
+
# browser.hidden(:name, 'temp_value') # access the hidden field with a name of temp_value
|
305
|
+
# browser.hidden(:index, 2) # access the second hidden field on the page (1 based, so the first field is accessed with :index,1)
|
306
|
+
# browser.hidden(:xpath, "//input[@type='hidden' and @id='session_value']/") # access the hidden field with an ID of session_id
|
307
|
+
def hidden(how, what=nil)
|
308
|
+
Hidden.new(self, how, what)
|
309
|
+
end
|
310
|
+
|
311
|
+
# this is the method for accessing the hiddens iterator. It returns a Hiddens object
|
312
|
+
#
|
313
|
+
# Typical usage:
|
314
|
+
#
|
315
|
+
# browser.hiddens.each { |t| puts t.to_s } # iterate through all the hidden fields on the page
|
316
|
+
# browser.hiddens[1].to_s # goto the first hidden field on the page
|
317
|
+
# browser.hiddens.length # show how many hidden fields are on the page.
|
318
|
+
def hiddens
|
319
|
+
Hiddens.new(self)
|
320
|
+
end
|
321
|
+
|
322
|
+
# This is the main method for accessing a selection list. Usually a <tt><select></tt> HTML tag.
|
323
|
+
# * how - symbol - how we access the selection list, :index, :id, :name etc
|
324
|
+
# * what - string, integer or regular expression - what we are looking for,
|
325
|
+
#
|
326
|
+
# Valid values for 'how' are listed in the Watir Wiki - http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
|
327
|
+
#
|
328
|
+
# returns a SelectList object
|
329
|
+
#
|
330
|
+
# Typical usage
|
331
|
+
#
|
332
|
+
# browser.select_list(:id, 'currency') # access the select box with an id of currency
|
333
|
+
# browser.select_list(:name, 'country') # access the select box with a name of country
|
334
|
+
# browser.select_list(:name, /n_/) # access the first select box whose name matches n_
|
335
|
+
# browser.select_list(:index, 2) # access the second select box on the page (1 based, so the first field is accessed with :index,1)
|
336
|
+
# browser.select(:xpath, "//select[@id='currency']/") # access the select box with an id of currency
|
337
|
+
def select_list(how, what=nil)
|
338
|
+
SelectList.new(self, how, what)
|
339
|
+
end
|
340
|
+
|
341
|
+
# this is the method for accessing the select lists iterator. Returns a SelectLists object
|
342
|
+
#
|
343
|
+
# Typical usage:
|
344
|
+
#
|
345
|
+
# browser.select_lists.each { |s| puts s.to_s } # iterate through all the select boxes on the page
|
346
|
+
# browser.select_lists[1].to_s # goto the first select boxes on the page
|
347
|
+
# browser.select_lists.length # show how many select boxes are on the page.
|
348
|
+
def select_lists
|
349
|
+
SelectLists.new(self)
|
350
|
+
end
|
351
|
+
|
352
|
+
# This is the main method for accessing a check box. Usually an <tt><input type = checkbox></tt> HTML tag.
|
353
|
+
#
|
354
|
+
# * how - symbol - how we access the check box - :index, :id, :name etc
|
355
|
+
# * what - string, integer or regular expression - what we are looking for,
|
356
|
+
# * value - string - when there are multiple objects with different value attributes, this can be used to find the correct object
|
357
|
+
#
|
358
|
+
# Valid values for 'how' are listed in the Watir Wiki - http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
|
359
|
+
#
|
360
|
+
# returns a CheckBox object
|
361
|
+
#
|
362
|
+
# Typical usage
|
363
|
+
#
|
364
|
+
# browser.checkbox(:id, 'send_email') # access the check box with an id of send_mail
|
365
|
+
# browser.checkbox(:name, 'send_copy') # access the check box with a name of send_copy
|
366
|
+
# browser.checkbox(:name, /n_/) # access the first check box whose name matches n_
|
367
|
+
# browser.checkbox(:index, 2) # access the second check box on the page (1 based, so the first field is accessed with :index,1)
|
368
|
+
#
|
369
|
+
# In many instances, checkboxes on an html page have the same name, but are identified by different values. An example is shown next.
|
370
|
+
#
|
371
|
+
# <input type = checkbox name = email_frequency value = 'daily' > Daily Email
|
372
|
+
# <input type = checkbox name = email_frequency value = 'Weekly'> Weekly Email
|
373
|
+
# <input type = checkbox name = email_frequency value = 'monthly'>Monthly Email
|
374
|
+
#
|
375
|
+
# Watir can access these using the following:
|
376
|
+
#
|
377
|
+
# browser.checkbox(:id, 'day_to_send', 'monday') # access the check box with an id of day_to_send and a value of monday
|
378
|
+
# browser.checkbox(:name,'email_frequency', 'weekly') # access the check box with a name of email_frequency and a value of 'weekly'
|
379
|
+
# browser.checkbox(:xpath, "//input[@name='email_frequency' and @value='daily']/") # access the checkbox with a name of email_frequency and a value of 'daily'
|
380
|
+
def checkbox(how, what=nil, value=nil) # should be "check_box" ?
|
381
|
+
CheckBox.new(self, how, what, value)
|
382
|
+
end
|
383
|
+
|
384
|
+
# this is the method for accessing the check boxes iterator. Returns a CheckBoxes object
|
385
|
+
#
|
386
|
+
# Typical usage:
|
387
|
+
#
|
388
|
+
# browser.checkboxes.each { |c| puts c.to_s } # iterate through all the check boxes on the page
|
389
|
+
# browser.checkboxes[1].to_s # goto the first check box on the page
|
390
|
+
# browser.checkboxes.length # show how many check boxes are on the page.
|
391
|
+
def checkboxes
|
392
|
+
CheckBoxes.new(self)
|
393
|
+
end
|
394
|
+
|
395
|
+
# This is the main method for accessing a radio button. Usually an <tt><input type = radio></tt> HTML tag.
|
396
|
+
# * how - symbol - how we access the radio button, :index, :id, :name etc
|
397
|
+
# * what - string, integer or regular expression - what we are looking for,
|
398
|
+
# * value - string - when there are multiple objects with different value attributes, this can be used to find the correct object
|
399
|
+
#
|
400
|
+
# Valid values for 'how' are listed in the Watir Wiki - http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
|
401
|
+
#
|
402
|
+
# returns a Radio object
|
403
|
+
#
|
404
|
+
# Typical usage
|
405
|
+
#
|
406
|
+
# browser.radio(:id, 'send_email') # access the radio button with an id of currency
|
407
|
+
# browser.radio(:name, 'send_copy') # access the radio button with a name of country
|
408
|
+
# browser.radio(:name, /n_/) # access the first radio button whose name matches n_
|
409
|
+
# browser.radio(:index, 2) # access the second radio button on the page (1 based, so the first field is accessed with :index,1)
|
410
|
+
#
|
411
|
+
# In many instances, radio buttons on an html page have the same name, but are identified by different values. An example is shown next.
|
412
|
+
#
|
413
|
+
# <input type="radio" name="email_frequency" value="daily">Daily Email</input>
|
414
|
+
# <input type="radio" name="email_frequency" value="weekly">Weekly Email</input>
|
415
|
+
# <input type="radio" name="email_frequency" value="monthly">Monthly Email</input>
|
416
|
+
#
|
417
|
+
# Watir can access these using the following:
|
418
|
+
#
|
419
|
+
# browser.radio(:id, 'day_to_send', 'monday') # access the radio button with an id of day_to_send and a value of monday
|
420
|
+
# browser.radio(:name,'email_frequency', 'weekly') # access the radio button with a name of email_frequency and a value of 'weekly'
|
421
|
+
# browser.radio(:xpath, "//input[@name='email_frequency' and @value='daily']/") # access the radio button with a name of email_frequency and a value of 'daily'
|
422
|
+
def radio(how, what=nil, value=nil)
|
423
|
+
Radio.new(self, how, what, value)
|
424
|
+
end
|
425
|
+
|
426
|
+
# This is the method for accessing the radio buttons iterator. Returns a Radios object
|
427
|
+
#
|
428
|
+
# Typical usage:
|
429
|
+
#
|
430
|
+
# browser.radios.each { |r| puts r.to_s } # iterate through all the radio buttons on the page
|
431
|
+
# browser.radios[1].to_s # goto the first radio button on the page
|
432
|
+
# browser.radios.length # show how many radio buttons are on the page.
|
433
|
+
#
|
434
|
+
def radios
|
435
|
+
Radios.new(self)
|
436
|
+
end
|
437
|
+
|
438
|
+
# This is the main method for accessing a link.
|
439
|
+
# * how - symbol - how we access the link, :index, :id, :name, :title, :text, :url
|
440
|
+
# * what - string, integer or regular expression - what we are looking for,
|
441
|
+
#
|
442
|
+
# Valid values for 'how' are listed in the Watir Wiki - http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
|
443
|
+
#
|
444
|
+
# returns a Link object
|
445
|
+
#
|
446
|
+
# Typical Usage
|
447
|
+
#
|
448
|
+
# browser.link(:url, /login/) # access the first link whose url matches login. We can use a string in place of the regular expression
|
449
|
+
# # but the complete path must be used, browser.link(:url, 'http://myserver.com/my_path/login.asp')
|
450
|
+
# browser.link(:index,2) # access the second link on the page
|
451
|
+
# browser.link(:title, "Picture") # access a link using the tool tip
|
452
|
+
# browser.link(:text, 'Click Me') # access the link that has Click Me as its text
|
453
|
+
# browser.link(:xpath, "//a[contains(.,'Click Me')]/") # access the link with Click Me as its text
|
454
|
+
def link(how, what=nil)
|
455
|
+
Link.new(self, how, what)
|
456
|
+
end
|
457
|
+
|
458
|
+
# This is the main method for accessing the links collection. Returns a Links object
|
459
|
+
#
|
460
|
+
# Typical usage:
|
461
|
+
#
|
462
|
+
# browser.links.each { |l| puts l.to_s } # iterate through all the links on the page
|
463
|
+
# browser.links[1].to_s # goto the first link on the page
|
464
|
+
# browser.links.length # show how many links are on the page.
|
465
|
+
#
|
466
|
+
def links
|
467
|
+
Links.new(self)
|
468
|
+
end
|
469
|
+
|
470
|
+
# This is the main method for accessing li tags - http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/map.asp?frame=true
|
471
|
+
# * how - symbol - how we access the li,
|
472
|
+
# * what - string, integer or regular expression - what we are looking for,
|
473
|
+
#
|
474
|
+
# Valid values for 'how' are listed in the Watir Wiki - http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
|
475
|
+
#
|
476
|
+
# returns a li object
|
477
|
+
#
|
478
|
+
# Typical Usage
|
479
|
+
#
|
480
|
+
# browser.li(:id, /list/) # access the first li that matches list.
|
481
|
+
# browser.li(:index,2) # access the second li on the page
|
482
|
+
# browser.li(:title, "A Picture") # access a li using the tooltip text. See http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/title_1.asp?frame=true
|
483
|
+
#
|
484
|
+
# def li(how, what=nil)
|
485
|
+
# return Li.new(self, how, what)
|
486
|
+
# end
|
487
|
+
|
488
|
+
# this is the main method for accessing the lis iterator.
|
489
|
+
#
|
490
|
+
# Returns a lis object
|
491
|
+
#
|
492
|
+
# Typical usage:
|
493
|
+
#
|
494
|
+
# browser.lis.each { |s| puts s.to_s } # iterate through all the lis on the page
|
495
|
+
# browser.lis[1].to_s # goto the first li on the page
|
496
|
+
# browser.lis.length # show how many lis are on the page.
|
497
|
+
#
|
498
|
+
def lis
|
499
|
+
return Lis.new(self)
|
500
|
+
end
|
501
|
+
|
502
|
+
|
503
|
+
# This is the main method for accessing map tags - http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/map.asp?frame=true
|
504
|
+
# * how - symbol - how we access the map,
|
505
|
+
# * what - string, integer or regular expression - what we are looking for,
|
506
|
+
#
|
507
|
+
# Valid values for 'how' are listed in the Watir Wiki - http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
|
508
|
+
#
|
509
|
+
# returns a map object
|
510
|
+
#
|
511
|
+
# Typical Usage
|
512
|
+
#
|
513
|
+
# browser.map(:id, /list/) # access the first map that matches list.
|
514
|
+
# browser.map(:index,2) # access the second map on the page
|
515
|
+
# browser.map(:title, "A Picture") # access a map using the tooltip text. See http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/title_1.asp?frame=true
|
516
|
+
#
|
517
|
+
def map(how, what=nil)
|
518
|
+
return Map.new(self, how, what)
|
519
|
+
end
|
520
|
+
|
521
|
+
# this is the main method for accessing the maps iterator.
|
522
|
+
#
|
523
|
+
# Returns a maps object
|
524
|
+
#
|
525
|
+
# Typical usage:
|
526
|
+
#
|
527
|
+
# browser.maps.each { |s| puts s.to_s } # iterate through all the maps on the page
|
528
|
+
# browser.maps[1].to_s # goto the first map on the page
|
529
|
+
# browser.maps.length # show how many maps are on the page.
|
530
|
+
#
|
531
|
+
def maps
|
532
|
+
return Maps.new(self)
|
533
|
+
end
|
534
|
+
|
535
|
+
# This is the main method for accessing area tags - http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/area.asp?frame=true
|
536
|
+
# * how - symbol - how we access the area
|
537
|
+
# * what - string, integer or regular expression - what we are looking for,
|
538
|
+
#
|
539
|
+
# Valid values for 'how' are listed in the Watir Wiki - http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
|
540
|
+
#
|
541
|
+
# returns a area object
|
542
|
+
#
|
543
|
+
# Typical Usage
|
544
|
+
#
|
545
|
+
# browser.area(:id, /list/) # access the first area that matches list.
|
546
|
+
# browser.area(:index,2) # access the second area on the page
|
547
|
+
# browser.area(:title, "A Picture") # access a area using the tooltip text. See http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/title_1.asp?frame=true
|
548
|
+
#
|
549
|
+
def area(how, what=nil)
|
550
|
+
return Area.new(self, how, what)
|
551
|
+
end
|
552
|
+
|
553
|
+
# this is the main method for accessing the areas iterator.
|
554
|
+
#
|
555
|
+
# Returns a areas object
|
556
|
+
#
|
557
|
+
# Typical usage:
|
558
|
+
#
|
559
|
+
# browser.areas.each { |s| puts s.to_s } # iterate through all the areas on the page
|
560
|
+
# browser.areas[1].to_s # goto the first area on the page
|
561
|
+
# browser.areas.length # show how many areas are on the page.
|
562
|
+
#
|
563
|
+
def areas
|
564
|
+
return Areas.new(self)
|
565
|
+
end
|
566
|
+
|
567
|
+
# This is the main method for accessing images - normally an <tt><img src="image.gif"></tt> HTML tag.
|
568
|
+
# * how - symbol - how we access the image, :index, :id, :name, :src, :title or :alt are supported
|
569
|
+
# * what - string, integer or regular expression - what we are looking for,
|
570
|
+
#
|
571
|
+
# Valid values for 'how' are listed in the Watir Wiki - http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
|
572
|
+
#
|
573
|
+
# returns an Image object
|
574
|
+
#
|
575
|
+
# Typical Usage
|
576
|
+
#
|
577
|
+
# browser.image(:src, /myPic/) # access the first image that matches myPic. We can use a string in place of the regular expression
|
578
|
+
# # but the complete path must be used, browser.image(:src, 'http://myserver.com/my_path/my_image.jpg')
|
579
|
+
# browser.image(:index,2) # access the second image on the page
|
580
|
+
# browser.image(:alt, "A Picture") # access an image using the alt text
|
581
|
+
# browser.image(:xpath, "//img[@alt='A Picture']/") # access an image using the alt text
|
582
|
+
#
|
583
|
+
def image(how, what=nil)
|
584
|
+
Image.new(self, how, what)
|
585
|
+
end
|
586
|
+
|
587
|
+
# This is the main method for accessing the images collection. Returns an Images object
|
588
|
+
#
|
589
|
+
# Typical usage:
|
590
|
+
#
|
591
|
+
# browser.images.each { |i| puts i.to_s } # iterate through all the images on the page
|
592
|
+
# browser.images[1].to_s # goto the first image on the page
|
593
|
+
# browser.images.length # show how many images are on the page.
|
594
|
+
#
|
595
|
+
def images
|
596
|
+
Images.new(self)
|
597
|
+
end
|
598
|
+
|
599
|
+
# This is the main method for accessing JavaScript popups.
|
600
|
+
# returns a PopUp object
|
601
|
+
def popup # BUG this should not be on the container object!
|
602
|
+
PopUp.new(self)
|
603
|
+
end
|
604
|
+
|
605
|
+
|
606
|
+
# this is the main method for accessing the divs iterator. Returns a Divs collection
|
607
|
+
#
|
608
|
+
# Typical usage:
|
609
|
+
#
|
610
|
+
# browser.divs.each { |d| puts d.to_s } # iterate through all the divs on the page
|
611
|
+
# browser.divs[1].to_s # goto the first div on the page
|
612
|
+
# browser.divs.length # show how many divs are on the page.
|
613
|
+
#
|
614
|
+
def divs
|
615
|
+
Divs.new(self)
|
616
|
+
end
|
617
|
+
|
618
|
+
# this is the main method for accessing the dls iterator. Returns a Dls collection
|
619
|
+
#
|
620
|
+
# Typical usage:
|
621
|
+
#
|
622
|
+
# browser.dls.each { |d| puts d.to_s } # iterate through all the dls on the page
|
623
|
+
# browser.dls[1].to_s # goto the first dl on the page
|
624
|
+
# browser.dls.length # show how many dls are on the page.
|
625
|
+
#
|
626
|
+
def dls
|
627
|
+
Dls.new(self)
|
628
|
+
end
|
629
|
+
|
630
|
+
# this is the main method for accessing the dds iterator. Returns a Dds collection
|
631
|
+
#
|
632
|
+
# Typical usage:
|
633
|
+
#
|
634
|
+
# browser.dds.each { |d| puts d.to_s } # iterate through all the dds on the page
|
635
|
+
# browser.dds[1].to_s # goto the first dd on the page
|
636
|
+
# browser.dds.length # show how many dds are on the page.
|
637
|
+
#
|
638
|
+
def dds
|
639
|
+
Dds.new(self)
|
640
|
+
end
|
641
|
+
|
642
|
+
# this is the main method for accessing the dts iterator. Returns a Dts collection
|
643
|
+
#
|
644
|
+
# Typical usage:
|
645
|
+
#
|
646
|
+
# browser.dts.each { |d| puts d.to_s } # iterate through all the dts on the page
|
647
|
+
# browser.dts[1].to_s # goto the first dt on the page
|
648
|
+
# browser.dts.length # show how many dts are on the page.
|
649
|
+
#
|
650
|
+
def dts
|
651
|
+
Dts.new(self)
|
652
|
+
end
|
653
|
+
|
654
|
+
# this is the main method for accessing the ems iterator. Returns a Ems collection
|
655
|
+
#
|
656
|
+
# Typical usage:
|
657
|
+
#
|
658
|
+
# browser.ems.each { |d| puts d.to_s } # iterate through all the ems on the page
|
659
|
+
# browser.ems[1].to_s # goto the first em on the page
|
660
|
+
# browser.ems.length # show how many ems are on the page.
|
661
|
+
#
|
662
|
+
def ems
|
663
|
+
Ems.new(self)
|
664
|
+
end
|
665
|
+
|
666
|
+
# this is the main method for accessing the spans iterator.
|
667
|
+
#
|
668
|
+
# Returns a Spans object
|
669
|
+
#
|
670
|
+
# Typical usage:
|
671
|
+
#
|
672
|
+
# browser.spans.each { |s| puts s.to_s } # iterate through all the spans on the page
|
673
|
+
# browser.spans[1].to_s # goto the first span on the page
|
674
|
+
# browser.spans.length # show how many spans are on the page.
|
675
|
+
#
|
676
|
+
def spans
|
677
|
+
Spans.new(self)
|
678
|
+
end
|
679
|
+
|
680
|
+
# this is the main method for accessing the Strongs iterator.
|
681
|
+
#
|
682
|
+
# Returns a Strongs object
|
683
|
+
#
|
684
|
+
# Typical usage:
|
685
|
+
#
|
686
|
+
# browser.strongs.each { |s| puts s.to_s } # iterate through all the strongs on the page
|
687
|
+
# browser.strongs[1].to_s # goto the first strong on the page
|
688
|
+
# browser.strongs.length # show how many strongs are on the page.
|
689
|
+
#
|
690
|
+
def strongs
|
691
|
+
return Strongs.new(self)
|
692
|
+
end
|
693
|
+
|
694
|
+
|
695
|
+
# this is the main method for accessing the ps iterator.
|
696
|
+
#
|
697
|
+
# Returns a Ps object
|
698
|
+
#
|
699
|
+
# Typical usage:
|
700
|
+
#
|
701
|
+
# browser.ps.each { |p| puts p.to_s } # iterate through all the p tags on the page
|
702
|
+
# browser.ps[1].to_s # goto the first p tag on the page
|
703
|
+
# browser.ps.length # show how many p tags are on the page.
|
704
|
+
#
|
705
|
+
def ps
|
706
|
+
Ps.new(self)
|
707
|
+
end
|
708
|
+
|
709
|
+
# this is the main method for accessing the ps iterator.
|
710
|
+
#
|
711
|
+
# Returns a Pres object
|
712
|
+
#
|
713
|
+
# Typical usage:
|
714
|
+
#
|
715
|
+
# browser.pres.each { |pre| puts pre.to_s } # iterate through all the pre tags on the page
|
716
|
+
# browser.pres[1].to_s # goto the first pre tag on the page
|
717
|
+
# browser.pres.length # show how many pre tags are on the page.
|
718
|
+
#
|
719
|
+
def pres
|
720
|
+
Pres.new(self)
|
721
|
+
end
|
722
|
+
|
723
|
+
# this is the main method for accessing the labels iterator. It returns a Labels object
|
724
|
+
#
|
725
|
+
# Returns a Labels object
|
726
|
+
#
|
727
|
+
# Typical usage:
|
728
|
+
#
|
729
|
+
# browser.labels.each { |l| puts l.to_s } # iterate through all the labels on the page
|
730
|
+
# browser.labels[1].to_s # goto the first label on the page
|
731
|
+
# browser.labels.length # show how many labels are on the page.
|
732
|
+
#
|
733
|
+
def labels
|
734
|
+
Labels.new(self)
|
735
|
+
end
|
736
|
+
|
737
|
+
|
738
|
+
# This is the main method for accessing a generic element with a given attibute
|
739
|
+
# * how - symbol - how we access the element. Supports all values except :index and :xpath
|
740
|
+
# * what - string, integer or regular expression - what we are looking for,
|
741
|
+
#
|
742
|
+
# Valid values for 'how' are listed in the Watir Wiki - http://wiki.openqa.org/display/WTR/Methods+supported+by+Element
|
743
|
+
#
|
744
|
+
# returns an Watir::Element object
|
745
|
+
#
|
746
|
+
# Typical Usage
|
747
|
+
#
|
748
|
+
# ie.element(:class, /foo/) # access the first element with class 'foo'. We can use a string in place of the regular expression
|
749
|
+
# ie.element(:id, "11") # access the first element that matches an id
|
750
|
+
def element(how, what)
|
751
|
+
return HTMLElement.new(self, how, what)
|
752
|
+
end
|
753
|
+
|
754
|
+
# this is the main method for accessing generic html elements by an attribute
|
755
|
+
#
|
756
|
+
# Returns a HTMLElements object
|
757
|
+
#
|
758
|
+
# Typical usage:
|
759
|
+
#
|
760
|
+
# ie.elements(:class, 'test').each { |l| puts l.to_s } # iterate through all elements of a given attribute
|
761
|
+
# ie.elements(:alt, 'foo')[1].to_s # get the first element of a given attribute
|
762
|
+
# ie.elements(:id, 'foo').length # show how many elements are foung in the collection
|
763
|
+
#
|
764
|
+
def elements(how, what)
|
765
|
+
return HTMLElements.new(self, how, what)
|
766
|
+
end
|
767
|
+
|
768
|
+
#--
|
769
|
+
#
|
770
|
+
# Searching for Page Elements
|
771
|
+
# Not for external consumption
|
772
|
+
#
|
773
|
+
#++
|
774
|
+
def ole_inner_elements
|
775
|
+
return document.body.all
|
776
|
+
end
|
777
|
+
private :ole_inner_elements
|
778
|
+
|
779
|
+
# This method shows the available objects on the current page.
|
780
|
+
# This is usually only used for debugging or writing new test scripts.
|
781
|
+
# This is a nice feature to help find out what HTML objects are on a page
|
782
|
+
# when developing a test case using Watir.
|
783
|
+
def show_all_objects
|
784
|
+
puts "-----------Objects in page -------------"
|
785
|
+
doc = document
|
786
|
+
s = ""
|
787
|
+
props = ["name", "id", "value", "alt", "src"]
|
788
|
+
doc.all.each do |n|
|
789
|
+
begin
|
790
|
+
s += n.invoke("type").to_s.ljust(16)
|
791
|
+
rescue
|
792
|
+
next
|
793
|
+
end
|
794
|
+
props.each do |prop|
|
795
|
+
begin
|
796
|
+
p = n.invoke(prop)
|
797
|
+
s += " " + "#{prop}=#{p}".to_s.ljust(18)
|
798
|
+
rescue
|
799
|
+
# this object probably doesnt have this property
|
800
|
+
end
|
801
|
+
end
|
802
|
+
s += "\n"
|
803
|
+
end
|
804
|
+
puts s
|
805
|
+
end
|
806
|
+
|
807
|
+
#
|
808
|
+
# Locator Methods
|
809
|
+
#
|
810
|
+
|
811
|
+
# Returns the specified ole object for input elements on a web page.
|
812
|
+
#
|
813
|
+
# This method is used internally by Watir and should not be used externally. It cannot be marked as private because of the way mixins and inheritance work in watir
|
814
|
+
#
|
815
|
+
# * how - symbol - the way we look for the object. Supported values are
|
816
|
+
# - :name
|
817
|
+
# - :id
|
818
|
+
# - :index
|
819
|
+
# - :value etc
|
820
|
+
# * what - string that we are looking for, ex. the name, or id tag attribute or index of the object we are looking for.
|
821
|
+
# * types - what object types we will look at.
|
822
|
+
# * value - used for objects that have one name, but many values. ex. radio lists and checkboxes
|
823
|
+
def locate_input_element(how, what, types, value=nil)
|
824
|
+
case how
|
825
|
+
when :xpath
|
826
|
+
return element_by_xpath(what)
|
827
|
+
when :ole_object
|
828
|
+
return what
|
829
|
+
end
|
830
|
+
# else:
|
831
|
+
|
832
|
+
locator = InputElementLocator.new self, types
|
833
|
+
locator.specifier = [how, what, value]
|
834
|
+
locator.document = document
|
835
|
+
return locator.element if locator.fast_locate
|
836
|
+
# todo: restrict search to elements.getElementsByTag('INPUT'); faster
|
837
|
+
locator.elements = ole_inner_elements if locator.elements.nil?
|
838
|
+
locator.locate
|
839
|
+
end
|
840
|
+
|
841
|
+
# returns the ole object for the specified element
|
842
|
+
def locate_tagged_element(tag, how, what)
|
843
|
+
locator = TaggedElementLocator.new(self, tag)
|
844
|
+
locator.set_specifier(how, what)
|
845
|
+
locator.locate
|
846
|
+
end
|
847
|
+
|
848
|
+
# returns the the locator object so you can iterate
|
849
|
+
# over the elements using #each
|
850
|
+
def locate_all_elements(how, what)
|
851
|
+
locator = ElementLocator.new(self)
|
852
|
+
locator.set_specifier(how, what)
|
853
|
+
locator
|
854
|
+
end
|
855
|
+
|
856
|
+
end # module
|
857
|
+
end
|