awetestlib 0.1.30-x86-mingw32 → 1.2.4-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +101 -41
- data/awetestlib.gemspec +36 -47
- data/awetestlib_osx.gemspec +24 -18
- data/awetestlib_windows.gemspec +46 -0
- data/bin/awetestlib +130 -111
- data/bin/awetestlib-driver-setup.rb +0 -2
- data/bin/awetestlib-helpers.rb +43 -30
- data/lib/awetestlib.rb +196 -20
- data/lib/awetestlib/command_line.rb +44 -0
- data/lib/awetestlib/html_report.rb +57 -50
- data/lib/awetestlib/logging.rb +242 -171
- data/lib/awetestlib/regression/awetest_dsl.rb +4240 -0
- data/lib/awetestlib/regression/browser.rb +514 -397
- data/lib/awetestlib/regression/date_and_time.rb +280 -0
- data/lib/awetestlib/regression/drag_and_drop.rb +24 -0
- data/lib/awetestlib/regression/find.rb +70 -43
- data/lib/awetestlib/regression/legacy.rb +1 -1
- data/lib/awetestlib/regression/mobile.rb +293 -0
- data/lib/awetestlib/regression/reporting.rb +298 -0
- data/lib/awetestlib/regression/runner.rb +156 -200
- data/lib/awetestlib/regression/tables.rb +117 -7
- data/lib/awetestlib/regression/test_data.rb +354 -0
- data/lib/awetestlib/regression/user_input.rb +179 -93
- data/lib/awetestlib/regression/utilities.rb +755 -286
- data/lib/awetestlib/regression/validations.rb +325 -115
- data/lib/awetestlib/regression/waits.rb +60 -133
- data/lib/awetestlib/runner.rb +5 -2
- data/lib/version.rb +11 -2
- data/setup_samples/sample_cucumber/features/step_definitions/predefined_steps.rb +109 -49
- data/setup_samples/sample_mobile_app/features/support/env.rb +1 -1
- data/test/google_search2.rb +7 -6
- data/test/popup_child_0.rb +13 -0
- data/test/popup_child_1.rb +33 -0
- data/test/watir_no_require.rb +13 -0
- data/test/watir_with_require.rb +16 -0
- data/test/zoho_exercise.rb +8 -8
- metadata +216 -303
- data/AwetestLib Instructions.rtf +0 -0
- data/awetestlib.windows.gemspec +0 -42
- data/lib/patches/README +0 -2
- data/lib/patches/firewatir.rb +0 -106
- data/lib/patches/watir.rb +0 -175
@@ -15,13 +15,13 @@ module Awetestlib
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def setup
|
18
|
-
# if
|
18
|
+
# if $os.name =~ /Windows.+Server\s+2003/
|
19
19
|
## 'Microsoft(R) Windows(R) Server 2003, Enterprise Edition'
|
20
20
|
# @vertical_hack_ie = 110
|
21
21
|
# @vertical_hack_ff = 138
|
22
22
|
# @horizontal_hack_ie = 5
|
23
23
|
# @horizontal_hack_ff = 4
|
24
|
-
# elsif
|
24
|
+
# elsif $os.name =~ /Windows XP Professional/
|
25
25
|
# 'Microsoft Windows XP Professional'
|
26
26
|
@vertical_hack_ie = 118
|
27
27
|
@vertical_hack_ff = 144
|
@@ -50,39 +50,24 @@ module Awetestlib
|
|
50
50
|
@y_tolerance = 4
|
51
51
|
end
|
52
52
|
|
53
|
-
def build_message(strg1,
|
53
|
+
def build_message(strg1, *strings)
|
54
54
|
msg = "#{strg1}"
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
strings.each do |strg|
|
56
|
+
if strg.is_a?(Array)
|
57
|
+
strg.each do |str|
|
58
|
+
msg << " #{str}" if str and str.length > 0
|
59
|
+
end
|
60
|
+
else
|
61
|
+
msg << " #{strg}" if strg and strg.length > 0
|
62
|
+
end
|
63
|
+
end if strings
|
59
64
|
msg
|
65
|
+
rescue
|
66
|
+
failed_to_log(unable_to)
|
60
67
|
end
|
61
68
|
|
62
|
-
|
63
|
-
|
64
|
-
if this_month == 12
|
65
|
-
next_month = 1
|
66
|
-
else
|
67
|
-
next_month = this_month + 1
|
68
|
-
end
|
69
|
-
if this_month == 1
|
70
|
-
prev_month = 12
|
71
|
-
else
|
72
|
-
prev_month = this_month - 1
|
73
|
-
end
|
74
|
-
|
75
|
-
month_arr = ['', 'January', 'February', 'March', 'April', 'May', 'June',
|
76
|
-
'July', 'August', 'September', 'October', 'November', 'December']
|
77
|
-
|
78
|
-
this_month_name = month_arr[this_month]
|
79
|
-
next_month_name = month_arr[next_month]
|
80
|
-
prev_month_name = month_arr[prev_month]
|
81
|
-
|
82
|
-
arr = [date.year, date.day, this_month_name, next_month_name, prev_month_name]
|
83
|
-
debug_to_log("#{__method__} #{nice_array(arr)}")
|
84
|
-
arr
|
85
|
-
end
|
69
|
+
alias build_msg build_message
|
70
|
+
alias bld_msg build_message
|
86
71
|
|
87
72
|
def get_trace(lnbr)
|
88
73
|
callertrace = "\nCaller trace: (#{lnbr})\n"
|
@@ -94,44 +79,43 @@ module Awetestlib
|
|
94
79
|
|
95
80
|
alias dump_caller get_trace
|
96
81
|
|
97
|
-
def get_mdyy(t = Time.now)
|
98
|
-
"#{t.month}/#{t.day}/#{t.year}"
|
99
|
-
end
|
100
|
-
|
101
82
|
def get_prefix(strg, offset)
|
102
83
|
a_slice = strg.slice(0, offset)
|
103
84
|
a_slice.downcase
|
104
85
|
end
|
105
86
|
|
106
|
-
def get_timestamp(format = 'long', offset = nil, offset_unit = :years)
|
107
|
-
t = DateTime.now
|
108
|
-
if offset
|
109
|
-
t = t.advance(offset_unit => offset)
|
110
|
-
end
|
111
|
-
case format
|
112
|
-
when 'dateonly'
|
113
|
-
t.strftime("%m/%d/%Y")
|
114
|
-
when 'condensed'
|
115
|
-
t.strftime("%Y%m%d%H%M")
|
116
|
-
when 'condensed_seconds'
|
117
|
-
t.strftime("%Y%m%d%H%M%S")
|
118
|
-
when 'long'
|
119
|
-
t.strftime("%m/%d/%Y %I:%M %p")
|
120
|
-
when 'mdyy'
|
121
|
-
get_mdyy(t)
|
122
|
-
when 'm/d/y'
|
123
|
-
get_mdyy(t)
|
124
|
-
else
|
125
|
-
Time.now.strftime("%m/%d/%Y %H:%M:%S")
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
87
|
def calc_index(index, every = 1)
|
130
88
|
(index / every) + (every - 1)
|
131
89
|
end
|
132
90
|
|
133
|
-
def
|
91
|
+
def get_upload_file_control_indexes
|
92
|
+
case $win_major
|
93
|
+
when '5'
|
94
|
+
case @browserAbbrev
|
95
|
+
when 'IE'
|
96
|
+
['1', '1', '2', 'Choose File to Upload']
|
97
|
+
when 'FF'
|
98
|
+
['1', '1', '2', 'File Upload']
|
99
|
+
when 'GC', 'C'
|
100
|
+
['1', '1', '2', 'Open']
|
101
|
+
end
|
102
|
+
when '6'
|
103
|
+
case @browserAbbrev
|
104
|
+
when 'IE'
|
105
|
+
['1', '1', '2', 'Choose File to Upload']
|
106
|
+
when 'FF'
|
107
|
+
['1', '1', '2', 'File Upload']
|
108
|
+
when 'GC', 'C'
|
109
|
+
['1', '1', '2', 'Open']
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def get_variables(file, key_type = :role, enabled_only = true, dbg = true)
|
115
|
+
|
116
|
+
#TODO: support for xlsx files
|
134
117
|
#TODO refactor this
|
118
|
+
|
135
119
|
debug_to_log("#{__method__}: file = #{file}")
|
136
120
|
debug_to_log("#{__method__}: key = #{key_type}")
|
137
121
|
|
@@ -164,60 +148,75 @@ module Awetestlib
|
|
164
148
|
end if dbg
|
165
149
|
|
166
150
|
@login = Hash.new
|
167
|
-
|
151
|
+
script_col = 0
|
168
152
|
role_col = 0
|
169
153
|
userid_col = 0
|
154
|
+
company_col = 0
|
170
155
|
password_col = 0
|
171
156
|
url_col = 0
|
157
|
+
env_col = 0
|
172
158
|
name_col = 0
|
173
159
|
login_index = find_sheet_with_name(workbook, 'Login')
|
174
160
|
if login_index and login_index >= 0
|
175
161
|
workbook.default_sheet = workbook.sheets[login_index]
|
176
162
|
|
177
163
|
1.upto(workbook.last_column) do |col|
|
178
|
-
a_cell = workbook.cell(1, col)
|
164
|
+
a_cell = workbook.cell(1, col).downcase
|
179
165
|
case a_cell
|
180
|
-
when @myName
|
181
|
-
|
166
|
+
when @myName.downcase
|
167
|
+
script_col = col
|
182
168
|
script_found_in_login = true
|
183
169
|
break
|
184
170
|
when 'role'
|
185
171
|
role_col = col
|
186
|
-
when 'userid'
|
172
|
+
when 'userid', 'user_id'
|
187
173
|
userid_col = col
|
174
|
+
when 'companyid', 'company_id'
|
175
|
+
company_col = col
|
188
176
|
when 'password'
|
189
177
|
password_col = col
|
190
178
|
when 'url'
|
191
179
|
url_col = col
|
180
|
+
when 'environment'
|
181
|
+
env_col = col
|
192
182
|
when 'name'
|
193
183
|
name_col = col
|
194
184
|
end
|
195
185
|
end
|
196
186
|
|
197
187
|
2.upto(workbook.last_row) do |line|
|
198
|
-
role
|
199
|
-
userid
|
200
|
-
password
|
201
|
-
url
|
202
|
-
|
203
|
-
|
188
|
+
role = workbook.cell(line, role_col)
|
189
|
+
userid = workbook.cell(line, userid_col)
|
190
|
+
password = workbook.cell(line, password_col)
|
191
|
+
url = workbook.cell(line, url_col)
|
192
|
+
env = workbook.cell(line, env_col)
|
193
|
+
username = workbook.cell(line, name_col)
|
194
|
+
companyid = workbook.cell(line, company_col)
|
195
|
+
enabled = workbook.cell(line, script_col).to_s
|
204
196
|
|
205
197
|
case key_type
|
206
198
|
when :id, :userid
|
207
199
|
key = userid
|
200
|
+
when :environment
|
201
|
+
key = env
|
208
202
|
when :role
|
209
203
|
key = role
|
210
204
|
else
|
211
205
|
key = userid
|
212
206
|
end
|
213
207
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
@login[key]
|
219
|
-
@login[key]['
|
220
|
-
@login[key]['
|
208
|
+
if enabled_only and enabled.length == 0
|
209
|
+
next
|
210
|
+
end
|
211
|
+
|
212
|
+
@login[key] = Hash.new
|
213
|
+
@login[key]['role'] = role
|
214
|
+
@login[key]['userid'] = userid
|
215
|
+
@login[key]['companyid'] = companyid
|
216
|
+
@login[key]['password'] = password
|
217
|
+
@login[key]['url'] = url
|
218
|
+
@login[key]['name'] = username
|
219
|
+
@login[key]['enabled'] = enabled
|
221
220
|
|
222
221
|
end
|
223
222
|
|
@@ -232,7 +231,46 @@ module Awetestlib
|
|
232
231
|
failed_to_log("Script found: in Login = #{script_found_in_login}; in Data = #{script_found_in_data}")
|
233
232
|
end
|
234
233
|
rescue
|
235
|
-
failed_to_log(
|
234
|
+
failed_to_log(unable_to)
|
235
|
+
end
|
236
|
+
|
237
|
+
def translate_color_name(color)
|
238
|
+
if color and color.length > 0
|
239
|
+
HTML_COLORS[color.camelize.downcase].downcase
|
240
|
+
else
|
241
|
+
color
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def translate_tag_name(element)
|
246
|
+
rtrn = ''
|
247
|
+
tag = ''
|
248
|
+
typ = ''
|
249
|
+
if element.respond_to?(:tag_name)
|
250
|
+
tag = element.tag_name
|
251
|
+
typ = element.type if element.respond_to?(:type)
|
252
|
+
rtrn = tag
|
253
|
+
case tag
|
254
|
+
when 'a'
|
255
|
+
rtrn = 'link'
|
256
|
+
when 'input'
|
257
|
+
case typ
|
258
|
+
when 'text'
|
259
|
+
rtrn = 'textfield'
|
260
|
+
when 'textarea'
|
261
|
+
rtrn = 'textarea'
|
262
|
+
when 'submit', 'button'
|
263
|
+
rtrn = 'button'
|
264
|
+
else
|
265
|
+
rtrn = tag
|
266
|
+
end
|
267
|
+
else
|
268
|
+
rtrn = tag
|
269
|
+
end
|
270
|
+
end
|
271
|
+
rtrn
|
272
|
+
rescue
|
273
|
+
failed_to_log(unable_to(tag, typ))
|
236
274
|
end
|
237
275
|
|
238
276
|
def translate_var_list(key)
|
@@ -247,6 +285,66 @@ module Awetestlib
|
|
247
285
|
failed_to_log("#{__method__}: '#{$!}'")
|
248
286
|
end
|
249
287
|
|
288
|
+
def get_awetestlib_metadata
|
289
|
+
$metadata = YAML.load(`gem spec awetestlib metadata`.chomp)
|
290
|
+
end
|
291
|
+
|
292
|
+
def parse_list(string, delim = ',', limit = -1)
|
293
|
+
string.split(/#{delim}\s*/, limit)
|
294
|
+
rescue
|
295
|
+
failed_to_log(unable_to("string:[#{string}]"))
|
296
|
+
end
|
297
|
+
|
298
|
+
def get_project_git(proj_name, proj_dir = Dir.pwd)
|
299
|
+
debug_to_log(with_caller(proj_dir))
|
300
|
+
sha = nil
|
301
|
+
branch = nil
|
302
|
+
date = nil
|
303
|
+
|
304
|
+
curr_dir = Dir.pwd
|
305
|
+
version_file = "#{proj_name.downcase.gsub(' ', '_')}_version"
|
306
|
+
|
307
|
+
if Dir.exists?(proj_dir)
|
308
|
+
|
309
|
+
Dir.chdir(proj_dir) unless proj_dir == curr_dir
|
310
|
+
|
311
|
+
if Dir.exists?('.git')
|
312
|
+
require 'git'
|
313
|
+
git = Git.open(Dir.pwd)
|
314
|
+
branch = git.current_branch
|
315
|
+
commit = git.gblob(branch).log(5).first
|
316
|
+
sha = commit.sha
|
317
|
+
date = commit.date
|
318
|
+
|
319
|
+
version_file = File.join(proj_dir, version_file)
|
320
|
+
file = File.open(version_file, 'w')
|
321
|
+
file.puts "#{branch}, #{date}, #{sha}"
|
322
|
+
file.close
|
323
|
+
|
324
|
+
end
|
325
|
+
|
326
|
+
Dir.chdir(curr_dir) unless proj_dir == curr_dir
|
327
|
+
|
328
|
+
end
|
329
|
+
|
330
|
+
unless branch
|
331
|
+
version_file = File.join(Dir.pwd, version_file)
|
332
|
+
if File.exists?(version_file)
|
333
|
+
vers = File.open(version_file).read
|
334
|
+
branch, date, sha = parse_list(vers.chomp)
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
[branch, date, sha]
|
339
|
+
end
|
340
|
+
|
341
|
+
def git_sha1(file)
|
342
|
+
if File.exists?(file)
|
343
|
+
size, sha1 = `ruby git_sha1.rb #{file}`.chomp.split(/\n/)
|
344
|
+
debug_to_log("#{file} #{size} sha1 is #{sha1}")
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
250
348
|
def grab_window_list(strg)
|
251
349
|
@ai.AutoItSetOption("WinTitleMatchMode", 2)
|
252
350
|
list = @ai.WinList(strg)
|
@@ -265,25 +363,21 @@ module Awetestlib
|
|
265
363
|
stuff
|
266
364
|
end
|
267
365
|
|
366
|
+
def count_duplicates(arr)
|
367
|
+
counts = {}
|
368
|
+
dups = {}
|
369
|
+
arr.each do |id|
|
370
|
+
counts[id] = counts[id] ? counts[id] + 1 : 1
|
371
|
+
dups[id] = counts[id] if counts[id] > 1
|
372
|
+
end
|
373
|
+
[dups, counts]
|
374
|
+
end
|
375
|
+
|
268
376
|
def debug_call_list(msg)
|
269
377
|
call_array = get_call_array
|
270
378
|
debug_to_log("#{msg}\n#{dump_array(call_array)}")
|
271
379
|
end
|
272
380
|
|
273
|
-
def sec2hms(s)
|
274
|
-
Time.at(s.to_i).gmtime.strftime('%H:%M:%S')
|
275
|
-
end
|
276
|
-
|
277
|
-
def close_log(scriptName, lnbr = '')
|
278
|
-
cmplTS = Time.now.to_f.to_s
|
279
|
-
puts ("#{scriptName} finished. Closing log. #{lnbr.to_s}")
|
280
|
-
passed_to_log("#{scriptName} run complete [#{cmplTS}]")
|
281
|
-
@myLog.close()
|
282
|
-
sleep(2)
|
283
|
-
end
|
284
|
-
|
285
|
-
protected :close_log
|
286
|
-
|
287
381
|
def find_sheet_with_name(workbook, sheet_name)
|
288
382
|
sheets = workbook.sheets
|
289
383
|
idx = 0
|
@@ -321,33 +415,76 @@ module Awetestlib
|
|
321
415
|
sprintf(ptrn, number).gsub(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")
|
322
416
|
end
|
323
417
|
|
324
|
-
def
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
418
|
+
def normalize_color_value(value, rgba = true)
|
419
|
+
case value
|
420
|
+
when /^#/
|
421
|
+
html_to_rgb(value, rgba)
|
422
|
+
when /^rgba/i
|
423
|
+
value
|
424
|
+
when /^rgb()/i
|
425
|
+
rgb_to_rgba(value)
|
426
|
+
when /^transparent/i, /^0$/i
|
427
|
+
'rgba(0, 0, 0, 0)'
|
428
|
+
when /white/
|
429
|
+
'rgba(255, 255, 255, 1)'
|
430
|
+
else
|
431
|
+
html_to_rgb(translate_color_name(value), rgba)
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
def number_to_word(nbr)
|
436
|
+
map = { 1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five',
|
437
|
+
6 => 'six', 7 => 'seven', 8 => 'eight', 9 => 'nine', 10 => 'ten',
|
438
|
+
11 => 'eleven', 12 => 'twelve', 13 => 'thirteen', 14 => 'fourteen', 15 => 'fifteen',
|
439
|
+
16 => 'sixteen', 17 => 'seventeen', 18 => 'eighteen', 19 => 'nineteen', 20 => 'twenty'
|
440
|
+
}
|
441
|
+
if nbr > 20
|
442
|
+
'more than twenty'
|
443
|
+
else
|
444
|
+
map[nbr]
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
alias nbr2word number_to_word
|
449
|
+
|
450
|
+
def string_array_numeric_sort(arr)
|
451
|
+
#TODO: almost certainly a more 'rubyish' and less clunky way to do this
|
452
|
+
trgt = arr.dup
|
453
|
+
narr = []
|
454
|
+
trgt.each do |n|
|
455
|
+
narr << n.to_i
|
456
|
+
end
|
457
|
+
narr.sort!
|
458
|
+
sarr = []
|
459
|
+
narr.each do |n|
|
460
|
+
sarr << n.to_s
|
461
|
+
end
|
462
|
+
sarr
|
463
|
+
end
|
464
|
+
|
465
|
+
alias strg_arr_numeric_sort string_array_numeric_sort
|
335
466
|
|
336
467
|
def string_count_in_string(strg, substrg)
|
337
468
|
count = strg.scan(substrg).length
|
338
469
|
count
|
339
470
|
end
|
340
471
|
|
472
|
+
def string_to_hex(strg, format = 'U')
|
473
|
+
strg.unpack(format*strg.length)
|
474
|
+
# strg.split(//).collect do |x|
|
475
|
+
# x.match(/\d/) ? x : x.unpack('U')[0].to_s(16)
|
476
|
+
# end
|
477
|
+
end
|
478
|
+
|
341
479
|
def strip_regex_mix(strg)
|
342
480
|
rslt = strg.dup
|
343
|
-
|
344
|
-
|
345
|
-
end
|
481
|
+
mtch = rslt.match(/(\(\?-mix:(.+)\))/)
|
482
|
+
rslt.sub!(mtch[1], "/#{mtch[2]}/")
|
346
483
|
rslt
|
347
484
|
end
|
348
485
|
|
349
486
|
def rescue_me(e, me = nil, what = nil, where = nil, who = nil)
|
350
|
-
#TODO: these are rescues from exceptions raised in Watir
|
487
|
+
#TODO: these are rescues from exceptions raised in Watir or Watir-webdriver
|
351
488
|
debug_to_log("#{__method__}: Begin rescue")
|
352
489
|
ok = false
|
353
490
|
begin
|
@@ -358,7 +495,7 @@ module Awetestlib
|
|
358
495
|
end
|
359
496
|
msg = e.message
|
360
497
|
debug_to_log("#{__method__}: msg = #{msg}")
|
361
|
-
if
|
498
|
+
if msg =~ /undefined method\s+.join.\s+for/i # firewatir to_s implementation error
|
362
499
|
ok = true
|
363
500
|
elsif msg =~ /undefined method\s+.match.\s+for.+WIN32OLERuntimeError/i # watir and firewatir
|
364
501
|
ok = true
|
@@ -372,106 +509,105 @@ module Awetestlib
|
|
372
509
|
ok = true
|
373
510
|
elsif msg =~ /wrong number of arguments \(1 for 0\)/i
|
374
511
|
ok = true
|
375
|
-
elsif
|
512
|
+
elsif msg =~ /unable to locate element/i
|
376
513
|
if located
|
377
514
|
ok = true
|
378
515
|
elsif where == 'Watir::Div'
|
379
516
|
ok = true
|
380
517
|
end
|
381
|
-
elsif
|
518
|
+
elsif msg =~ /(The SafariDriver does not interact with modal dialogs)/i
|
519
|
+
to_report = $1
|
520
|
+
ok = true
|
521
|
+
elsif msg =~ /HRESULT error code:0x80070005/
|
382
522
|
ok = true
|
383
|
-
|
384
|
-
|
523
|
+
#elsif msg =~ /missing\s+\;\s+before statement/
|
524
|
+
# ok = true
|
385
525
|
end
|
526
|
+
call_list = get_call_list(6, true)
|
386
527
|
if ok
|
387
528
|
debug_to_log("#{__method__}: RESCUED: \n#{who.to_yaml}=> #{what} in #{me}()\n=> '#{$!}'")
|
388
529
|
debug_to_log("#{__method__}: #{who.inspect}") if who
|
389
530
|
debug_to_log("#{__method__}: #{where.inspect}")
|
390
|
-
debug_to_log("#{__method__}: #{
|
531
|
+
debug_to_log("#{__method__}: #{call_list}")
|
532
|
+
failed_to_log("#{to_report} #{call_list}")
|
391
533
|
else
|
392
534
|
debug_to_log("#{__method__}: NO RESCUE: #{e.message}")
|
393
|
-
debug_to_log("#{__method__}: NO RESCUE: \n#{
|
535
|
+
debug_to_log("#{__method__}: NO RESCUE: \n#{call_list}")
|
394
536
|
end
|
395
537
|
debug_to_log("#{__method__}: Exit")
|
396
538
|
ok
|
397
539
|
end
|
398
540
|
|
399
|
-
def
|
400
|
-
|
401
|
-
|
402
|
-
|
541
|
+
def convert_color_value(value, rgba = false)
|
542
|
+
if value =~ /^#/
|
543
|
+
html_to_rgb(value, rgba)
|
544
|
+
else
|
545
|
+
rgb_to_html(value)
|
546
|
+
end
|
403
547
|
end
|
404
548
|
|
405
|
-
def
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
myList << "[#{$1.gsub(/eval/, @myName)}] "
|
413
|
-
break if x > depth or myCaller =~ /:in .run.$/
|
549
|
+
def rgb_to_html(rgb)
|
550
|
+
rgb =~ /rgba?\((.+)\)/
|
551
|
+
if $1
|
552
|
+
r, g, b, a = $1.split(/,\s*/)
|
553
|
+
"#%02x%02x%02x" % [r, g, b]
|
554
|
+
else
|
555
|
+
rgb
|
414
556
|
end
|
415
|
-
myList
|
416
557
|
end
|
417
558
|
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
myCaller =~ /([\(\)\w_\_\-\.]+\:\d+\:?.*?)$/
|
428
|
-
myList << "[#{$1.gsub(/eval/, @myName)}] "
|
429
|
-
break
|
430
|
-
end
|
431
|
-
break if x > depth or myCaller =~ /:in .run.$/ # this break causes error in Ruby 1.9.x
|
432
|
-
end
|
433
|
-
if @projName
|
434
|
-
call_list.each_index do |x|
|
435
|
-
myCaller = call_list[x].to_s
|
436
|
-
if myCaller.include? @projName
|
437
|
-
myCaller =~ /([\(\)\w_\_\-\.]+\:\d+\:?.*?)$/
|
438
|
-
myList << "[#{$1.gsub(/eval/, @projName)}] "
|
439
|
-
break
|
440
|
-
end
|
441
|
-
end
|
442
|
-
break if x > depth or myCaller =~ /:in .run.$/ # this break causes error in Ruby 1.9.
|
559
|
+
def rgb_to_rgba(rgb)
|
560
|
+
if rgb =~ /^rgb\(\s*(\d+),\s*(\d+),\s*(\d+)\s*\)/i
|
561
|
+
r = $1
|
562
|
+
g = $2
|
563
|
+
b = $3
|
564
|
+
op = rgb =~ /[1-9]/ ? '1' : '0'
|
565
|
+
rtrn = "rgba(#{r}, #{g}, #{b}, #{op})" #waft-1148
|
566
|
+
else
|
567
|
+
rtrn = rgb
|
443
568
|
end
|
444
|
-
|
569
|
+
rtrn
|
445
570
|
end
|
446
571
|
|
447
|
-
def
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
572
|
+
def html_to_rgb(html, a = true)
|
573
|
+
if html and html.length > 0
|
574
|
+
html = html.gsub(%r{[#;]}, '')
|
575
|
+
case html.size
|
576
|
+
when 3
|
577
|
+
colors = html.scan(%r{[0-9A-Fa-f]}).map { |el| (el * 2).to_i(16) }
|
578
|
+
when 6
|
579
|
+
colors = html.scan(%r<[0-9A-Fa-f]{2}>).map { |el| el.to_i(16) }
|
580
|
+
end
|
581
|
+
rgb = 'rgb'
|
582
|
+
rgb << 'a' if a
|
583
|
+
rgb << '('
|
584
|
+
colors.each do |c|
|
585
|
+
rgb << "#{c}, "
|
586
|
+
end
|
587
|
+
if a
|
588
|
+
rgb << '1)'
|
589
|
+
else
|
590
|
+
rgb.strip!.chop!
|
591
|
+
rgb << ')'
|
592
|
+
end
|
593
|
+
rgb
|
594
|
+
else
|
595
|
+
html
|
455
596
|
end
|
456
|
-
arr
|
457
597
|
end
|
458
598
|
|
459
|
-
def
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
599
|
+
def analyse_element_presence(container, element, how, what, max_seconds = 30, interval = 0.25)
|
600
|
+
duration = 0
|
601
|
+
code = build_webdriver_fetch(element, how, what) + '.present?'
|
602
|
+
debug_to_log("#{__method__}: code=>[#{code}")
|
603
|
+
until duration > max_seconds do
|
604
|
+
begin
|
605
|
+
debug_to_log("#{eval(code)} #{duration}")
|
606
|
+
rescue => e
|
607
|
+
debug_to_log("#{__method__}: #{e.inspect}")
|
466
608
|
end
|
467
|
-
|
468
|
-
|
469
|
-
if arr.length > 0
|
470
|
-
list = 'TRACE:'
|
471
|
-
arr.reverse.each { |l| list << "=>#{l}" }
|
472
|
-
" [[#{list}]]"
|
473
|
-
else
|
474
|
-
nil
|
609
|
+
duration += interval
|
610
|
+
sleep(interval)
|
475
611
|
end
|
476
612
|
end
|
477
613
|
|
@@ -536,23 +672,10 @@ module Awetestlib
|
|
536
672
|
end
|
537
673
|
end
|
538
674
|
|
539
|
-
def
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
tables.each do |tbl|
|
544
|
-
tbl_cnt += 1
|
545
|
-
row_cnt = 0
|
546
|
-
msg << "\n=================\ntable: #{tbl_cnt}\n=================\n#{tbl}\ntext:\n#{tbl.text}"
|
547
|
-
tbl.rows.each do |row|
|
548
|
-
row_cnt += 1
|
549
|
-
cell_cnt = 0
|
550
|
-
msg << "\n=================\ntable: #{tbl_cnt} row: #{row_cnt}\n#{row.inspect}\n#{row}\ntext:'#{row.text}'"
|
551
|
-
row.each do |cell|
|
552
|
-
cell_cnt += 1
|
553
|
-
msg << " \ncell: #{cell_cnt}\n#{cell.inspect}\n#{row}\ntext: '#{cell.text}'"
|
554
|
-
end
|
555
|
-
end
|
675
|
+
def dump_option_array(options, desc = '', to_report = false)
|
676
|
+
msg = with_caller(desc, "\n")
|
677
|
+
options.each do |option|
|
678
|
+
msg << "text: '#{option.text}' value: '#{option.value}' selected: #{option.selected?}\n"
|
556
679
|
end
|
557
680
|
if to_report
|
558
681
|
debug_to_report(msg)
|
@@ -561,59 +684,193 @@ module Awetestlib
|
|
561
684
|
end
|
562
685
|
end
|
563
686
|
|
564
|
-
def
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
687
|
+
def parse_cookies(browser)
|
688
|
+
cookies = Hash.new
|
689
|
+
strg = browser.document.cookie
|
690
|
+
ary = strg.split(';')
|
691
|
+
ary.each do |c|
|
692
|
+
key, value = c.split('=')
|
693
|
+
cookies[key.lstrip] = value
|
570
694
|
end
|
571
|
-
|
572
|
-
|
573
|
-
|
695
|
+
cookies
|
696
|
+
end
|
697
|
+
|
698
|
+
def parse_test_flag(string)
|
699
|
+
test = false
|
700
|
+
refs = nil
|
701
|
+
if string
|
702
|
+
if string == true or string == false
|
703
|
+
test = string
|
704
|
+
else
|
705
|
+
if string.length > 0
|
706
|
+
unless string =~ /^no$/i
|
707
|
+
test = true
|
708
|
+
unless string =~ /^yes$/i
|
709
|
+
refs = format_refs(string)
|
710
|
+
end
|
711
|
+
end
|
712
|
+
end
|
713
|
+
end
|
714
|
+
end
|
715
|
+
[test, refs]
|
716
|
+
rescue
|
717
|
+
failed_to_log(unable_to)
|
718
|
+
end
|
719
|
+
|
720
|
+
def build_webdriver_fetch(element, how, what, more = {})
|
721
|
+
code = "container.#{element}(:#{how} => "
|
722
|
+
what = escape_stuff(what) unless how == :index
|
723
|
+
if what.is_a?(Regexp)
|
724
|
+
code << "/#{what.source}/"
|
725
|
+
elsif how == :index
|
726
|
+
code << "#{what}"
|
574
727
|
else
|
575
|
-
|
728
|
+
code << "'#{what}'"
|
576
729
|
end
|
730
|
+
if more and not more.empty?
|
731
|
+
more.each do |key, vlu|
|
732
|
+
next if key == :desc or key == :flash or key == :exists_only
|
733
|
+
code << ", :#{key} => "
|
734
|
+
if vlu.is_a?(Regexp)
|
735
|
+
code << "/#{vlu}/"
|
736
|
+
elsif vlu.is_a?(String)
|
737
|
+
code << "'#{vlu.gsub('/', '\/')}'"
|
738
|
+
else
|
739
|
+
code << "#{vlu}"
|
740
|
+
end
|
741
|
+
end
|
742
|
+
end
|
743
|
+
code << ')'
|
744
|
+
#debug_to_log("code: '#{code}'")
|
745
|
+
code
|
746
|
+
rescue
|
747
|
+
failed_to_log(unable_to)
|
577
748
|
end
|
578
749
|
|
579
|
-
def
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
750
|
+
def element_action_message(element, action, how = nil, what = nil, value = nil, desc = '', refs = '')
|
751
|
+
name = element.respond_to?(:tag_name) ? element.tag_name.upcase : element.to_s
|
752
|
+
how, what = extract_locator(element, how)[1, 2] unless how and what
|
753
|
+
build_message(desc, action, "#{name}",
|
754
|
+
(what ? "with #{how}=>'#{what}'" : nil),
|
755
|
+
(value ? "and value=>'#{value}'" : nil), refs)
|
756
|
+
end
|
757
|
+
|
758
|
+
def element_query_message(element, query, how = nil, what = nil, value = nil, desc = '', refs = '')
|
759
|
+
if element.exists?
|
760
|
+
name = element.respond_to?(:tag_name) ? element.tag_name.upcase : element.to_s
|
761
|
+
else
|
762
|
+
name = '(unknown)'
|
763
|
+
end
|
764
|
+
build_message(desc, "#{name}",
|
765
|
+
(what ? "with #{how}=>' #{what}'" : nil),
|
766
|
+
(value ? "and value=>'#{value}'" : nil),
|
767
|
+
query, refs)
|
768
|
+
rescue
|
769
|
+
failed_to_log(unable_to)
|
770
|
+
end
|
771
|
+
|
772
|
+
def end_processes(*names)
|
773
|
+
pattern = ''
|
774
|
+
names.each { |n| pattern << "#{n}|" }
|
775
|
+
pattern.chop!
|
776
|
+
# puts pattern
|
777
|
+
targets = {}
|
778
|
+
|
779
|
+
if USING_OSX
|
780
|
+
p_io = IO.popen("ps axo comm,pid,sess,fname")
|
781
|
+
else
|
782
|
+
p_io = IO.popen("tasklist /nh")
|
783
|
+
end
|
784
|
+
|
785
|
+
p_io.readlines.each do |prc|
|
786
|
+
# puts prc.chop
|
787
|
+
if prc =~ /#{pattern}/
|
788
|
+
name, pid = prc.split(/\s+/)[0, 2]
|
789
|
+
# puts "#{name} #{pid}"
|
790
|
+
base = File.basename(name)
|
791
|
+
targets[pid] = base
|
590
792
|
end
|
591
793
|
end
|
592
|
-
|
794
|
+
|
795
|
+
debug_to_log("End these processes:\n#{targets.to_yaml}")
|
796
|
+
|
797
|
+
if USING_OSX
|
798
|
+
kill_cmd = 'kill -9 @@@@@'
|
799
|
+
else
|
800
|
+
kill_cmd = 'taskkill /f /pid @@@@@'
|
801
|
+
end
|
802
|
+
|
803
|
+
targets.each do |pid, name|
|
804
|
+
cmd = kill_cmd.sub('@@@@@', pid)
|
805
|
+
debug_to_log("[#{cmd}]")
|
806
|
+
kill_io = IO.popen(cmd, :err => :out)
|
807
|
+
debug_to_log(kill_io.read.chomp)
|
808
|
+
end
|
809
|
+
|
810
|
+
if targets.length > 0
|
811
|
+
sleep_for(10)
|
812
|
+
end
|
593
813
|
end
|
594
814
|
|
595
|
-
|
815
|
+
def escape_stuff(strg)
|
816
|
+
if strg.respond_to?(:dup)
|
817
|
+
rslt = strg.dup
|
818
|
+
unless rslt.is_a?(Regexp)
|
819
|
+
if rslt.match(/[\/\(\)]/)
|
820
|
+
rslt.gsub!('/', '\/')
|
821
|
+
rslt.gsub!('(', '\(')
|
822
|
+
rslt.gsub!(')', '\)')
|
823
|
+
rslt = Regexp.new(rslt)
|
824
|
+
end
|
825
|
+
end
|
826
|
+
else
|
827
|
+
rslt = strg
|
828
|
+
end
|
829
|
+
rslt
|
830
|
+
rescue
|
831
|
+
failed_to_log(unable_to("#{rslt}"))
|
832
|
+
end
|
596
833
|
|
597
|
-
def
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
834
|
+
def extract_selected(selected_options, which = :text)
|
835
|
+
arr = Array.new
|
836
|
+
selected_options.each do |so|
|
837
|
+
case which
|
838
|
+
when :text
|
839
|
+
arr << so.text
|
840
|
+
else
|
841
|
+
arr << so.value
|
842
|
+
end
|
604
843
|
end
|
605
|
-
|
844
|
+
arr.sort
|
845
|
+
rescue
|
846
|
+
failed_to_log(unable_to)
|
606
847
|
end
|
607
848
|
|
608
|
-
def
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
849
|
+
def extract_locator(element, how = nil)
|
850
|
+
# html_to_log(element)
|
851
|
+
if element.respond_to?(:tag_name)
|
852
|
+
tag = element.tag_name.to_sym
|
853
|
+
else
|
854
|
+
element = element.body.elements[0]
|
855
|
+
tag = element.tag_name.to_sym
|
615
856
|
end
|
616
|
-
|
857
|
+
what = nil
|
858
|
+
case how
|
859
|
+
when nil
|
860
|
+
[:id, :name, :title, :class, :value].each do |attr|
|
861
|
+
what = element.attribute_value(attr.to_s)
|
862
|
+
if what and what.length > 0
|
863
|
+
how = attr
|
864
|
+
break
|
865
|
+
end
|
866
|
+
end
|
867
|
+
else
|
868
|
+
what = element.attribute_value(how.to_s)
|
869
|
+
end
|
870
|
+
# debug_to_log(with_caller("#{tag}:#{how}:#{what}"))
|
871
|
+
[tag, how, what]
|
872
|
+
rescue
|
873
|
+
failed_to_log(unable_to(build_message(":#{tag}, :#{how}='#{what}'")))
|
617
874
|
end
|
618
875
|
|
619
876
|
def capture_screen(browser, ts)
|
@@ -657,12 +914,30 @@ module Awetestlib
|
|
657
914
|
failed_to_log("Unable to #{msg} '#{$!}'")
|
658
915
|
end
|
659
916
|
|
660
|
-
def flash(element,
|
661
|
-
|
662
|
-
|
663
|
-
|
917
|
+
def flash(container, element, how, what, value = nil, desc = '', refs = '', options = {})
|
918
|
+
if @flash
|
919
|
+
value, desc, refs, options = capture_value_desc(value, desc, refs, options) # for backwards compatibility
|
920
|
+
code = build_webdriver_fetch(element, how, what, options)
|
921
|
+
target = eval(code)
|
922
|
+
flash_element(target, desc, refs)
|
923
|
+
end
|
924
|
+
rescue
|
925
|
+
failed_to_log(unable_to)
|
926
|
+
end
|
927
|
+
|
928
|
+
def flash_element(element, desc = '', refs = '')
|
929
|
+
if @flash
|
930
|
+
if element
|
931
|
+
element.wd.location_once_scrolled_into_view
|
932
|
+
# scroll_to(element.browser, element, desc, refs)
|
933
|
+
if element.respond_to?(:flash)
|
934
|
+
# sleep(0.1)
|
935
|
+
element.flash
|
936
|
+
end
|
937
|
+
end
|
938
|
+
end
|
664
939
|
rescue
|
665
|
-
|
940
|
+
failed_to_log(unable_to)
|
666
941
|
end
|
667
942
|
|
668
943
|
def get_save_file_path(root, filename)
|
@@ -747,6 +1022,28 @@ module Awetestlib
|
|
747
1022
|
failed_to_log("Save file failed: #{desc} '#{$!}'. (#{__LINE__})")
|
748
1023
|
end
|
749
1024
|
|
1025
|
+
def rotate_array(arr, stop = 0, index = 0, target = '')
|
1026
|
+
rotated = arr.dup
|
1027
|
+
length = rotated.size
|
1028
|
+
(1..length).each do |itr|
|
1029
|
+
rotated.push(rotated.shift)
|
1030
|
+
if stop > 0
|
1031
|
+
break if itr == stop
|
1032
|
+
else
|
1033
|
+
break if rotated[index] == target
|
1034
|
+
end
|
1035
|
+
end
|
1036
|
+
rotated
|
1037
|
+
rescue
|
1038
|
+
failed_to_log(unable_to)
|
1039
|
+
end
|
1040
|
+
|
1041
|
+
def running_thread_count
|
1042
|
+
running = Thread.list.select { |thread| thread.status == "run" }.count
|
1043
|
+
asleep = Thread.list.select { |thread| thread.status == "sleep" }.count
|
1044
|
+
[running, asleep]
|
1045
|
+
end
|
1046
|
+
|
750
1047
|
#method for handling save dialog
|
751
1048
|
#use click_no_wait on the action that triggers the save dialog
|
752
1049
|
def save_file(filepath, download_title = "File Download - Security Warning")
|
@@ -887,7 +1184,7 @@ module Awetestlib
|
|
887
1184
|
#use click_no_wait on the action that triggers the save dialog
|
888
1185
|
# TODO need version for Firefox
|
889
1186
|
def file_upload(filepath, title = 'Choose File', text = '', button = '&Open',
|
890
|
-
|
1187
|
+
control = 'Edit1', side = 'primary')
|
891
1188
|
title = translate_popup_title(title)
|
892
1189
|
msg = "Window title=#{title} button='#{button}' text='#{text}' side='#{side}':"
|
893
1190
|
begin
|
@@ -922,20 +1219,22 @@ module Awetestlib
|
|
922
1219
|
|
923
1220
|
end
|
924
1221
|
|
925
|
-
def upload_file(data_path)
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
}
|
936
|
-
|
937
|
-
|
938
|
-
|
1222
|
+
def upload_file(browser, data_path, wait = 20)
|
1223
|
+
#mark_test_level(data_path)
|
1224
|
+
message_to_report(with_caller(data_path))
|
1225
|
+
data_path.gsub!('/', '\\') if USING_WINDOWS
|
1226
|
+
|
1227
|
+
file, open, cancel, title = get_upload_file_control_indexes
|
1228
|
+
|
1229
|
+
@ai.WinWait(title, "", wait)
|
1230
|
+
sleep_for(1)
|
1231
|
+
@ai.ControlSend(title, '', "[CLASS:Edit; INSTANCE:#{file}]", '!u')
|
1232
|
+
@ai.ControlSetText(title, '', "[CLASS:Edit; INSTANCE:#{file}]", data_path)
|
1233
|
+
sleep_for(0.5)
|
1234
|
+
@ai.ControlClick(title, "", "[CLASS:Button; INSTANCE:#{open}]", "primary")
|
1235
|
+
|
1236
|
+
rescue
|
1237
|
+
failed_to_log(unable_to)
|
939
1238
|
end
|
940
1239
|
|
941
1240
|
def focus_on_textfield_by_id(browser, strg, desc = '')
|
@@ -981,25 +1280,43 @@ module Awetestlib
|
|
981
1280
|
loc
|
982
1281
|
end
|
983
1282
|
|
984
|
-
def
|
1283
|
+
def rescue_msg_for_validation(desc, refs = nil)
|
1284
|
+
failed_to_log(unable_to(build_message(desc, refs), NO_DOLLAR_BANG, VERIFY_MSG), 2)
|
1285
|
+
end
|
1286
|
+
|
1287
|
+
def method_to_title(method, no_sub = false, subs = { /And/ => '&', /^Ac / => 'AC ' })
|
985
1288
|
title = method.to_s.titleize
|
986
|
-
|
1289
|
+
unless no_sub
|
1290
|
+
subs.each do |ptrn, rplc|
|
1291
|
+
title.gsub!(ptrn, rplc)
|
1292
|
+
end
|
1293
|
+
end
|
987
1294
|
title
|
988
1295
|
rescue
|
989
|
-
debug_to_log("
|
1296
|
+
debug_to_log(unable_to(": #{method}"))
|
990
1297
|
end
|
991
1298
|
|
992
|
-
def unable_to(message = '', no_dolbang = false, verify_that = false)
|
993
|
-
call_arr
|
994
|
-
|
1299
|
+
def unable_to(message = '', no_dolbang = false, verify_that = false, caller_index = 1)
|
1300
|
+
call_arr = get_call_array
|
1301
|
+
puts call_arr
|
1302
|
+
call_script, call_line, call_meth = parse_caller(call_arr[caller_index])
|
995
1303
|
strg = "Unable to"
|
996
1304
|
strg << " verify" if verify_that
|
997
1305
|
strg << " #{call_meth.titleize}:"
|
1306
|
+
strg << '?' if call_meth =~ /\?/
|
1307
|
+
strg << ':'
|
998
1308
|
strg << " #{message}" if message.length > 0
|
999
1309
|
strg << " '#{$!}'" unless no_dolbang
|
1000
1310
|
strg
|
1001
1311
|
end
|
1002
1312
|
|
1313
|
+
def pad_id_end_count(id, delim = '_', pad = 6)
|
1314
|
+
mtch = id.match(/^(.*)#{delim}(\d+)$/)
|
1315
|
+
mtch[1] + delim + mtch[2].rjust(pad, '0')
|
1316
|
+
rescue
|
1317
|
+
failed_to_log(unable_to("id: '#{id}' delim: '#{delim}' pad: #{pad}"))
|
1318
|
+
end
|
1319
|
+
|
1003
1320
|
def parse_caller(caller)
|
1004
1321
|
call_script, call_line, call_meth = caller.split(':')
|
1005
1322
|
call_script.gsub!(/\.rb/, '')
|
@@ -1009,45 +1326,197 @@ module Awetestlib
|
|
1009
1326
|
[call_script, call_line, call_meth]
|
1010
1327
|
end
|
1011
1328
|
|
1012
|
-
def
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1329
|
+
def insert_id_pswd_in_url(userid, password, url)
|
1330
|
+
http = url.match(/^(http)(s?)(:\/\/)/)
|
1331
|
+
path = url.gsub(http[0], '')
|
1332
|
+
URI.encode("#{http[0]}#{userid}:#{password}@#{path}")
|
1333
|
+
end
|
1334
|
+
|
1335
|
+
def get_basic_auth_control_indexes
|
1336
|
+
case $win_major
|
1337
|
+
when '5'
|
1338
|
+
case @browserAbbrev
|
1339
|
+
when 'IE'
|
1340
|
+
['2', '3', '1', 'Connect to']
|
1341
|
+
when 'FF'
|
1342
|
+
['2', '3', '1', 'Authentication Required']
|
1343
|
+
when 'GC', 'C'
|
1344
|
+
['2', '1', '2', 'Authentication Required']
|
1345
|
+
end
|
1346
|
+
when '6'
|
1347
|
+
case @browserAbbrev
|
1348
|
+
when 'IE'
|
1349
|
+
['1', '2', '2', 'Windows Security']
|
1350
|
+
when 'FF'
|
1351
|
+
['2', '1', '2', 'Authentication Required']
|
1352
|
+
when 'GC', 'C'
|
1353
|
+
['2', '1', '2', 'Authentication Required']
|
1354
|
+
end
|
1355
|
+
end
|
1356
|
+
end
|
1357
|
+
|
1358
|
+
def windows_to_log(browser)
|
1359
|
+
msg = ("===== Current windows (#{where_am_i?(2)})")
|
1360
|
+
idx = 0
|
1361
|
+
browser.windows.each do |w|
|
1362
|
+
msg << "\n #{idx}: #{w.title} current?=#{w.current?}" #" (#{w.url})"
|
1363
|
+
idx += 1
|
1364
|
+
end
|
1365
|
+
debug_to_log(msg)
|
1366
|
+
rescue => e
|
1367
|
+
debug_to_log(unable_to("#{where_am_i?(2)}: #{e.inspect}"))
|
1368
|
+
end
|
1369
|
+
|
1370
|
+
# def where_am_i?(index = 1)
|
1371
|
+
# get_call_list_new[index].to_s
|
1372
|
+
# end
|
1373
|
+
|
1374
|
+
def get_windows_version
|
1375
|
+
ver = `ver`.gsub("\n", '')
|
1376
|
+
mtch = ver.match(/(.*)\s\[Version\s*(\d+)\.(\d+)\.(\d+)\]/)
|
1377
|
+
$win_name = mtch[1]
|
1378
|
+
$win_major = mtch[2]
|
1379
|
+
$win_minor = mtch[3]
|
1380
|
+
$win_build = mtch[4]
|
1381
|
+
$win_version = "#{$win_major}.#{$win_minor}.#{$win_build}"
|
1382
|
+
rescue
|
1383
|
+
failed_to_log(unable_to)
|
1384
|
+
end
|
1385
|
+
|
1386
|
+
def set_env_name(xls = @xls_path, fix = :prefix, strg = 'toad')
|
1387
|
+
if fix == :prefix
|
1388
|
+
pattern = /#{strg}_([\w\d]+)\.xls$/
|
1389
|
+
else
|
1390
|
+
pattern = /([\w\d]+)_#{strg}\.xls$/
|
1391
|
+
end
|
1392
|
+
if awetestlib?
|
1393
|
+
if @runenv
|
1394
|
+
@env_name = @myAppEnv.name.downcase.underscore
|
1395
|
+
else
|
1396
|
+
@env_name = 'dev'
|
1397
|
+
#if xls
|
1398
|
+
# xls =~ pattern
|
1399
|
+
# @env_name = $1
|
1400
|
+
#else
|
1401
|
+
# @env_name = 'sit'
|
1402
|
+
#end
|
1403
|
+
end
|
1404
|
+
else
|
1405
|
+
@env_name = @myAppEnv.name.downcase # .underscore #.gsub(/^toad./, '')
|
1406
|
+
end
|
1407
|
+
debug_to_report("#{__LINE__}: @env_name=#{@env_name}")
|
1408
|
+
rescue
|
1409
|
+
failed_to_log(unable_to)
|
1410
|
+
end
|
1411
|
+
|
1412
|
+
def set_xls_spec(proj_acro = 'unknown', env = @env_name.downcase.underscore, fix = :prefix, xlsx = @xlsx)
|
1413
|
+
env = env.split(/:[\s_]*/)[1] if env =~ /:/
|
1414
|
+
case fix
|
1415
|
+
when :prefix
|
1416
|
+
xls_name = "#{proj_acro}_#{env}.xls"
|
1417
|
+
when :suffix
|
1418
|
+
xls_name = "#{env}_#{proj_acro}.xls"
|
1419
|
+
when :none
|
1420
|
+
xls_name = "#{env.gsub('-', '_')}.xls"
|
1421
|
+
else
|
1422
|
+
failed_to_log(with_caller("Unknown fix type: '#{fix}'. Must be 'prefix', 'suffix', or 'none'."))
|
1423
|
+
return nil
|
1424
|
+
end
|
1425
|
+
spec = "#{@myRoot}/#{xls_name}"
|
1426
|
+
spec << 'x' if xlsx
|
1427
|
+
debug_to_log("#{where_am_i?}: #{spec}")
|
1428
|
+
spec
|
1429
|
+
rescue
|
1430
|
+
failed_to_log(unable_to)
|
1431
|
+
end
|
1432
|
+
|
1433
|
+
def format_refs(list)
|
1434
|
+
refs = ''
|
1435
|
+
if list
|
1436
|
+
list.split(/,\s*/).each do |ref|
|
1437
|
+
refs << "*** #{ref} *** "
|
1438
|
+
end
|
1439
|
+
end
|
1440
|
+
refs
|
1441
|
+
end
|
1442
|
+
|
1443
|
+
def force_regexp(target)
|
1444
|
+
if target.respond_to?(:dup)
|
1445
|
+
rslt = target.dup
|
1446
|
+
unless rslt.is_a?(Regexp)
|
1447
|
+
rslt = Regexp.new(Regexp.escape(target.to_s))
|
1448
|
+
end
|
1449
|
+
else
|
1450
|
+
rslt = target
|
1451
|
+
end
|
1452
|
+
rslt
|
1453
|
+
rescue
|
1454
|
+
failed_to_log(unable_to("'#{target}'"))
|
1455
|
+
end
|
1456
|
+
|
1457
|
+
def force_string(target, slash_regexp = true)
|
1458
|
+
if target
|
1459
|
+
if target.respond_to?(:dup)
|
1460
|
+
rslt = target.dup
|
1461
|
+
if rslt.is_a?(Regexp)
|
1462
|
+
if slash_regexp
|
1463
|
+
rslt = "/#{rslt.source}/"
|
1027
1464
|
else
|
1028
|
-
|
1465
|
+
rslt = rslt.source
|
1029
1466
|
end
|
1030
1467
|
end
|
1468
|
+
else
|
1469
|
+
rslt = target.to_s
|
1470
|
+
end
|
1471
|
+
else
|
1472
|
+
rslt = ''
|
1473
|
+
end
|
1474
|
+
rslt
|
1475
|
+
rescue
|
1476
|
+
failed_to_log(unable_to("'#{target}'"))
|
1477
|
+
end
|
1478
|
+
|
1479
|
+
def array_neighbors(arr, target)
|
1480
|
+
less_than = []
|
1481
|
+
greater_than = []
|
1482
|
+
arr.each do |elmt|
|
1483
|
+
if elmt < target
|
1484
|
+
less_than << elmt
|
1485
|
+
elsif elmt > target
|
1486
|
+
greater_than << elmt
|
1487
|
+
end
|
1488
|
+
end
|
1489
|
+
[less_than.max, greater_than.min]
|
1490
|
+
end
|
1491
|
+
|
1492
|
+
def array_to_list(arr, delim = ',')
|
1493
|
+
list = ''
|
1494
|
+
arr.each do |entry|
|
1495
|
+
if entry =~ /#{delim}/
|
1496
|
+
list << "\"#{entry}\""
|
1497
|
+
else
|
1498
|
+
list << entry
|
1031
1499
|
end
|
1032
|
-
|
1500
|
+
list << "#{delim} " unless entry == arr.last
|
1033
1501
|
end
|
1034
|
-
|
1035
|
-
[arr.length, arr]
|
1502
|
+
list
|
1036
1503
|
end
|
1037
1504
|
|
1505
|
+
alias arr2list array_to_list
|
1506
|
+
|
1038
1507
|
def awetestlib?
|
1039
|
-
|
1508
|
+
defined? Awetestlib::Runner
|
1040
1509
|
rescue
|
1041
1510
|
return false
|
1042
1511
|
end
|
1043
1512
|
|
1044
1513
|
def get_os
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1514
|
+
$os = OpenStruct.new(
|
1515
|
+
:name => Sys::Uname.sysname,
|
1516
|
+
:version => Sys::Uname.version,
|
1517
|
+
:release => Sys::Uname.release,
|
1518
|
+
:nodename => Sys::Uname.nodename,
|
1519
|
+
:machine => Sys::Uname.machine
|
1051
1520
|
)
|
1052
1521
|
end
|
1053
1522
|
|