awetestlib 0.1.13-x86-mingw32 → 0.1.14-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/awetestlib/logging.rb +17 -3
- data/lib/awetestlib/regression/browser.rb +520 -394
- data/lib/awetestlib/regression/drag_and_drop.rb +15 -0
- data/lib/awetestlib/regression/find.rb +322 -290
- data/lib/awetestlib/regression/legacy.rb +3 -35
- data/lib/awetestlib/regression/page_data.rb +27 -26
- data/lib/awetestlib/regression/runner.rb +3 -1
- data/lib/awetestlib/regression/tables.rb +57 -0
- data/lib/awetestlib/regression/user_input.rb +991 -859
- data/lib/awetestlib/regression/utilities.rb +41 -18
- data/lib/awetestlib/regression/validations.rb +392 -419
- data/lib/awetestlib/regression/waits.rb +59 -66
- data/lib/awetestlib/runner.rb +1 -0
- data/lib/awetestlib.rb +1 -1
- data/lib/version.rb +2 -2
- data/test/create_zoho.rb +1 -0
- data/test/create_zoho_account1.rb +2 -0
- data/test/create_zoho_account2.rb +1 -0
- data/test/zoho_util.rb +8 -6
- metadata +4 -4
@@ -1,83 +1,86 @@
|
|
1
1
|
module Awetestlib
|
2
2
|
module Regression
|
3
|
+
# Methods for waiting until something has happened in the browser or DOM.
|
4
|
+
# sleep_for() is the basic technique. Its disadvantage is that it needs to be set for the longest likely wait time.
|
5
|
+
# The wait methods take advantage of the Watir and Watir Webdriver wait functionality to pause only as long as necessary for
|
6
|
+
# the element in question to be in the state needed.
|
3
7
|
module Waits
|
4
8
|
|
9
|
+
# Sleep for +seconds+ seconds before continuing execution of the script.
|
10
|
+
# A message is logged (but not reported) which, by default, includes a trace showing where in the script the sleep was invoked.
|
11
|
+
# @param [Fixnum] seconds The number of seconds to wait.
|
12
|
+
# @param [Boolean] dbg If true, includes a trace in the message
|
13
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output.
|
5
14
|
def sleep_for(seconds, dbg = true, desc = '')
|
6
|
-
|
7
|
-
msg
|
15
|
+
trace = "\n#{get_debug_list}" if dbg
|
16
|
+
msg = build_message("Sleeping for #{seconds} seconds.", desc, trace)
|
8
17
|
info_to_log(msg)
|
9
18
|
sleep(seconds)
|
10
19
|
end
|
11
20
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def hold_for_text(browser,
|
20
|
-
countdown =
|
21
|
+
# Wait for a specific text to appear in the +browser+.
|
22
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
23
|
+
# @param [String, Regexp] text A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
24
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
25
|
+
# @param [Fixnum] threshold The number of seconds after which a warning is added to the report message.
|
26
|
+
# @param [Fixnum] interval The time between checks that the text exists.
|
27
|
+
# @return [Boolean] Returns true if the text appears before +how_long+ has expired.
|
28
|
+
def hold_for_text(browser, how_long, text, desc = '', threshold = 20, interval = 0.25)
|
29
|
+
countdown = how_long
|
21
30
|
while ((not browser.contains_text(text)) and countdown > 0)
|
22
31
|
sleep(interval)
|
23
32
|
countdown = countdown - interval
|
24
33
|
end
|
25
|
-
if countdown <
|
26
|
-
waittime =
|
27
|
-
|
34
|
+
if countdown < how_long
|
35
|
+
waittime = how_long - countdown
|
36
|
+
passed_to_log("#{__method__} '#{text}' found after #{waittime} second(s) #{desc}")
|
28
37
|
if waittime > threshold
|
29
|
-
|
38
|
+
failed_to_log("#{__method__} '#{text}' took #{waittime} second(s). (threshold: #{threshold} seconds) #{desc}")
|
30
39
|
end
|
31
40
|
true
|
32
41
|
else
|
33
|
-
|
42
|
+
failed_to_log("#{__method__} '#{text}' not found after #{how_long} second(s) #{desc}")
|
34
43
|
false
|
35
44
|
end
|
36
45
|
rescue
|
37
|
-
|
46
|
+
failed_to_log("Unable to #{__method__} '#{text}'. '#{$!}' #{desc}")
|
38
47
|
end
|
39
48
|
|
40
49
|
alias wait_for_text hold_for_text
|
41
50
|
|
42
|
-
#
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
else
|
52
|
-
failed_tolog("wait_for_text '#{text}' not foundafter #{howLong} second(s)")
|
53
|
-
end
|
54
|
-
countdown
|
55
|
-
end
|
56
|
-
|
51
|
+
# Wait while an element identified by attribute +how+ with value +what+ 1) exists, disappears, and exists again.
|
52
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
53
|
+
# @param [Symbol] how The element attribute used to identify the specific element.
|
54
|
+
# Valid values depend on the kind of element.
|
55
|
+
# Common values: :text, :id, :title, :name, :class, :href (:link only)
|
56
|
+
# @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
57
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
58
|
+
# @param [Fixnum] timeout
|
59
|
+
# @return [Boolean] Returns true if disappears and reappears, each within the +timeout+ limit
|
57
60
|
def wait_for_element_to_reappear(browser, how, what, desc = '', timeout = 20)
|
58
61
|
msg = "Element #{how}=#{what} exists. #{desc}"
|
59
62
|
wait_while(browser, "While: #{msg}", timeout) { browser.element(how, what).exists? }
|
60
63
|
wait_until(browser, "Until: #{msg}", timeout) { browser.element(how, what).exists? }
|
61
64
|
end
|
62
65
|
|
63
|
-
#
|
64
|
-
def wait_for_exists(
|
65
|
-
wait_for(
|
66
|
+
# how_long is integer, what_for is a browser object
|
67
|
+
def wait_for_exists(how_long, what_for)
|
68
|
+
wait_for(how_long, what_for)
|
66
69
|
end
|
67
70
|
|
68
|
-
def wait_for(
|
69
|
-
countdown =
|
70
|
-
while ((not
|
71
|
+
def wait_for(how_long, what_for)
|
72
|
+
countdown = how_long
|
73
|
+
while ((not what_for.exists?) and countdown > 0)
|
71
74
|
sleep(1)
|
72
|
-
puts
|
75
|
+
puts what_for.inspect+':'+countdown.to_s
|
73
76
|
countdown = countdown - 1
|
74
77
|
end
|
75
78
|
if countdown
|
76
|
-
puts 'found '+
|
77
|
-
passed_tolog("wait_for (#{
|
79
|
+
puts 'found '+what_for.inspect
|
80
|
+
passed_tolog("wait_for (#{how_long} found "+what_for.inspect)
|
78
81
|
else
|
79
|
-
puts 'Did not find '+
|
80
|
-
failed_tolog("wait_for (#{
|
82
|
+
puts 'Did not find '+what_for.inspect
|
83
|
+
failed_tolog("wait_for (#{how_long} did not find "+what_for.inspect)
|
81
84
|
end
|
82
85
|
countdown
|
83
86
|
end
|
@@ -151,10 +154,8 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
|
|
151
154
|
stop = Time.now.to_f
|
152
155
|
#debug_to_log("#{__method__}: start:#{start} stop:#{stop}")
|
153
156
|
# sleep 1
|
154
|
-
|
155
|
-
|
156
|
-
true
|
157
|
-
end
|
157
|
+
passed_to_log("#{msg} (#{stop - start} seconds)")
|
158
|
+
true
|
158
159
|
rescue
|
159
160
|
failed_to_log("Unable to complete #{msg}: '#{$!}'")
|
160
161
|
end
|
@@ -178,11 +179,9 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
|
|
178
179
|
end
|
179
180
|
stop = Time.now.to_f
|
180
181
|
#debug_to_log("#{__method__}: start:#{start} stop:#{stop} block: #{block.to_s}")
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
true
|
185
|
-
end
|
182
|
+
# sleep 1
|
183
|
+
passed_to_log("#{msg} (#{"%.5f" % (stop - start)} seconds)") # {#{block.to_s}}")
|
184
|
+
true
|
186
185
|
rescue
|
187
186
|
failed_to_log("Unable to complete #{msg}. '#{$!}'")
|
188
187
|
end
|
@@ -205,11 +204,9 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
|
|
205
204
|
end
|
206
205
|
stop = Time.now.to_f
|
207
206
|
#debug_to_log("#{__method__}: start:#{start} stop:#{stop} block: #{block.to_s}")
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
true
|
212
|
-
end
|
207
|
+
# sleep 1
|
208
|
+
passed_to_log("#{msg} (#{"%.5f" % (stop - start)} seconds)") unless skip_pass # {#{block.to_s}}")
|
209
|
+
true
|
213
210
|
rescue
|
214
211
|
failed_to_log("Unable to complete #{msg} '#{$!}'")
|
215
212
|
end
|
@@ -335,10 +332,8 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
|
|
335
332
|
stop = Time.now.to_f
|
336
333
|
#debug_to_log("#{__method__}: start:#{start} stop:#{stop}")
|
337
334
|
# sleep 1
|
338
|
-
|
339
|
-
|
340
|
-
true
|
341
|
-
end
|
335
|
+
passed_to_log("Wait until (#{what} :#{how}=>#{value}) enabled. #{desc} (#{stop - start} seconds)")
|
336
|
+
true
|
342
337
|
rescue
|
343
338
|
failed_to_log("Unable to complete wait until (#{what} :#{how}=>#{value}) enabled. #{desc}: '#{$!}'")
|
344
339
|
end
|
@@ -364,7 +359,7 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
|
|
364
359
|
Watir::Wait.until { browser.text_field(how, what).visible? }
|
365
360
|
else
|
366
361
|
Watir::Wait.until { browser.element(how, what).visible? }
|
367
|
-
|
362
|
+
# raise "#{__method__}: Element #{what} not supported."
|
368
363
|
end
|
369
364
|
rescue => e
|
370
365
|
if e.class.to_s =~ /TimeOutException/
|
@@ -377,10 +372,8 @@ Use this in place of wait_until_by_text when the wait time needs to be longer th
|
|
377
372
|
stop = Time.now.to_f
|
378
373
|
#debug_to_log("#{__method__}: start:#{start} stop:#{stop}")
|
379
374
|
# sleep 1
|
380
|
-
|
381
|
-
|
382
|
-
true
|
383
|
-
end
|
375
|
+
passed_to_log("Wait until (#{element} :#{how}=>#{what}) visible. #{desc} (#{stop - start} seconds)")
|
376
|
+
true
|
384
377
|
rescue
|
385
378
|
failed_to_log("Unable to complete wait until (#{element} :#{how}=>#{what}) visible. #{desc}: '#{$!}'")
|
386
379
|
end
|
data/lib/awetestlib/runner.rb
CHANGED
data/lib/awetestlib.rb
CHANGED
@@ -20,7 +20,7 @@ module Awetestlib
|
|
20
20
|
|
21
21
|
if USING_WINDOWS
|
22
22
|
#require 'win32ole' <-- We'll load this later in Shamisen::AwetestLegacy::Runner. It has to be loaded after watir, see https://www.pivotaltracker.com/story/show/19249981
|
23
|
-
require 'win32/screenshot'
|
23
|
+
require 'win32/screenshot' # triggering segmentation fault 10sep2012 pmn
|
24
24
|
end
|
25
25
|
#require 'active_support/inflector'
|
26
26
|
#require 'active_support/core_ext/object'
|
data/lib/version.rb
CHANGED
data/test/create_zoho.rb
CHANGED
data/test/zoho_util.rb
CHANGED
@@ -35,7 +35,9 @@ module ZohoUtil
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def zoho_login(browser, userid, password, url, validation = 'Welcome joeklienwatir at Software')
|
38
|
-
|
38
|
+
msg = build_message("#{__method__.to_s.titleize}", "userid:'#{userid}",
|
39
|
+
"password:'#{password}", "URL:#{url}")
|
40
|
+
mark_testlevel(msg, 8)
|
39
41
|
set_textfield_by_name(browser, 'lid', userid)
|
40
42
|
set_textfield_by_name(browser, 'pwd', password)
|
41
43
|
click_button_by_value(browser, 'Sign In')
|
@@ -64,7 +66,7 @@ module ZohoUtil
|
|
64
66
|
validate_text(browser, 'Create Account')
|
65
67
|
click_button_by_value(browser, 'Save')
|
66
68
|
sleep(1)
|
67
|
-
close_popup('Message from webpage')
|
69
|
+
close_popup(browser, 'Message from webpage')
|
68
70
|
end
|
69
71
|
|
70
72
|
def export_accounts(browser)
|
@@ -76,7 +78,7 @@ module ZohoUtil
|
|
76
78
|
select_option_by_name_and_option_value(browser, 'module', 'Accounts')
|
77
79
|
if @use_sikuli
|
78
80
|
run_sikuli_script("exportaccounts")
|
79
|
-
close_popup('File Download')
|
81
|
+
close_popup(browser, 'File Download')
|
80
82
|
else
|
81
83
|
#click_button_no_wait_by_value(browser, 'Export')
|
82
84
|
# Make sure popups are allowed by browser
|
@@ -93,12 +95,12 @@ module ZohoUtil
|
|
93
95
|
|
94
96
|
click_button_no_wait_by_value(browser, 'Export')
|
95
97
|
sleep_for(5)
|
96
|
-
close_popup('Message from webpage', 'Are you sure?')
|
98
|
+
close_popup(browser, 'Message from webpage', 'Are you sure?')
|
97
99
|
sleep_for(1)
|
98
100
|
|
99
101
|
click_button_no_wait_by_value(browser, 'Export')
|
100
102
|
sleep_for(3)
|
101
|
-
close_popup('Message from webpage', 'Are you sure?')
|
103
|
+
close_popup(browser, 'Message from webpage', 'Are you sure?')
|
102
104
|
sleep_for(3)
|
103
105
|
|
104
106
|
save_file1(filepath)
|
@@ -277,7 +279,7 @@ module ZohoUtil
|
|
277
279
|
sleep(1)
|
278
280
|
click_button_by_value(browser, 'Delete')
|
279
281
|
sleep(1)
|
280
|
-
close_popup('Message from webpage')
|
282
|
+
close_popup(browser, 'Message from webpage')
|
281
283
|
end
|
282
284
|
|
283
285
|
def find_lead_reports(browser) ## Find Lead Reports by Source
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awetestlib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 14
|
10
|
+
version: 0.1.14
|
11
11
|
platform: x86-mingw32
|
12
12
|
authors:
|
13
13
|
- Anthony Woo
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-09-
|
19
|
+
date: 2012-09-19 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: watir-webdriver
|