awetestlib 0.1.3-x86-mingw32 → 0.1.5-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/awetestlib.windows.gemspec +1 -1
- data/bin/awetestlib +11 -4
- data/bin/awetestlib-helpers.rb +28 -1
- data/bin/awetestlib-netbeans-setup.rb +39 -0
- data/bin/awetestlib-rubymine-setup.rb +33 -0
- data/images/logo.png +0 -0
- data/lib/awetestlib/html_report.rb +171 -0
- data/lib/{regression → awetestlib}/logging.rb +10 -43
- data/lib/awetestlib/regression/browser.rb +1233 -0
- data/lib/awetestlib/regression/drag_and_drop.rb +379 -0
- data/lib/awetestlib/regression/find.rb +431 -0
- data/lib/awetestlib/regression/legacy.rb +45 -0
- data/lib/awetestlib/regression/page_data.rb +190 -0
- data/lib/awetestlib/regression/runner.rb +306 -0
- data/lib/awetestlib/regression/tables.rb +491 -0
- data/lib/awetestlib/regression/user_input.rb +1256 -0
- data/lib/awetestlib/regression/utilities.rb +895 -0
- data/lib/awetestlib/regression/validations.rb +1184 -0
- data/lib/awetestlib/regression/waits.rb +391 -0
- data/lib/awetestlib/runner.rb +16 -0
- data/lib/awetestlib.rb +4 -4
- data/lib/version.rb +2 -2
- data/setup_samples/sample_netbeans/demo.rb +86 -0
- data/setup_samples/sample_netbeans/nbproject/configs/Demo.properties +2 -0
- data/setup_samples/sample_netbeans/nbproject/private/config.properties +1 -0
- data/setup_samples/sample_netbeans/nbproject/private/configs/Demo.properties +1 -0
- data/setup_samples/sample_netbeans/nbproject/private/private.properties +2 -0
- data/setup_samples/sample_netbeans/nbproject/project.properties +5 -0
- data/setup_samples/sample_netbeans/nbproject/project.xml +13 -0
- data/setup_samples/sample_rubymine/.idea/.name +1 -0
- data/setup_samples/sample_rubymine/.idea/encodings.xml +5 -0
- data/setup_samples/sample_rubymine/.idea/misc.xml +5 -0
- data/setup_samples/sample_rubymine/.idea/modules.xml +9 -0
- data/setup_samples/sample_rubymine/.idea/sample_rubymine.iml +9 -0
- data/setup_samples/sample_rubymine/.idea/scopes/scope_settings.xml +5 -0
- data/setup_samples/sample_rubymine/.idea/vcs.xml +7 -0
- data/setup_samples/sample_rubymine/.idea/workspace.xml +213 -0
- data/setup_samples/sample_rubymine/demo.rb +86 -0
- metadata +44 -19
- data/lib/regression/browser.rb +0 -1259
- data/lib/regression/drag_and_drop.rb +0 -374
- data/lib/regression/find.rb +0 -426
- data/lib/regression/legacy.rb +0 -40
- data/lib/regression/page_data.rb +0 -185
- data/lib/regression/runner.rb +0 -278
- data/lib/regression/tables.rb +0 -486
- data/lib/regression/user_input.rb +0 -1255
- data/lib/regression/utilities.rb +0 -891
- data/lib/regression/validations.rb +0 -1179
- data/lib/regression/waits.rb +0 -387
data/lib/regression/find.rb
DELETED
@@ -1,426 +0,0 @@
|
|
1
|
-
module Find
|
2
|
-
|
3
|
-
def get_select_list(browser, how, what, desc = '')
|
4
|
-
list = browser.select_list(how, what)
|
5
|
-
if validate(browser, @myName, __LINE__)
|
6
|
-
passed_to_log("Select list #{how}='#{what}' found and returned.")
|
7
|
-
return list
|
8
|
-
end
|
9
|
-
rescue
|
10
|
-
failed_to_log("Unable to return select list #{how}='#{what}': '#{$!}' (#{__LINE__})")
|
11
|
-
end
|
12
|
-
|
13
|
-
def get_select_options(browser, how, what, dump = false)
|
14
|
-
list = browser.select_list(how, what)
|
15
|
-
dump_select_list_options(list) if dump
|
16
|
-
list.options
|
17
|
-
rescue
|
18
|
-
failed_to_log("Unable to get select options for #{how}=>#{what}. '#{$!}'")
|
19
|
-
end
|
20
|
-
|
21
|
-
def get_select_options_by_id(browser, strg, dump = false)
|
22
|
-
get_select_options(browser, :id, strg, dump)
|
23
|
-
end
|
24
|
-
|
25
|
-
def get_select_options_by_name(browser, strg, dump = false)
|
26
|
-
get_select_options(browser, :name, strg, dump)
|
27
|
-
end
|
28
|
-
|
29
|
-
def get_selected_options(browser, how, what)
|
30
|
-
begin
|
31
|
-
list = browser.select_list(how, what)
|
32
|
-
rescue => e
|
33
|
-
if not rescue_me(e, __method__, "browser.select_list(#{how}, '#{what}')", "#{browser.class}")
|
34
|
-
raise e
|
35
|
-
end
|
36
|
-
end
|
37
|
-
list.selected_options
|
38
|
-
end
|
39
|
-
|
40
|
-
def get_selected_options_by_id(browser, strg)
|
41
|
-
get_selected_options(browser, :id, strg)
|
42
|
-
end
|
43
|
-
|
44
|
-
alias get_selected_option_by_id get_selected_options_by_id
|
45
|
-
|
46
|
-
def get_selected_options_by_name(browser, strg)
|
47
|
-
get_selected_options(browser, :name, strg)
|
48
|
-
end
|
49
|
-
|
50
|
-
alias get_selected_option_by_name get_selected_options_by_name
|
51
|
-
|
52
|
-
=begin rdoc
|
53
|
-
:category: A_rdoc_test
|
54
|
-
Returns a reference to a division element. Used to assign a div element to a variable
|
55
|
-
which can then be passed to methods that require a *browser* parameter.
|
56
|
-
|
57
|
-
_Parameters_::
|
58
|
-
|
59
|
-
*browser* - a reference to the browser window or container element to be tested
|
60
|
-
|
61
|
-
*how* - the element attribute used to identify the specific element. Valid values depend on the kind of element.
|
62
|
-
Common values: :text, :id, :title, :name, :class, :href (:link only)
|
63
|
-
|
64
|
-
*what* - a string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
65
|
-
|
66
|
-
*desc* - a string containing a message or description intended to appear in the log and/or report output
|
67
|
-
|
68
|
-
_Example_
|
69
|
-
|
70
|
-
mainwindow = open_browser('www.myapp.com') # open a browser to www.google.com
|
71
|
-
click(mainwindow, :button, :id, 'an id string') # click a button that opens another browser window
|
72
|
-
popup = attach_browser(mainwindow, :url, '[url of new window]') *or*
|
73
|
-
popup = attach_browser(mainwindow, :title, '[title of new window]')
|
74
|
-
|
75
|
-
=end
|
76
|
-
|
77
|
-
def get_div(browser, how, what, desc = '', dbg = false)
|
78
|
-
msg = "Get division #{how}=>#{what}."
|
79
|
-
msg << " #{desc}" if desc.length > 0
|
80
|
-
Watir::Wait.until { browser.div(how, what).exists? }
|
81
|
-
div = browser.div(how, what)
|
82
|
-
debug_to_log(div.inspect) if dbg
|
83
|
-
if validate(browser, @myName, __LINE__)
|
84
|
-
if div
|
85
|
-
passed_to_log(msg)
|
86
|
-
return div
|
87
|
-
else
|
88
|
-
failed_to_log(msg)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
rescue
|
92
|
-
failed_to_log("Unable to '#{msg}' '#{$!}'")
|
93
|
-
end
|
94
|
-
|
95
|
-
def get_div_by_id(browser, strg, desc = '', dbg = false)
|
96
|
-
get_div(browser, :id, strg, desc, dbg)
|
97
|
-
end
|
98
|
-
|
99
|
-
=begin rdoc
|
100
|
-
:category: A_rdoc_test
|
101
|
-
Returns a reference to a division element identified by the value in its class attribute. Calls get_div()
|
102
|
-
|
103
|
-
_Parameters_::
|
104
|
-
|
105
|
-
*browser* - a reference to the browser window or container element to be tested
|
106
|
-
|
107
|
-
*strg* - a string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
108
|
-
|
109
|
-
*desc* - a string containing a message or description intended to appear in the log and/or report output
|
110
|
-
|
111
|
-
_Example_
|
112
|
-
|
113
|
-
mainwindow = open_browser('www.myapp.com') # open a browser to www.google.com
|
114
|
-
click(mainwindow, :button, :id, 'an id string') # click a button that opens another browser window
|
115
|
-
popup = attach_browser(mainwindow, :url, '[url of new window]') *or*
|
116
|
-
popup = attach_browser(mainwindow, :title, '[title of new window]')
|
117
|
-
|
118
|
-
=end
|
119
|
-
|
120
|
-
def get_div_by_class(browser, strg, desc = '', dbg = false)
|
121
|
-
get_div(browser, :class, strg, desc, dbg)
|
122
|
-
end
|
123
|
-
|
124
|
-
def get_div_by_text(browser, strg, desc = '', dbg = false)
|
125
|
-
get_div(browser, :text, strg, desc, dbg)
|
126
|
-
end
|
127
|
-
|
128
|
-
def get_form(browser, how, strg)
|
129
|
-
begin
|
130
|
-
# Watir::Wait.until( browser.form(how, strg).exists? ) # fails in wait_until
|
131
|
-
rescue => e
|
132
|
-
if not rescue_me(e, __method__, "browser.form(#{how}, '#{strg}').exists?", "#{browser.class}")
|
133
|
-
raise e
|
134
|
-
end
|
135
|
-
end
|
136
|
-
myForm = browser.form(how, strg)
|
137
|
-
if validate(browser, @myName, __LINE__)
|
138
|
-
passed_to_log("Form #{how}='#{strg}' found and returned.")
|
139
|
-
return myForm
|
140
|
-
end
|
141
|
-
rescue
|
142
|
-
failed_to_log("Unable to return form #{how}='#{strg}': '#{$!}' (#{__LINE__})")
|
143
|
-
end
|
144
|
-
|
145
|
-
def get_form_by_id(browser, strg)
|
146
|
-
get_form(browser, :id, strg)
|
147
|
-
end
|
148
|
-
|
149
|
-
def get_frame(browser, how, strg, desc = '')
|
150
|
-
# begin
|
151
|
-
# Watir::Wait.until(browser.frame(how, strg).exists?) # fails in wait_until
|
152
|
-
# rescue => e
|
153
|
-
# if not rescue_me(e, __method__, "browser.frame(#{how}, '#{strg}').exists?", "#{browser.class}")
|
154
|
-
# raise e
|
155
|
-
# end
|
156
|
-
# end
|
157
|
-
begin
|
158
|
-
frame = browser.frame(how, strg)
|
159
|
-
rescue => e
|
160
|
-
if not rescue_me(e, __method__, "browser.frame(#{how}, '#{strg}').exists?", "#{browser.class}")
|
161
|
-
raise e
|
162
|
-
end
|
163
|
-
end
|
164
|
-
if validate(browser, @myName, __LINE__)
|
165
|
-
passed_to_log("Frame #{how}='#{strg}' found and returned. #{desc}")
|
166
|
-
return frame
|
167
|
-
end
|
168
|
-
rescue
|
169
|
-
failed_to_log("Unable to return frame #{how}='#{strg}'. #{desc}: '#{$!}' (#{__LINE__})")
|
170
|
-
end
|
171
|
-
|
172
|
-
def get_frame_by_id(browser, strg, desc = '')
|
173
|
-
get_frame(browser, :id, strg, desc)
|
174
|
-
end
|
175
|
-
|
176
|
-
def get_frame_by_index(browser, index, desc = '')
|
177
|
-
get_frame(browser, :index, index, desc)
|
178
|
-
end
|
179
|
-
|
180
|
-
def get_frame_by_name(browser, strg, desc = '')
|
181
|
-
get_frame(browser, :name, strg, desc)
|
182
|
-
end
|
183
|
-
|
184
|
-
def get_span(browser, how, strg, desc = '')
|
185
|
-
begin
|
186
|
-
#TODO: use LegacyExtensions#wait_until
|
187
|
-
Watir::Wait.until { browser.span(how, strg).exists? }
|
188
|
-
rescue => e
|
189
|
-
if not rescue_me(e, __method__, "browser.span(#{how}, '#{strg}').exists?", "#{browser.class}")
|
190
|
-
raise e
|
191
|
-
end
|
192
|
-
end
|
193
|
-
begin
|
194
|
-
span = browser.span(how, strg)
|
195
|
-
rescue => e
|
196
|
-
if not rescue_me(e, __method__, "browser.span(#{how}, '#{strg}').exists?", "#{browser.class}")
|
197
|
-
raise e
|
198
|
-
end
|
199
|
-
end
|
200
|
-
if validate(browser, @myName, __LINE__)
|
201
|
-
passed_to_log("Span #{how}='#{strg}' found and returned. #{desc}")
|
202
|
-
return span
|
203
|
-
end
|
204
|
-
rescue
|
205
|
-
failed_to_log("Unable to return span #{how}='#{strg}'. #{desc}: '#{$!}' (#{__LINE__})")
|
206
|
-
end
|
207
|
-
|
208
|
-
def get_span_by_id(browser, strg, desc = '')
|
209
|
-
get_span(browser, :id, strg, desc)
|
210
|
-
end
|
211
|
-
|
212
|
-
=begin rdoc
|
213
|
-
:category: A_rdoc_test
|
214
|
-
Returns a reference to a table element. Used to assign a table element to a variable
|
215
|
-
which can then be used directly or passed to methods that require a *browser* or *table* parameter.
|
216
|
-
|
217
|
-
_Parameters_::
|
218
|
-
|
219
|
-
*browser* - a reference to the browser window or container element to be tested
|
220
|
-
|
221
|
-
*how* - the element attribute used to identify the specific element. Valid values depend on the kind of element.
|
222
|
-
Common values: :text, :id, :title, :name, :class, :href (:link only)
|
223
|
-
|
224
|
-
*what* - a string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
225
|
-
|
226
|
-
*desc* - a string containing a message or description intended to appear in the log and/or report output
|
227
|
-
|
228
|
-
_Example_
|
229
|
-
|
230
|
-
a_table = get_table(browser, :id, 'table1')
|
231
|
-
a_table_cell = a_table[2][1] # The cell in the first column of the second row of the table
|
232
|
-
|
233
|
-
=end
|
234
|
-
|
235
|
-
def get_table(browser, how, what, desc = '')
|
236
|
-
msg = "Return table :#{how}='#{what}'. #{desc}"
|
237
|
-
tbl = browser.table(how, what)
|
238
|
-
if validate(browser, @myName, __LINE__)
|
239
|
-
passed_to_log(msg)
|
240
|
-
tbl
|
241
|
-
end
|
242
|
-
rescue
|
243
|
-
failed_to_log("#{msg}': '#{$!}'")
|
244
|
-
end
|
245
|
-
|
246
|
-
def get_table_by_id(browser, strg, desc = '')
|
247
|
-
get_table(browser, :id, strg, desc)
|
248
|
-
end
|
249
|
-
|
250
|
-
def get_table_by_index(browser, idx)
|
251
|
-
get_table(browser, :index, idx, desc)
|
252
|
-
end
|
253
|
-
|
254
|
-
def get_table_by_text(browser, strg)
|
255
|
-
get_table(browser, :text, strg, desc)
|
256
|
-
end
|
257
|
-
|
258
|
-
def get_table_headers(table, header_index = 1)
|
259
|
-
headers = Hash.new
|
260
|
-
headers['index'] = Hash.new
|
261
|
-
headers['name'] = Hash.new
|
262
|
-
count = 1
|
263
|
-
table[header_index].each do |cell|
|
264
|
-
if cell.text.length > 0
|
265
|
-
name = cell.text.gsub(/\s+/, ' ')
|
266
|
-
headers['index'][count] = name
|
267
|
-
headers['name'][name] = count
|
268
|
-
end
|
269
|
-
count += 1
|
270
|
-
end
|
271
|
-
#debug_to_log("#{__method__}:****** headers:\n#{headers.to_yaml}")
|
272
|
-
headers
|
273
|
-
rescue
|
274
|
-
failed_to_log("Unable to get content headers. '#{$!}'")
|
275
|
-
end
|
276
|
-
|
277
|
-
def get_element(browser, element, how, what, value = nil)
|
278
|
-
target = nil
|
279
|
-
what = Regexp.new(Regexp.escape(what)) unless how == :index or what.is_a?(Regexp)
|
280
|
-
case element
|
281
|
-
when :link
|
282
|
-
target = browser.link(how, what)
|
283
|
-
when :button
|
284
|
-
target = browser.button(how, what)
|
285
|
-
when :div
|
286
|
-
target = browser.div(how, what)
|
287
|
-
when :checkbox
|
288
|
-
target = browser.checkbox(how, what, value)
|
289
|
-
when :text_field, :textfield
|
290
|
-
target = browser.text_field(how, what)
|
291
|
-
when :image
|
292
|
-
target = browser.image(how, what)
|
293
|
-
when :file_field, :filefield
|
294
|
-
target = browser.file_field(how, what)
|
295
|
-
when :form
|
296
|
-
target = browser.form(how, what)
|
297
|
-
when :frame
|
298
|
-
target = browser.frame(how, what)
|
299
|
-
when :radio
|
300
|
-
target = browser.radio(how, what, value)
|
301
|
-
when :span
|
302
|
-
target = browser.span(how, what)
|
303
|
-
when :table
|
304
|
-
target = browser.table(how, what)
|
305
|
-
when :li
|
306
|
-
target = browser.li(how, what)
|
307
|
-
when :select_list, :selectlist
|
308
|
-
target = browser.select_list(how, what)
|
309
|
-
when :hidden
|
310
|
-
target = browser.hidden(how, what)
|
311
|
-
when :area
|
312
|
-
target = browser.area(how, what)
|
313
|
-
end
|
314
|
-
if target.exists?
|
315
|
-
target
|
316
|
-
else
|
317
|
-
nil
|
318
|
-
end
|
319
|
-
rescue => e
|
320
|
-
if not rescue_me(e, __method__, "browser.#{element}(#{how}, '#{what}')", "#{browser.class}", target)
|
321
|
-
raise e
|
322
|
-
end
|
323
|
-
end
|
324
|
-
|
325
|
-
def get_objects(browser, which, dbg=false)
|
326
|
-
cnt = 0
|
327
|
-
case which
|
328
|
-
when :links
|
329
|
-
list = browser.links
|
330
|
-
sleep(1)
|
331
|
-
when :tables
|
332
|
-
list = browser.tables
|
333
|
-
when :divs
|
334
|
-
list = browser.divs
|
335
|
-
when :buttons
|
336
|
-
list = browser.buttons
|
337
|
-
when :checkboxes
|
338
|
-
list = browser.checkboxes
|
339
|
-
when :radios
|
340
|
-
list = browser.radios
|
341
|
-
when :selectlists
|
342
|
-
list = browser.selectlists
|
343
|
-
when :textfields
|
344
|
-
list = browser.textfields
|
345
|
-
when :lis
|
346
|
-
list = browser.lis
|
347
|
-
else
|
348
|
-
debug_to_log("Unrecognized dom object '#{which}'")
|
349
|
-
end
|
350
|
-
if dbg
|
351
|
-
list.each do |obj|
|
352
|
-
cnt += 1
|
353
|
-
debug_to_log("\n==========#{which}:\nindex: #{cnt}\n#{obj}\n#{obj.to_yaml}")
|
354
|
-
end
|
355
|
-
end
|
356
|
-
list
|
357
|
-
end
|
358
|
-
|
359
|
-
def get_ole(element)
|
360
|
-
ole = element.ole_object
|
361
|
-
if ole
|
362
|
-
passed_to_log("Found ole_object for #{element}.")
|
363
|
-
ole
|
364
|
-
else
|
365
|
-
failed_to_log("Did not find ole_object for #{element}.")
|
366
|
-
end
|
367
|
-
rescue
|
368
|
-
failed_to_log("Unable to find ole_object for #{element}. #{$!}")
|
369
|
-
end
|
370
|
-
|
371
|
-
def find_all_links_with_exact_href(browser, href)
|
372
|
-
links = browser.links
|
373
|
-
hash = Hash.new
|
374
|
-
idx = 0
|
375
|
-
links.each do |l|
|
376
|
-
idx += 1
|
377
|
-
an_href = href
|
378
|
-
my_href = l.href
|
379
|
-
if my_href == an_href
|
380
|
-
hash[idx] = l
|
381
|
-
debug_to_log("#{__method__}:#{idx}\n********\n#{l.to_s}\n\n#{l.to_yaml}")
|
382
|
-
end
|
383
|
-
end
|
384
|
-
hash
|
385
|
-
end
|
386
|
-
|
387
|
-
def find_link_with_exact_href(browser, href)
|
388
|
-
links = browser.links
|
389
|
-
link = nil
|
390
|
-
index = 0
|
391
|
-
links.each do |l|
|
392
|
-
index += 1
|
393
|
-
an_href = href
|
394
|
-
my_href = l.href
|
395
|
-
if my_href == an_href
|
396
|
-
link = l
|
397
|
-
# debug_to_log("#{__method__}:#{__LINE__}\n********\n#{l.to_s}\n\n#{l.to_yaml}")
|
398
|
-
break
|
399
|
-
end
|
400
|
-
end
|
401
|
-
link
|
402
|
-
end
|
403
|
-
|
404
|
-
def find_index_for_object(browser, obj, how, ord, strg)
|
405
|
-
obj_sym = (obj.to_s.pluralize).to_sym
|
406
|
-
how_str = how.to_s
|
407
|
-
ptrn = /#{how}:\s+#{strg}/i
|
408
|
-
list = get_objects(browser, obj_sym, true)
|
409
|
-
cnt = 0
|
410
|
-
idx = 0
|
411
|
-
list.each do |nty|
|
412
|
-
s = nty.to_s
|
413
|
-
# a = nty.to_a
|
414
|
-
if s =~ ptrn
|
415
|
-
cnt += 1
|
416
|
-
if cnt == ord
|
417
|
-
break
|
418
|
-
end
|
419
|
-
end
|
420
|
-
idx += 1
|
421
|
-
end
|
422
|
-
idx
|
423
|
-
end
|
424
|
-
|
425
|
-
|
426
|
-
end
|
data/lib/regression/legacy.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
module Legacy
|
2
|
-
|
3
|
-
#--
|
4
|
-
##def open_log
|
5
|
-
# start = Time.now.to_f.to_s
|
6
|
-
#
|
7
|
-
# logTS = Time.at(@myRun.launched.to_f).strftime("%Y%m%d%H%M%S")
|
8
|
-
# xls = @myAppEnv.xls_name.gsub('.xls', '') + '_' if @myAppEnv.xls_name.length > 0
|
9
|
-
# @logFileSpec = "#{@myRoot}/#{logdir}/#{@myName}_#{@targetBrowser.abbrev}_#{xls}#{logTS}.log"
|
10
|
-
# init_logger(@logFileSpec, @myName)
|
11
|
-
#
|
12
|
-
# # message_tolog( self.inspect )
|
13
|
-
# message_to_log("#{@myName} launched at [#{@myRun.launched.to_f.to_s}][#{@myScript.id}][#{@myRun.id}][#{@myChild.id}]")
|
14
|
-
# debug_to_log("pid: #{$$}")
|
15
|
-
# message_to_log("#{@myName} begin at [#{start}]")
|
16
|
-
# message_to_log("#{@myName} environment [#{@myAppEnv.name}]")
|
17
|
-
# message_to_log("#{@myName} xls_name [#{@myAppEnv.xls_name}]") if @myAppEnv.xls_name.length > 0
|
18
|
-
# message_to_log("#{@myName} rootDir [#{@myRoot}]")
|
19
|
-
# message_to_log("#{@myName} Target Browser [#{@targetBrowser.name}]")
|
20
|
-
# mark_testlevel(@myParent.name, @myParent.level) # Module
|
21
|
-
# mark_testlevel(@myChild.name, @myChild.level) # SubModule
|
22
|
-
#
|
23
|
-
#end
|
24
|
-
#++
|
25
|
-
|
26
|
-
#def find_me(where, how, what)
|
27
|
-
# me = where.element(how, what)
|
28
|
-
# puts me.inspect
|
29
|
-
#rescue
|
30
|
-
# error_to_log("#{where.inspect} doesn't seem to respond to element() #{$!}")
|
31
|
-
#end
|
32
|
-
|
33
|
-
# def click_me(element)
|
34
|
-
# element.click
|
35
|
-
# rescue
|
36
|
-
# error_to_log("#{element.inspect} doesn't seem to respond to click() #{$!}")
|
37
|
-
# end
|
38
|
-
|
39
|
-
|
40
|
-
end
|
data/lib/regression/page_data.rb
DELETED
@@ -1,185 +0,0 @@
|
|
1
|
-
module PageData
|
2
|
-
|
3
|
-
=begin rdoc
|
4
|
-
:category: Page Data
|
5
|
-
:tags: data, DOM, page
|
6
|
-
|
7
|
-
_Parameters_::
|
8
|
-
|
9
|
-
*browser* is any container element, usually the browser window or a div within it. Best to use is the smallest that contains the desired data.
|
10
|
-
|
11
|
-
*types* is an array that defaults to all of: :text, :textarea, :select_list, :span, :hidden, :checkbox, and :radio.
|
12
|
-
Set types to an array of a subset of these if fewer elements are desired.
|
13
|
-
|
14
|
-
No positive validations are reported but failure is rescued and reported.
|
15
|
-
=end
|
16
|
-
def capture_page_data(browser, types = [:text, :textarea, :select_list, :span, :hidden, :checkbox, :radio])
|
17
|
-
start = Time.now
|
18
|
-
debug_to_log("Begin #{__method__}")
|
19
|
-
data = Hash.new
|
20
|
-
data[:id] = Hash.new
|
21
|
-
data[:name] = Hash.new
|
22
|
-
data[:index] = Hash.new
|
23
|
-
types.each do |type|
|
24
|
-
#debug_to_log("#{__method__}: #{type}. . .")
|
25
|
-
data[:id][type], data[:name][type], data[:index][type] = parse_elements(browser, type)
|
26
|
-
end
|
27
|
-
data
|
28
|
-
rescue
|
29
|
-
failed_to_log("#{__method__}: '#{$!}'")
|
30
|
-
ensure
|
31
|
-
stop = Time.now
|
32
|
-
passed_to_log("#{__method__.to_s.titleize} finished. (#{"%.5f" % (stop - start)} secs)")
|
33
|
-
#debug_to_log("End #{__method__}")
|
34
|
-
end
|
35
|
-
|
36
|
-
def compare_page_data(before, after, how, desc = '')
|
37
|
-
[:text, :textarea, :select_list, :span, :checkbox, :radio].each do |type|
|
38
|
-
before[how][type].each_key do |what|
|
39
|
-
msg = "#{desc} #{type} #{how}=#{what}: Expected '#{before[how][type][what]}'."
|
40
|
-
if after[how][type][what] == before[how][type][what]
|
41
|
-
passed_to_log(msg)
|
42
|
-
else
|
43
|
-
failed_to_log("#{msg} Found '#{after[how][type][what]}'")
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
rescue
|
48
|
-
failed_to_log("Unable to compare before and after page data. '#{$!}'")
|
49
|
-
end
|
50
|
-
|
51
|
-
=begin rdoc
|
52
|
-
:category: Page Data
|
53
|
-
:tags:data, DOM
|
54
|
-
|
55
|
-
*data* is the hash returned by capture_page_data().
|
56
|
-
|
57
|
-
*how* is one of :id, :name, :index
|
58
|
-
|
59
|
-
*what* is the target value for how. It can be a string or a regular expression
|
60
|
-
|
61
|
-
*type* is one of :text,:textarea,:select_list,:span,:hidden,:checkbox,:radio
|
62
|
-
|
63
|
-
*get_text* determines whether selected option's text or value is returned. Default is true, i.e., return the selected text.
|
64
|
-
This only applies when the *type* is :select_list.
|
65
|
-
|
66
|
-
=end
|
67
|
-
def fetch_page_data(data, how, what, type, get_text = true)
|
68
|
-
rslt = data[how][type][what]
|
69
|
-
if type == :select_list
|
70
|
-
value, text = rslt.split('::')
|
71
|
-
if get_text
|
72
|
-
rslt = text
|
73
|
-
else
|
74
|
-
rslt = value
|
75
|
-
end
|
76
|
-
end
|
77
|
-
rslt
|
78
|
-
end
|
79
|
-
|
80
|
-
=begin rdoc
|
81
|
-
:category: Page Data
|
82
|
-
:tags:data, DOM
|
83
|
-
|
84
|
-
*browser* is any container element. best to use is the smallest that contains the desired data.
|
85
|
-
|
86
|
-
*type* is one of these symbols: :text,:textarea,:select_list,:span,:hidden,:checkbox,:radio
|
87
|
-
|
88
|
-
Returns three hashes: id[type][id] = value, name[type][id] = value, index[type][id] = value
|
89
|
-
|
90
|
-
A given element appears once in the set of hashes depending on how is is found: id first
|
91
|
-
then name, then index.
|
92
|
-
|
93
|
-
Select list value is in the form 'value::text'. parse with x.split('::')
|
94
|
-
|
95
|
-
No positive validations are reported but failure is rescued and reported.
|
96
|
-
=end
|
97
|
-
def parse_elements(browser, type)
|
98
|
-
id = Hash.new
|
99
|
-
name = Hash.new
|
100
|
-
index = Hash.new
|
101
|
-
idx = 0
|
102
|
-
#debug_to_log("#{__method__}: #{type}")
|
103
|
-
case type
|
104
|
-
when :span
|
105
|
-
collection = browser.spans
|
106
|
-
when :select_list
|
107
|
-
collection = browser.select_lists
|
108
|
-
when :radio
|
109
|
-
collection = browser.radios
|
110
|
-
when :checkbox
|
111
|
-
collection = browser.checkboxes
|
112
|
-
else
|
113
|
-
collection = browser.elements(:type, type.to_s)
|
114
|
-
end
|
115
|
-
#debug_to_log("#{__method__}: collection: #{collection.inspect}")
|
116
|
-
collection.each do |e|
|
117
|
-
case type
|
118
|
-
when :span
|
119
|
-
vlu = e.text
|
120
|
-
when :select_list
|
121
|
-
vlu = "#{e.value}::#{e.selected_options[0]}"
|
122
|
-
when :radio
|
123
|
-
vlu = e.set?
|
124
|
-
when :checkbox
|
125
|
-
vlu = e.set?
|
126
|
-
else
|
127
|
-
vlu = e.value
|
128
|
-
end
|
129
|
-
idx += 1
|
130
|
-
if e.id.length > 0 and not e.id =~ /^__[A-Z]/
|
131
|
-
id[e.id] = vlu
|
132
|
-
elsif e.name.length > 0 and not e.name =~ /^__[A-Z]/
|
133
|
-
name[e.name] = vlu
|
134
|
-
else
|
135
|
-
index[idx] = vlu if not type == :hidden
|
136
|
-
end
|
137
|
-
end
|
138
|
-
[id, name, index]
|
139
|
-
|
140
|
-
rescue
|
141
|
-
failed_to_log("#{__method__}: '#{$!}'")
|
142
|
-
end
|
143
|
-
|
144
|
-
def get_textfield_value(browser, how, what, desc = '')
|
145
|
-
msg = "Return value in textfield #{how}='#{what}'"
|
146
|
-
msg << " #{desc}" if desc.length > 0
|
147
|
-
tf = browser.text_field(how, what)
|
148
|
-
if validate(browser, @myName, __LINE__)
|
149
|
-
if tf
|
150
|
-
debug_to_log("#{tf.inspect}")
|
151
|
-
vlu = tf.value
|
152
|
-
passed_to_log("#{msg} Value='#{vlu}'")
|
153
|
-
vlu
|
154
|
-
else
|
155
|
-
failed_to_log("#{msg}")
|
156
|
-
end
|
157
|
-
end
|
158
|
-
rescue
|
159
|
-
failed_to_log("Unable to #{msg}: '#{$!}'")
|
160
|
-
end
|
161
|
-
|
162
|
-
def get_textfield_value_by_name(browser, strg, desc = '')
|
163
|
-
get_textfield_value(browser, :name, strg, desc)
|
164
|
-
end
|
165
|
-
|
166
|
-
def get_textfield_value_by_id(browser, strg)
|
167
|
-
get_textfield_value(browser, :id, strg)
|
168
|
-
end
|
169
|
-
|
170
|
-
def get_element_text(browser, element, how, what, desc = '')
|
171
|
-
msg = "Return text in #{element} #{how}='#{what}'"
|
172
|
-
msg << " #{desc}" if desc.length > 0
|
173
|
-
text = browser.element(how, what).text
|
174
|
-
if validate(browser, @myName, __LINE__)
|
175
|
-
passed_to_log("#{msg} text='#{text}'")
|
176
|
-
text
|
177
|
-
end
|
178
|
-
rescue
|
179
|
-
failed_to_log("Unable to #{msg}: '#{$!}'")
|
180
|
-
end
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
end
|