watir 1.6.2 → 1.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +326 -188
- data/bin/watir-console +7 -8
- 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 -45
- data/lib/watir/clickJSDialog.rb +19 -19
- data/lib/watir/close_all.rb +37 -37
- data/lib/watir/collections.rb +344 -312
- data/lib/watir/container.rb +815 -753
- 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_ext.rb +18 -0
- data/lib/watir/datahandler.rb +107 -107
- data/lib/watir/dialog.rb +46 -46
- data/lib/watir/element.rb +343 -312
- data/lib/watir/element_collections.rb +97 -81
- data/lib/watir/form.rb +170 -170
- data/lib/watir/frame.rb +59 -59
- data/lib/watir/ie-class.rb +1009 -1003
- data/lib/watir/ie-process.rb +39 -39
- data/lib/watir/ie.rb +133 -132
- data/lib/watir/image.rb +130 -130
- data/lib/watir/input_elements.rb +572 -539
- data/lib/watir/irb-history.rb +30 -30
- data/lib/watir/link.rb +64 -64
- data/lib/watir/locator.rb +176 -161
- data/lib/watir/logger.rb +19 -19
- data/lib/watir/modal_dialog.rb +122 -122
- data/lib/watir/non_control_elements.rb +145 -127
- data/lib/watir/page-container.rb +107 -105
- 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 +362 -362
- data/lib/watir/utils.rb +19 -19
- data/lib/watir/version.rb +5 -5
- data/lib/watir/watir_simple.rb +475 -475
- data/lib/watir/win32.rb +35 -28
- data/lib/watir/win32ole.rb +14 -6
- data/lib/watir/winClicker.rb +496 -479
- data/unittests/all_tests.rb +10 -10
- data/unittests/buttons_xpath_test.rb +69 -69
- data/unittests/checkbox_test.rb +179 -176
- data/unittests/checkbox_xpath_test.rb +107 -107
- data/unittests/core_tests.rb +17 -16
- data/unittests/css_test.rb +35 -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 -183
- data/unittests/div_xpath_test.rb +96 -96
- data/unittests/errorchecker_test.rb +22 -22
- data/unittests/filefield_test.rb +39 -40
- data/unittests/filefield_xpath_test.rb +33 -33
- data/unittests/form_test.rb +280 -293
- data/unittests/form_xpath_test.rb +252 -253
- data/unittests/frame_test.rb +155 -157
- 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/complex_table.html +36 -36
- data/unittests/html/cssTest.html +42 -42
- data/unittests/html/depot_store.html +51 -51
- 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 +107 -107
- 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 -55
- 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/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 -50
- 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 -177
- data/unittests/links_xpath_test.rb +39 -39
- 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/{windows → other}/jscriptExtraAlert.rb +6 -6
- data/unittests/{windows → other}/jscriptExtraConfirmCancel.rb +6 -6
- data/unittests/{windows → other}/jscriptExtraConfirmOk.rb +6 -6
- data/unittests/{windows → other}/jscriptPushButton.rb +6 -6
- data/unittests/{windows → other}/jscript_test.rb +63 -63
- data/unittests/other/navigate_exception_test.rb +24 -24
- data/unittests/other/rexml_unit_test.rb +27 -24
- 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 -139
- data/unittests/selectbox_xpath_test.rb +113 -113
- data/unittests/setup.rb +77 -75
- data/unittests/speed_settings_test.rb +67 -65
- data/unittests/table_cell_using_xpath_test.rb +35 -35
- data/unittests/table_test.rb +376 -362
- 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 -29
- data/unittests/textfields_test.rb +218 -218
- data/unittests/textfields_xpath_test.rb +111 -111
- data/unittests/window_tests.rb +10 -7
- data/unittests/windows/attach_to_existing_window_test.rb +53 -52
- data/unittests/windows/attach_to_new_window_test.rb +83 -82
- 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 +55 -55
- data/unittests/windows/modal_dialog_test.rb +128 -126
- data/unittests/windows/new_test.rb +57 -55
- data/unittests/windows/open_close_test.rb +18 -18
- data/unittests/windows/send_keys_test.rb +33 -32
- data/unittests/xpath_tests.rb +10 -10
- metadata +20 -20
- data/lib/watir/contrib/visible.rb +0 -47
- data/unittests/iostring.rb +0 -30
- data/unittests/iostring_test.rb +0 -48
data/lib/watir/dialog.rb
CHANGED
@@ -1,46 +1,46 @@
|
|
1
|
-
require 'watir/ie'
|
2
|
-
# TODO: move this file to watir/contrib
|
3
|
-
|
4
|
-
module Watir
|
5
|
-
|
6
|
-
class Dialog
|
7
|
-
WindowName = 'Windows Internet Explorer'
|
8
|
-
def button(name)
|
9
|
-
DialogButton.new(name)
|
10
|
-
end
|
11
|
-
def close
|
12
|
-
# TODO: register autoit before use
|
13
|
-
autoit = WIN32OLE.new('AutoItX3.Control')
|
14
|
-
autoit.WinClose WindowName, ""
|
15
|
-
end
|
16
|
-
def exists?
|
17
|
-
# TODO: register autoit before use
|
18
|
-
autoit = WIN32OLE.new('AutoItX3.Control')
|
19
|
-
found = autoit.WinWait(WindowName, "", 1)
|
20
|
-
return found == 1
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def dialog
|
25
|
-
Dialog.new
|
26
|
-
end
|
27
|
-
|
28
|
-
class DialogButton
|
29
|
-
def initialize(name)
|
30
|
-
@name = name
|
31
|
-
end
|
32
|
-
def click
|
33
|
-
# TODO: register autoit before use
|
34
|
-
autoit = WIN32OLE.new('AutoItX3.Control')
|
35
|
-
autoit.WinWait Dialog::WindowName, "", 1
|
36
|
-
name_pattern = Regexp.new "^#{@name}$"
|
37
|
-
unless name_pattern =~ autoit.WinGetText(Dialog::WindowName, "")
|
38
|
-
raise Watir::Exception::UnknownObjectException
|
39
|
-
end
|
40
|
-
autoit.Send "{ENTER}"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
|
1
|
+
require 'watir/ie'
|
2
|
+
# TODO: move this file to watir/contrib
|
3
|
+
|
4
|
+
module Watir
|
5
|
+
|
6
|
+
class Dialog
|
7
|
+
WindowName = 'Windows Internet Explorer'
|
8
|
+
def button(name)
|
9
|
+
DialogButton.new(name)
|
10
|
+
end
|
11
|
+
def close
|
12
|
+
# TODO: register autoit before use
|
13
|
+
autoit = WIN32OLE.new('AutoItX3.Control')
|
14
|
+
autoit.WinClose WindowName, ""
|
15
|
+
end
|
16
|
+
def exists?
|
17
|
+
# TODO: register autoit before use
|
18
|
+
autoit = WIN32OLE.new('AutoItX3.Control')
|
19
|
+
found = autoit.WinWait(WindowName, "", 1)
|
20
|
+
return found == 1
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def dialog
|
25
|
+
Dialog.new
|
26
|
+
end
|
27
|
+
|
28
|
+
class DialogButton
|
29
|
+
def initialize(name)
|
30
|
+
@name = name
|
31
|
+
end
|
32
|
+
def click
|
33
|
+
# TODO: register autoit before use
|
34
|
+
autoit = WIN32OLE.new('AutoItX3.Control')
|
35
|
+
autoit.WinWait Dialog::WindowName, "", 1
|
36
|
+
name_pattern = Regexp.new "^#{@name}$"
|
37
|
+
unless name_pattern =~ autoit.WinGetText(Dialog::WindowName, "")
|
38
|
+
raise Watir::Exception::UnknownObjectException
|
39
|
+
end
|
40
|
+
autoit.Send "{ENTER}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
|
data/lib/watir/element.rb
CHANGED
@@ -1,312 +1,343 @@
|
|
1
|
-
module Watir
|
2
|
-
# Base class for html elements.
|
3
|
-
# This is not a class that users would normally access.
|
4
|
-
class Element # Wrapper
|
5
|
-
include Watir::Exception
|
6
|
-
include Container # presumes @container is defined
|
7
|
-
attr_accessor :container
|
8
|
-
|
9
|
-
# number of spaces that separate the property from the value in the to_s method
|
10
|
-
TO_S_SIZE = 14
|
11
|
-
|
12
|
-
# ole_object - the ole object for the element being wrapped
|
13
|
-
def initialize(ole_object)
|
14
|
-
@o = ole_object
|
15
|
-
@original_color = nil
|
16
|
-
end
|
17
|
-
|
18
|
-
# Return the ole object, allowing any methods of the DOM that Watir doesn't support to be used.
|
19
|
-
def ole_object # BUG: should use an attribute reader and rename the instance variable
|
20
|
-
return @o
|
21
|
-
end
|
22
|
-
def ole_object=(o)
|
23
|
-
@o = o
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
# return
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
# return the
|
73
|
-
def_wrap_guard :
|
74
|
-
|
75
|
-
def_wrap_guard :
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
def_wrap_guard :
|
80
|
-
|
81
|
-
|
82
|
-
# return the
|
83
|
-
|
84
|
-
# return the
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
#
|
90
|
-
def_wrap :
|
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
|
-
|
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
|
-
n
|
168
|
-
n << "
|
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
|
-
|
1
|
+
module Watir
|
2
|
+
# Base class for html elements.
|
3
|
+
# This is not a class that users would normally access.
|
4
|
+
class Element # Wrapper
|
5
|
+
include Watir::Exception
|
6
|
+
include Container # presumes @container is defined
|
7
|
+
attr_accessor :container
|
8
|
+
|
9
|
+
# number of spaces that separate the property from the value in the to_s method
|
10
|
+
TO_S_SIZE = 14
|
11
|
+
|
12
|
+
# ole_object - the ole object for the element being wrapped
|
13
|
+
def initialize(ole_object)
|
14
|
+
@o = ole_object
|
15
|
+
@original_color = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
# Return the ole object, allowing any methods of the DOM that Watir doesn't support to be used.
|
19
|
+
def ole_object # BUG: should use an attribute reader and rename the instance variable
|
20
|
+
return @o
|
21
|
+
end
|
22
|
+
def ole_object=(o)
|
23
|
+
@o = o
|
24
|
+
end
|
25
|
+
|
26
|
+
def inspect
|
27
|
+
'#<%s:0x%x located=%s how=%s what=%s>' % [self.class, hash*2, !!ole_object, @how.inspect, @what.inspect]
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
def self.def_wrap(ruby_method_name, ole_method_name=nil)
|
32
|
+
ole_method_name = ruby_method_name unless ole_method_name
|
33
|
+
class_eval "def #{ruby_method_name}
|
34
|
+
assert_exists
|
35
|
+
ole_object.invoke('#{ole_method_name}')
|
36
|
+
end"
|
37
|
+
end
|
38
|
+
def self.def_wrap_guard(method_name)
|
39
|
+
class_eval "def #{method_name}
|
40
|
+
assert_exists
|
41
|
+
begin
|
42
|
+
ole_object.invoke('#{method_name}')
|
43
|
+
rescue
|
44
|
+
''
|
45
|
+
end
|
46
|
+
end"
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
public
|
52
|
+
def assert_exists
|
53
|
+
locate if respond_to?(:locate)
|
54
|
+
unless ole_object
|
55
|
+
raise UnknownObjectException.new(
|
56
|
+
Watir::Exception.message_for_unable_to_locate(@how, @what))
|
57
|
+
end
|
58
|
+
end
|
59
|
+
def assert_enabled
|
60
|
+
unless enabled?
|
61
|
+
raise ObjectDisabledException, "object #{@how} and #{@what} is disabled"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# return the name of the element (as defined in html)
|
66
|
+
def_wrap_guard :name
|
67
|
+
# return the id of the element
|
68
|
+
def_wrap_guard :id
|
69
|
+
# return whether the element is disabled
|
70
|
+
def_wrap :disabled
|
71
|
+
alias disabled? disabled
|
72
|
+
# return the value of the element
|
73
|
+
def_wrap_guard :value
|
74
|
+
# return the title of the element
|
75
|
+
def_wrap_guard :title
|
76
|
+
# return the style of the element
|
77
|
+
def_wrap_guard :style
|
78
|
+
|
79
|
+
def_wrap_guard :alt
|
80
|
+
def_wrap_guard :src
|
81
|
+
|
82
|
+
# return the type of the element
|
83
|
+
def_wrap_guard :type # input elements only
|
84
|
+
# return the url the link points to
|
85
|
+
def_wrap :href # link only
|
86
|
+
# return the ID of the control that this label is associated with
|
87
|
+
def_wrap :for, :htmlFor # label only
|
88
|
+
# return the class name of the element
|
89
|
+
# raise an ObjectNotFound exception if the object cannot be found
|
90
|
+
def_wrap :class_name, :className
|
91
|
+
# return the unique COM number for the element
|
92
|
+
def_wrap :unique_number, :uniqueNumber
|
93
|
+
# Return the outer html of the object - see http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/outerhtml.asp?frame=true
|
94
|
+
def_wrap :html, :outerHTML
|
95
|
+
|
96
|
+
# return the text before the element
|
97
|
+
def before_text # label only
|
98
|
+
assert_exists
|
99
|
+
begin
|
100
|
+
ole_object.getAdjacentText("afterEnd").strip
|
101
|
+
rescue
|
102
|
+
''
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# return the text after the element
|
107
|
+
def after_text # label only
|
108
|
+
assert_exists
|
109
|
+
begin
|
110
|
+
ole_object.getAdjacentText("beforeBegin").strip
|
111
|
+
rescue
|
112
|
+
''
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Return the innerText of the object
|
117
|
+
# Raise an ObjectNotFound exception if the object cannot be found
|
118
|
+
def text
|
119
|
+
assert_exists
|
120
|
+
return ole_object.innerText.strip
|
121
|
+
end
|
122
|
+
|
123
|
+
def ole_inner_elements
|
124
|
+
assert_exists
|
125
|
+
return ole_object.all
|
126
|
+
end
|
127
|
+
private :ole_inner_elements
|
128
|
+
|
129
|
+
def document
|
130
|
+
assert_exists
|
131
|
+
return ole_object
|
132
|
+
end
|
133
|
+
|
134
|
+
# Return the element immediately containing self.
|
135
|
+
def parent
|
136
|
+
assert_exists
|
137
|
+
result = Element.new(ole_object.parentelement)
|
138
|
+
result.set_container self
|
139
|
+
result
|
140
|
+
end
|
141
|
+
|
142
|
+
include Comparable
|
143
|
+
def <=> other
|
144
|
+
assert_exists
|
145
|
+
other.assert_exists
|
146
|
+
ole_object.sourceindex <=> other.ole_object.sourceindex
|
147
|
+
end
|
148
|
+
|
149
|
+
# Return true if self is contained earlier in the html than other.
|
150
|
+
alias :before? :<
|
151
|
+
# Return true if self is contained later in the html than other.
|
152
|
+
alias :after? :>
|
153
|
+
|
154
|
+
def typingspeed
|
155
|
+
@container.typingspeed
|
156
|
+
end
|
157
|
+
def type_keys
|
158
|
+
return @container.type_keys if @type_keys.nil?
|
159
|
+
@type_keys
|
160
|
+
end
|
161
|
+
def activeObjectHighLightColor
|
162
|
+
@container.activeObjectHighLightColor
|
163
|
+
end
|
164
|
+
|
165
|
+
# Return an array with many of the properties, in a format to be used by the to_s method
|
166
|
+
def string_creator
|
167
|
+
n = []
|
168
|
+
n << "type:".ljust(TO_S_SIZE) + self.type
|
169
|
+
n << "id:".ljust(TO_S_SIZE) + self.id.to_s
|
170
|
+
n << "name:".ljust(TO_S_SIZE) + self.name.to_s
|
171
|
+
n << "value:".ljust(TO_S_SIZE) + self.value.to_s
|
172
|
+
n << "disabled:".ljust(TO_S_SIZE) + self.disabled.to_s
|
173
|
+
return n
|
174
|
+
end
|
175
|
+
private :string_creator
|
176
|
+
|
177
|
+
# Display basic details about the object. Sample output for a button is shown.
|
178
|
+
# Raises UnknownObjectException if the object is not found.
|
179
|
+
# name b4
|
180
|
+
# type button
|
181
|
+
# id b5
|
182
|
+
# value Disabled Button
|
183
|
+
# disabled true
|
184
|
+
def to_s
|
185
|
+
assert_exists
|
186
|
+
return string_creator.join("\n")
|
187
|
+
end
|
188
|
+
|
189
|
+
# This method is responsible for setting and clearing the colored highlighting on the currently active element.
|
190
|
+
# use :set to set the highlight
|
191
|
+
# :clear to clear the highlight
|
192
|
+
# TODO: Make this two methods: set_highlight & clear_highlight
|
193
|
+
# TODO: Remove begin/rescue blocks
|
194
|
+
def highlight(set_or_clear)
|
195
|
+
if set_or_clear == :set
|
196
|
+
begin
|
197
|
+
@original_color ||= style.backgroundColor
|
198
|
+
style.backgroundColor = @container.activeObjectHighLightColor
|
199
|
+
rescue
|
200
|
+
@original_color = nil
|
201
|
+
end
|
202
|
+
else # BUG: assumes is :clear, but could actually be anything
|
203
|
+
begin
|
204
|
+
style.backgroundColor = @original_color unless @original_color == nil
|
205
|
+
rescue
|
206
|
+
# we could be here for a number of reasons...
|
207
|
+
# e.g. page may have reloaded and the reference is no longer valid
|
208
|
+
ensure
|
209
|
+
@original_color = nil
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
private :highlight
|
214
|
+
|
215
|
+
# This method clicks the active element.
|
216
|
+
# raises: UnknownObjectException if the object is not found
|
217
|
+
# ObjectDisabledException if the object is currently disabled
|
218
|
+
def click
|
219
|
+
click!
|
220
|
+
@container.wait
|
221
|
+
end
|
222
|
+
|
223
|
+
def click_no_wait
|
224
|
+
assert_enabled
|
225
|
+
|
226
|
+
highlight(:set)
|
227
|
+
object = "#{self.class}.new(self, :unique_number, #{self.unique_number})"
|
228
|
+
@page_container.eval_in_spawned_process(object + ".click!")
|
229
|
+
highlight(:clear)
|
230
|
+
end
|
231
|
+
|
232
|
+
def click!
|
233
|
+
assert_enabled
|
234
|
+
|
235
|
+
highlight(:set)
|
236
|
+
ole_object.click
|
237
|
+
highlight(:clear)
|
238
|
+
end
|
239
|
+
|
240
|
+
# Flash the element the specified number of times.
|
241
|
+
# Defaults to 10 flashes.
|
242
|
+
def flash number=10
|
243
|
+
assert_exists
|
244
|
+
number.times do
|
245
|
+
highlight(:set)
|
246
|
+
sleep 0.05
|
247
|
+
highlight(:clear)
|
248
|
+
sleep 0.05
|
249
|
+
end
|
250
|
+
nil
|
251
|
+
end
|
252
|
+
|
253
|
+
# Executes a user defined "fireEvent" for objects with JavaScript events tied to them such as DHTML menus.
|
254
|
+
# usage: allows a generic way to fire javascript events on page objects such as "onMouseOver", "onClick", etc.
|
255
|
+
# raises: UnknownObjectException if the object is not found
|
256
|
+
# ObjectDisabledException if the object is currently disabled
|
257
|
+
def fire_event(event)
|
258
|
+
assert_enabled
|
259
|
+
|
260
|
+
highlight(:set)
|
261
|
+
ole_object.fireEvent(event)
|
262
|
+
@container.wait
|
263
|
+
highlight(:clear)
|
264
|
+
end
|
265
|
+
|
266
|
+
# This method sets focus on the active element.
|
267
|
+
# raises: UnknownObjectException if the object is not found
|
268
|
+
# ObjectDisabledException if the object is currently disabled
|
269
|
+
def focus
|
270
|
+
assert_enabled
|
271
|
+
ole_object.focus
|
272
|
+
end
|
273
|
+
|
274
|
+
# Returns whether this element actually exists.
|
275
|
+
def exists?
|
276
|
+
begin
|
277
|
+
locate if defined?(locate)
|
278
|
+
rescue WIN32OLERuntimeError
|
279
|
+
@o = nil
|
280
|
+
end
|
281
|
+
@o ? true: false
|
282
|
+
end
|
283
|
+
alias :exist? :exists?
|
284
|
+
|
285
|
+
# Returns true if the element is enabled, false if it isn't.
|
286
|
+
# raises: UnknownObjectException if the object is not found
|
287
|
+
def enabled?
|
288
|
+
assert_exists
|
289
|
+
return ! disabled
|
290
|
+
end
|
291
|
+
|
292
|
+
# If any parent element isn't visible then we cannot write to the
|
293
|
+
# element. The only realiable way to determine this is to iterate
|
294
|
+
# up the DOM element tree checking every element to make sure it's
|
295
|
+
# visible.
|
296
|
+
def visible?
|
297
|
+
# Now iterate up the DOM element tree and return false if any
|
298
|
+
# parent element isn't visible or is disabled.
|
299
|
+
assert_exists
|
300
|
+
object = @o
|
301
|
+
while object
|
302
|
+
begin
|
303
|
+
if object.currentstyle.invoke('visibility') =~ /^hidden$/i
|
304
|
+
return false
|
305
|
+
end
|
306
|
+
if object.currentstyle.invoke('display') =~ /^none$/i
|
307
|
+
return false
|
308
|
+
end
|
309
|
+
if object.invoke('isDisabled')
|
310
|
+
return false
|
311
|
+
end
|
312
|
+
rescue WIN32OLERuntimeError
|
313
|
+
end
|
314
|
+
object = object.parentElement
|
315
|
+
end
|
316
|
+
true
|
317
|
+
end
|
318
|
+
|
319
|
+
# Get attribute value for any attribute of the element.
|
320
|
+
# Returns null if attribute doesn't exist.
|
321
|
+
def attribute_value(attribute_name)
|
322
|
+
assert_exists
|
323
|
+
return ole_object.getAttribute(attribute_name)
|
324
|
+
end
|
325
|
+
|
326
|
+
end
|
327
|
+
|
328
|
+
class ElementMapper # Still to be used
|
329
|
+
include Container
|
330
|
+
|
331
|
+
def initialize wrapper_class, container, how, what
|
332
|
+
@wrapper_class = wrapper_class
|
333
|
+
set_container
|
334
|
+
@how = how
|
335
|
+
@what = what
|
336
|
+
end
|
337
|
+
|
338
|
+
def method_missing method, *args
|
339
|
+
locate
|
340
|
+
@wrapper_class.new(@o).send(method, *args)
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|