awetestlib 0.1.22-x86-mingw32 → 0.1.23-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +7 -0
- data/lib/awetestlib/html_report.rb +15 -44
- data/lib/awetestlib/logging.rb +334 -374
- data/lib/awetestlib/regression/browser.rb +61 -71
- data/lib/awetestlib/regression/drag_and_drop.rb +31 -5
- data/lib/awetestlib/regression/find.rb +21 -139
- data/lib/awetestlib/regression/legacy.rb +1175 -1
- data/lib/awetestlib/regression/runner.rb +10 -6
- data/lib/awetestlib/regression/tables.rb +71 -25
- data/lib/awetestlib/regression/user_input.rb +88 -900
- data/lib/awetestlib/regression/utilities.rb +43 -18
- data/lib/awetestlib/regression/validations.rb +165 -248
- data/lib/awetestlib/regression/waits.rb +180 -94
- data/lib/awetestlib/runner.rb +1 -0
- data/lib/awetestlib.rb +3 -1
- data/lib/version.rb +2 -2
- data/test/create_zoho_account1.rb +1 -1
- data/test/login.xls +0 -0
- data/test/login_1.rb +37 -0
- data/test/login_1a.rb +37 -0
- data/test/login_2.rb +32 -0
- data/test/zoho_exercise.rb +21 -0
- metadata +10 -4
@@ -1,12 +1,14 @@
|
|
1
1
|
module Awetestlib
|
2
2
|
module Regression
|
3
|
-
# Methods for waiting until something has happened in the browser or DOM.
|
3
|
+
# Methods for waiting until something has happened, or waiting while a condition exists, in the browser or DOM.
|
4
4
|
# sleep_for() is the basic technique. Its disadvantage is that it needs to be set for the longest likely wait time.
|
5
5
|
# The wait methods take advantage of the Watir and Watir Webdriver wait functionality to pause only as long as necessary for
|
6
6
|
# the element in question to be in the state needed.
|
7
7
|
module Waits
|
8
8
|
|
9
|
-
#
|
9
|
+
# @!group Core
|
10
|
+
|
11
|
+
# Sleep for *seconds* seconds before continuing execution of the script.
|
10
12
|
# A message is logged (but not reported) which, by default, includes a trace showing where in the script the sleep was invoked.
|
11
13
|
# @param [Fixnum] seconds The number of seconds to wait.
|
12
14
|
# @param [Boolean] dbg If true, includes a trace in the message
|
@@ -18,37 +20,7 @@ module Awetestlib
|
|
18
20
|
sleep(seconds)
|
19
21
|
end
|
20
22
|
|
21
|
-
# Wait
|
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
|
30
|
-
while ((not browser.contains_text(text)) and countdown > 0)
|
31
|
-
sleep(interval)
|
32
|
-
countdown = countdown - interval
|
33
|
-
end
|
34
|
-
if countdown < how_long
|
35
|
-
waittime = how_long - countdown
|
36
|
-
passed_to_log("#{__method__} '#{text}' found after #{waittime} second(s) #{desc}")
|
37
|
-
if waittime > threshold
|
38
|
-
failed_to_log("#{__method__} '#{text}' took #{waittime} second(s). (threshold: #{threshold} seconds) #{desc}")
|
39
|
-
end
|
40
|
-
true
|
41
|
-
else
|
42
|
-
failed_to_log("#{__method__} '#{text}' not found after #{how_long} second(s) #{desc}")
|
43
|
-
false
|
44
|
-
end
|
45
|
-
rescue
|
46
|
-
failed_to_log("Unable to #{__method__} '#{text}'. '#{$!}' #{desc}")
|
47
|
-
end
|
48
|
-
|
49
|
-
alias wait_for_text hold_for_text
|
50
|
-
|
51
|
-
# Wait while an element identified by attribute +how+ with value +what+ 1) exists, disappears, and exists again.
|
23
|
+
# Wait while an element identified by attribute *how* with value *what* 1) exists, disappears, and exists again.
|
52
24
|
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
53
25
|
# @param [Symbol] how The element attribute used to identify the specific element.
|
54
26
|
# Valid values depend on the kind of element.
|
@@ -56,66 +28,30 @@ module Awetestlib
|
|
56
28
|
# @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
57
29
|
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
58
30
|
# @param [Fixnum] timeout
|
59
|
-
# @return [Boolean] Returns true if disappears and reappears, each within the
|
31
|
+
# @return [Boolean] Returns true if disappears and reappears, each within the *timeout* limit
|
60
32
|
def wait_for_element_to_reappear(browser, how, what, desc = '', timeout = 20)
|
61
33
|
msg = "Element #{how}=#{what} exists. #{desc}"
|
62
34
|
wait_while(browser, "While: #{msg}", timeout) { browser.element(how, what).exists? }
|
63
35
|
wait_until(browser, "Until: #{msg}", timeout) { browser.element(how, what).exists? }
|
64
36
|
end
|
65
37
|
|
66
|
-
#
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
78
|
-
if countdown
|
79
|
-
puts 'found '+what_for.inspect
|
80
|
-
passed_tolog("wait_for (#{how_long} found "+what_for.inspect)
|
81
|
-
else
|
82
|
-
puts 'Did not find '+what_for.inspect
|
83
|
-
failed_tolog("wait_for (#{how_long} did not find "+what_for.inspect)
|
84
|
-
end
|
85
|
-
countdown
|
86
|
-
end
|
87
|
-
|
88
|
-
def wait_the_hard_way(browser, how, what, wait = 6, intvl = 0.25)
|
89
|
-
count = (wait / intvl).to_i + 1
|
90
|
-
tally = 0
|
91
|
-
ok = (1 / intvl).to_i + 1
|
92
|
-
debug_to_log("#{__method__}: wait: #{wait} secs; intvl: #{intvl} secs; count; #{count}; thresh: #{ok}")
|
93
|
-
(1..count).each do |x|
|
94
|
-
begin
|
95
|
-
if browser.element(how, what).exists?
|
96
|
-
tally += 1
|
97
|
-
debug_to_log("#{x}: #{(x - 1) * intvl}: #{what} exists.")
|
98
|
-
else
|
99
|
-
tally = 0
|
100
|
-
debug_to_log("#{x}: #{(x - 1) * intvl}: #{what} does not exist.")
|
101
|
-
end
|
102
|
-
rescue
|
103
|
-
tally = 0
|
104
|
-
debug_to_log("#{x}: #{(x - 1) * intvl}: #{what} rescue: #{$!}")
|
105
|
-
end
|
106
|
-
if tally >= ok
|
107
|
-
return true
|
108
|
-
end
|
109
|
-
sleep(intvl)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
38
|
+
# Wait until element of type *element*, identified by attribute *how* with value *what* exists on the page.
|
39
|
+
# Timeout is the default used by watir (60 seconds)
|
40
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
41
|
+
# @param [Symbol] element The kind of element to click. Must be one of the elements recognized by Watir.
|
42
|
+
# Some common values are :link, :button, :image, :div, :span.
|
43
|
+
# @param [Symbol] how The element attribute used to identify the specific element.
|
44
|
+
# Valid values depend on the kind of element.
|
45
|
+
# Common values: :text, :id, :title, :name, :class, :href (:link only)
|
46
|
+
# @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
47
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
48
|
+
# @return [Boolean] True if element exists within timeout limit
|
113
49
|
def wait_until_exists(browser, element, how, what, desc = '')
|
114
|
-
msg = "Wait until (
|
115
|
-
msg << " #{desc}" if desc.length > 0
|
50
|
+
msg = build_message("Wait until (:#{element} :#{how}=>'#{what}') exists.", desc)
|
116
51
|
start = Time.now.to_f
|
117
52
|
# TODO: try Watir::Wait.until { browser.element(how, what).exists? } instead of this (cumbersome) case statement
|
118
53
|
# TODO: above fails on frame
|
54
|
+
Watir::Wait.until { browser.exists? }
|
119
55
|
begin
|
120
56
|
case element
|
121
57
|
when :link
|
@@ -147,7 +83,7 @@ module Awetestlib
|
|
147
83
|
if e.class.to_s =~ /TimeOutException/
|
148
84
|
failed_to_log("#{msg}: '#{$!}'")
|
149
85
|
return false
|
150
|
-
elsif not rescue_me(e, __method__,
|
86
|
+
elsif not rescue_me(e, __method__, rescue_me_command(element, how, what, :exists?), "#{browser.class}")
|
151
87
|
raise e
|
152
88
|
end
|
153
89
|
end
|
@@ -160,10 +96,24 @@ module Awetestlib
|
|
160
96
|
failed_to_log("Unable to complete #{msg}: '#{$!}'")
|
161
97
|
end
|
162
98
|
|
99
|
+
# Wait _while_ expression in *&block* returns true.
|
100
|
+
# @example
|
101
|
+
# wait_while(browser, 'Textfield is enabled.', 10) { browser.text_field(:id, 'this text field').enabled?}
|
102
|
+
#
|
103
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
104
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
105
|
+
# @param [Fixnum] timeout Maximum time to wait, in seconds.
|
106
|
+
# @param [Proc] &block A ruby expression that evaluates to true or false. The expression
|
107
|
+
# is usually a watir or watir-webdriver command like .exists?, enabled?, etc. on a
|
108
|
+
# specific DOM element. Note that *&block* is listed as the last parameter inside the signature
|
109
|
+
# parentheses, but is passed in curly braces outside the signature parentheses in the call. This is
|
110
|
+
# the way Ruby works.
|
111
|
+
# @return [Boolean] True if condition returns false within time limit.
|
163
112
|
def wait_while(browser, desc, timeout = 45, &block)
|
164
113
|
#TODO: Would like to be able to see the block code in the log message instead of the identification
|
165
114
|
msg = "Wait while #{desc}:"
|
166
115
|
start = Time.now.to_f
|
116
|
+
Watir::Wait.until { browser.exists? }
|
167
117
|
begin
|
168
118
|
#Watir::Wait.until(timeout) { block.call(nil) }
|
169
119
|
if block.call(nil)
|
@@ -188,10 +138,17 @@ module Awetestlib
|
|
188
138
|
|
189
139
|
alias wait_while_true wait_while
|
190
140
|
|
141
|
+
# Wait _until_ expression in *&block* returns true.
|
142
|
+
# @example
|
143
|
+
# wait_until(browser, 'Textfield is enabled.', 10) { browser.text_field(:id, 'this text field').exists?}
|
144
|
+
#
|
145
|
+
# @param (see #wait_while)
|
146
|
+
# @return [Boolean] True if condition in *&block* returns true within time limit.
|
191
147
|
def wait_until(browser, desc, timeout = 45, skip_pass = false, &block)
|
192
148
|
#TODO: Would like to be able to see the block code in the log message instead of the identification
|
193
149
|
msg = "Wait until #{desc}"
|
194
150
|
start = Time.now.to_f
|
151
|
+
Watir::Wait.until { browser.exists? }
|
195
152
|
begin
|
196
153
|
Watir::Wait.until(timeout) { block.call(nil) }
|
197
154
|
rescue => e
|
@@ -213,10 +170,18 @@ module Awetestlib
|
|
213
170
|
|
214
171
|
alias wait_until_true wait_until
|
215
172
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
173
|
+
# Wait _until_ element, identified by attribute *how* and its value *what*, exists.
|
174
|
+
# If it exists within *timeout* seconds then wait _until_ it is enabled.
|
175
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
176
|
+
# @param [Symbol] how The element attribute used to identify the specific element.
|
177
|
+
# Valid values depend on the kind of element.
|
178
|
+
# Common values: :text, :id, :title, :name, :class, :href (:link only)
|
179
|
+
# @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
180
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
181
|
+
# @param [Fixnum] timeout Maximum time to wait, in seconds.
|
182
|
+
# @param [Boolean] verbose When set to true, more debug information is written to the log and
|
183
|
+
# all steps return pass/fail messages in the report.
|
184
|
+
# @return [Boolean] True if condition returns false within time limit.
|
220
185
|
def wait_until_ready(browser, how, what, desc = '', timeout = 90, verbose = false)
|
221
186
|
msg = "#{__method__.to_s.titleize}: element: #{how}='#{what}'"
|
222
187
|
msg << " #{desc}" if desc.length > 0
|
@@ -240,6 +205,7 @@ module Awetestlib
|
|
240
205
|
end
|
241
206
|
else
|
242
207
|
start = Time.now.to_f
|
208
|
+
Watir::Wait.until { browser.exists? }
|
243
209
|
if Watir::Wait.until(timeout) { proc_exists.call(nil) }
|
244
210
|
if Watir::Wait.until(timeout) { proc_enabled.call(nil) }
|
245
211
|
stop = Time.now.to_f
|
@@ -257,6 +223,17 @@ module Awetestlib
|
|
257
223
|
failed_to_log("Unable to #{msg}. '#{$!}'")
|
258
224
|
end
|
259
225
|
|
226
|
+
# Wait _until_ element, identified by attribute *how* and its value *what*, exists.
|
227
|
+
# If it exists within *timeout* seconds then wait _until_ it is enabled. Report only failures.
|
228
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
229
|
+
# @param [Symbol] how The element attribute used to identify the specific element.
|
230
|
+
# Valid values depend on the kind of element.
|
231
|
+
# Common values: :text, :id, :title, :name, :class, :href (:link only)
|
232
|
+
# @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
233
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
234
|
+
# @param [Fixnum] timeout Maximum time to wait, in seconds.
|
235
|
+
# @param [Boolean] quiet When set to true, only fail messages are logged and reported.
|
236
|
+
# @return [Boolean] True if condition returns false within time limit.
|
260
237
|
def wait_until_ready_quiet(browser, how, what, desc = '', timeout = 45, quiet = true)
|
261
238
|
msg = "#{__method__.to_s.titleize}: element: #{how}='#{what}'"
|
262
239
|
msg << " #{desc}" if desc.length > 0
|
@@ -268,6 +245,8 @@ module Awetestlib
|
|
268
245
|
proc_enabled = Proc.new { browser.link(how, what).enabled? }
|
269
246
|
end
|
270
247
|
start = Time.now.to_f
|
248
|
+
Watir::Wait.until { browser.exists? }
|
249
|
+
sleep_for(1)
|
271
250
|
if Watir::Wait.until(timeout) { proc_exists.call(nil) }
|
272
251
|
if Watir::Wait.until(timeout) { proc_enabled.call(nil) }
|
273
252
|
stop = Time.now.to_f
|
@@ -293,13 +272,11 @@ module Awetestlib
|
|
293
272
|
|
294
273
|
alias wait_until_by_text wait_until_text
|
295
274
|
|
296
|
-
def wait_until_by_link_text(browser, strg, desc = '')
|
297
|
-
wait_until_exists(browser, :link, :text, strg, desc)
|
298
|
-
end
|
299
|
-
|
300
275
|
def wait_until_enabled(browser, what, how, value, desc = '')
|
301
276
|
# TODO: This can be simplified
|
302
277
|
start = Time.now.to_f
|
278
|
+
Watir::Wait.until { browser.exists? }
|
279
|
+
sleep_for(1)
|
303
280
|
begin
|
304
281
|
case what
|
305
282
|
when :link
|
@@ -319,7 +296,7 @@ module Awetestlib
|
|
319
296
|
when :table
|
320
297
|
Watir::Wait.until { browser.table(how, value).enabled? }
|
321
298
|
else
|
322
|
-
|
299
|
+
Watir::Wait.until { browser.element(how, value).enabled? }
|
323
300
|
end
|
324
301
|
rescue => e
|
325
302
|
if e.class.to_s =~ /TimeOutException/
|
@@ -340,6 +317,8 @@ module Awetestlib
|
|
340
317
|
|
341
318
|
def wait_until_visible(browser, element, how, what, desc = '')
|
342
319
|
start = Time.now.to_f
|
320
|
+
Watir::Wait.until { browser.exists? }
|
321
|
+
sleep_for(1)
|
343
322
|
Watir::Wait.until(20) { browser.element(how, what).exists? }
|
344
323
|
begin
|
345
324
|
case element
|
@@ -365,7 +344,7 @@ module Awetestlib
|
|
365
344
|
if e.class.to_s =~ /TimeOutException/
|
366
345
|
failed_to_log("Wait until (#{what} :#{how}=>#{what}) visible. #{desc}: '#{$!}' #{desc}")
|
367
346
|
return false
|
368
|
-
elsif not rescue_me(e, __method__,
|
347
|
+
elsif not rescue_me(e, __method__, rescue_me_command(element, how, what, :visible?), "#{browser.class}")
|
369
348
|
raise e
|
370
349
|
end
|
371
350
|
end
|
@@ -378,6 +357,113 @@ module Awetestlib
|
|
378
357
|
failed_to_log("Unable to complete wait until (#{element} :#{how}=>#{what}) visible. #{desc}: '#{$!}'")
|
379
358
|
end
|
380
359
|
|
360
|
+
# @!endgroup Core
|
361
|
+
|
362
|
+
# @!group Altenatives
|
363
|
+
|
364
|
+
# Wait for a specific text to appear in the *browser*.
|
365
|
+
# @note This is a last resort method when other wait or wait until avenues have been exhausted.
|
366
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
367
|
+
# @param [String, Regexp] text A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
368
|
+
# @param [String] desc Contains a message or description intended to appear in the log and/or report output
|
369
|
+
# @param [Fixnum] threshold The number of seconds after which a warning is added to the report message.
|
370
|
+
# @param [Fixnum] interval The time between checks that the text exists.
|
371
|
+
# @return [Boolean] Returns true if the text appears before *how_long* has expired.
|
372
|
+
def hold_for_text(browser, how_long, text, desc = '', threshold = 20, interval = 0.25)
|
373
|
+
countdown = how_long
|
374
|
+
Watir::Wait.until { browser.exists? }
|
375
|
+
sleep_for(1)
|
376
|
+
while ((not browser.contains_text(text)) and countdown > 0)
|
377
|
+
sleep(interval)
|
378
|
+
countdown = countdown - interval
|
379
|
+
end
|
380
|
+
if countdown < how_long
|
381
|
+
waittime = how_long - countdown
|
382
|
+
passed_to_log("#{__method__} '#{text}' found after #{waittime} second(s) #{desc}")
|
383
|
+
if waittime > threshold
|
384
|
+
failed_to_log("#{__method__} '#{text}' took #{waittime} second(s). (threshold: #{threshold} seconds) #{desc}")
|
385
|
+
end
|
386
|
+
true
|
387
|
+
else
|
388
|
+
failed_to_log("#{__method__} '#{text}' not found after #{how_long} second(s) #{desc}")
|
389
|
+
false
|
390
|
+
end
|
391
|
+
rescue
|
392
|
+
failed_to_log("Unable to #{__method__} '#{text}'. '#{$!}' #{desc}")
|
393
|
+
end
|
394
|
+
|
395
|
+
alias wait_for_text hold_for_text
|
396
|
+
|
397
|
+
# Wait up to *how_long* seconds for DOM element *what_for* to exist in the page.
|
398
|
+
# @note This is a last resort method when other wait or wait until avenues have been exhausted.
|
399
|
+
# @param [Fixnum] how_long Timeout limit
|
400
|
+
# @param [Watir::Element] what_for A reference to a Dom element to wait for.
|
401
|
+
def wait_for_exists(how_long, what_for)
|
402
|
+
wait_for(how_long, what_for)
|
403
|
+
end
|
404
|
+
|
405
|
+
# Wait up to *how_long* seconds for DOM element *what_for* to exist in the page.
|
406
|
+
# @note This is a last resort method when other wait or wait until avenues have
|
407
|
+
# been exhausted.
|
408
|
+
# @param [Fixnum] how_long Timeout limit
|
409
|
+
# @param [Watir::Element] what_for A reference to a Dom element to wait for.
|
410
|
+
def wait_for(how_long, what_for, interval = 0.25)
|
411
|
+
countdown = how_long
|
412
|
+
while ((not what_for.exists?) and countdown > 0)
|
413
|
+
sleep(interval)
|
414
|
+
puts what_for.inspect+':'+countdown.to_s
|
415
|
+
countdown = countdown - interval
|
416
|
+
end
|
417
|
+
if countdown
|
418
|
+
puts 'found '+what_for.inspect
|
419
|
+
passed_tolog("wait_for (#{how_long} found "+what_for.inspect)
|
420
|
+
else
|
421
|
+
puts 'Did not find '+what_for.inspect
|
422
|
+
failed_tolog("wait_for (#{how_long} did not find "+what_for.inspect)
|
423
|
+
end
|
424
|
+
countdown
|
425
|
+
end
|
426
|
+
|
427
|
+
# Wait up to *how_long* seconds for DOM element identified by attribute *how* and its value
|
428
|
+
# *what* to exist in the page.
|
429
|
+
# @note This is a last resort method when other wait or wait until avenues have been exhausted.
|
430
|
+
# @param [Watir::Browser] browser A reference to the browser window or container element to be tested.
|
431
|
+
# @param [Symbol] how The element attribute used to identify the specific element.
|
432
|
+
# Valid values depend on the kind of element.
|
433
|
+
# Common values: :text, :id, :title, :name, :class, :href (:link only)
|
434
|
+
# @param [String, Regexp] what A string or a regular expression to be found in the *how* attribute that uniquely identifies the element.
|
435
|
+
# @param [Fixnum] wait Timeout limit.
|
436
|
+
# @param [Fixnum] interval How long to wait before checking again.
|
437
|
+
# @return [Boolean] True if element exists within *wait* time
|
438
|
+
def wait_the_hard_way(browser, how, what, wait = 6, interval = 0.25)
|
439
|
+
count = (wait / interval).to_i + 1
|
440
|
+
tally = 0
|
441
|
+
ok = (1 / interval).to_i + 1
|
442
|
+
debug_to_log("#{__method__}: wait: #{wait} secs; interval: #{interval} secs; count; #{count}; thresh: #{ok}")
|
443
|
+
Watir::Wait.until { browser.exists? }
|
444
|
+
sleep_for(1)
|
445
|
+
(1..count).each do |x|
|
446
|
+
begin
|
447
|
+
if browser.element(how, what).exists?
|
448
|
+
tally += 1
|
449
|
+
debug_to_log("#{x}: #{(x - 1) * interval}: #{what} exists.")
|
450
|
+
else
|
451
|
+
tally = 0
|
452
|
+
debug_to_log("#{x}: #{(x - 1) * interval}: #{what} does not exist.")
|
453
|
+
end
|
454
|
+
rescue
|
455
|
+
tally = 0
|
456
|
+
debug_to_log("#{x}: #{(x - 1) * interval}: #{what} rescue: #{$!}")
|
457
|
+
end
|
458
|
+
if tally >= ok
|
459
|
+
return true
|
460
|
+
end
|
461
|
+
sleep(interval)
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
# @!endgroup Alternatives
|
466
|
+
|
381
467
|
end
|
382
468
|
end
|
383
469
|
end
|
data/lib/awetestlib/runner.rb
CHANGED
data/lib/awetestlib.rb
CHANGED
@@ -5,6 +5,7 @@ module Awetestlib
|
|
5
5
|
::USING_WINDOWS = !!((RUBY_PLATFORM =~ /(win|w)(32|64)$/) || (RUBY_PLATFORM=~ /mswin|mingw/))
|
6
6
|
::USING_OSX = RUBY_PLATFORM =~ /darwin/
|
7
7
|
|
8
|
+
# @private
|
8
9
|
BROWSER_MAP = {
|
9
10
|
'FF' => 'Firefox',
|
10
11
|
'IE' => 'Internet Explorer',
|
@@ -13,6 +14,7 @@ module Awetestlib
|
|
13
14
|
'C' => 'Chrome'
|
14
15
|
}
|
15
16
|
|
17
|
+
# @private
|
16
18
|
BROWSER_ALTERNATES = {
|
17
19
|
'OSX' => { 'IE' => 'S' },
|
18
20
|
'Windows' => { 'S' => 'IE' }
|
@@ -20,7 +22,7 @@ module Awetestlib
|
|
20
22
|
|
21
23
|
if USING_WINDOWS
|
22
24
|
#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' # triggering segmentation fault 10sep2012 pmn
|
25
|
+
#require 'win32/screenshot' # triggering segmentation fault 10sep2012 pmn
|
24
26
|
end
|
25
27
|
#require 'active_support/inflector'
|
26
28
|
#require 'active_support/core_ext/object'
|
data/lib/version.rb
CHANGED
@@ -28,7 +28,7 @@ module CreateZohoAccount1
|
|
28
28
|
def create_account(browser)
|
29
29
|
mark_testlevel('Create New Account', 1)
|
30
30
|
sleep_for(3)
|
31
|
-
|
31
|
+
click(browser, :link, :text, 'New Account')
|
32
32
|
wait_until_ready(browser, :name, /Account Name/)
|
33
33
|
set_textfield_by_name(browser, /Account Name/, "Test Account #1")
|
34
34
|
set_textfield_by_name(browser, /Phone/, "415-333-2311")
|
data/test/login.xls
ADDED
Binary file
|
data/test/login_1.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module Login1
|
2
|
+
|
3
|
+
def run
|
4
|
+
|
5
|
+
browser = open_browser
|
6
|
+
|
7
|
+
go_to_url(browser, 'www.yahoo.com')
|
8
|
+
wait_until_exists(browser, :link, :text, 'Sign In')
|
9
|
+
click(browser, :link, :text, 'Sign In')
|
10
|
+
wait_until_exists(browser, :text_field, :id, 'username')
|
11
|
+
set_textfield(browser, :id, 'username', 'awetesta@yahoo.com')
|
12
|
+
set_textfield(browser, :id, 'passwd', 'awetest001')
|
13
|
+
#wait_until_exists(browser, :button, :text, 'Sign In')
|
14
|
+
click(browser, :button, :text, 'Sign In')
|
15
|
+
sleep_for(8)
|
16
|
+
wait_until_text(browser, 'HI, A')
|
17
|
+
sleep_for(3)
|
18
|
+
click(browser, :link, :text, 'Sign Out')
|
19
|
+
|
20
|
+
go_to_url(browser, 'www.yahoo.com')
|
21
|
+
wait_until_exists(browser, :link, :text, 'Sign In')
|
22
|
+
click(browser, :link, :text, 'Sign In')
|
23
|
+
wait_until_exists(browser, :text_field, :id, 'username')
|
24
|
+
set_textfield(browser, :id, 'username', 'awetestt3@yahoo.com')
|
25
|
+
set_textfield(browser, :id, 'passwd', 'awetest001')
|
26
|
+
#wait_until_exists(browser, :button, :text, 'Sign In')
|
27
|
+
click(browser, :button, :text, 'Sign In')
|
28
|
+
sleep_for(8)
|
29
|
+
wait_until_text(browser, 'HI, T-THREE')
|
30
|
+
sleep_for(3)
|
31
|
+
click(browser, :link, :text, 'Sign Out')
|
32
|
+
|
33
|
+
browser.close
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/test/login_1a.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module Login1a
|
2
|
+
|
3
|
+
def run
|
4
|
+
|
5
|
+
browser = open_browser
|
6
|
+
|
7
|
+
go_to_url(browser, 'www.yahoo.com')
|
8
|
+
sleep(5)
|
9
|
+
click(browser, :link, :text, 'Sign In')
|
10
|
+
sleep(5)
|
11
|
+
set_textfield(browser, :id, 'username', 'awetesta@yahoo.com')
|
12
|
+
set_textfield(browser, :id, 'passwd', 'awetest001')
|
13
|
+
click(browser, :button, :text, 'Sign In')
|
14
|
+
sleep(8)
|
15
|
+
validate_text(browser, 'HI, A')
|
16
|
+
sleep(8)
|
17
|
+
click(browser, :link, :text, 'Sign Out')
|
18
|
+
|
19
|
+
sleep(8)
|
20
|
+
|
21
|
+
go_to_url(browser, 'www.yahoo.com')
|
22
|
+
sleep(5)
|
23
|
+
click(browser, :link, :text, 'Sign In')
|
24
|
+
sleep(5)
|
25
|
+
set_textfield(browser, :id, 'username', 'awetestt3@yahoo.com')
|
26
|
+
set_textfield(browser, :id, 'passwd', 'awetest001')
|
27
|
+
click(browser, :button, :text, 'Sign In')
|
28
|
+
sleep(8)
|
29
|
+
validate_text(browser, 'HI, T-THREE')
|
30
|
+
sleep(8)
|
31
|
+
click(browser, :link, :text, 'Sign Out')
|
32
|
+
|
33
|
+
browser.close
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/test/login_2.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
module Login2
|
2
|
+
|
3
|
+
def run
|
4
|
+
|
5
|
+
if @xls_path
|
6
|
+
|
7
|
+
get_variables(@xls_path, :userid)
|
8
|
+
|
9
|
+
login_url = "https://accounts.zoho.com/login?serviceurl=https://www.zoho.com/&hide_signup=true&css=https://www.zoho.com/css/login.css"
|
10
|
+
|
11
|
+
browser = open_browser
|
12
|
+
|
13
|
+
@login.each_key do |key|
|
14
|
+
if @login[key]['enabled'] == 'Y'
|
15
|
+
userid = key
|
16
|
+
password = @login[key]['password']
|
17
|
+
name = @login[key][name]
|
18
|
+
|
19
|
+
go_to_url(browser, login_url)
|
20
|
+
set_textfield(browser, :name, 'lid', userid)
|
21
|
+
set_textfield(browser, :name, 'pwd', password)
|
22
|
+
click(browser, :button, :value, 'Sign In')
|
23
|
+
go_to_url(browser, 'https://crm.zoho.com/crm/ShowHomePage.do')
|
24
|
+
validate_text(browser, "Welcome #{name} at Software")
|
25
|
+
click_link(browser, :text, 'sign out')
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module ZohoExercise
|
2
|
+
$watir_script = true
|
3
|
+
|
4
|
+
def run
|
5
|
+
browser = open_browser
|
6
|
+
go_to_url(browser, 'http://crm.zoho.com/crm/login.sas')
|
7
|
+
sleep_for(2)
|
8
|
+
logon_to_zoho(browser)
|
9
|
+
logout(browser)
|
10
|
+
end
|
11
|
+
|
12
|
+
def logon_to_zoho(browser)
|
13
|
+
mark_testlevel("#{__method__.to_s.humanize}", 8)
|
14
|
+
click(browser, :link, :text, 'Sign In')
|
15
|
+
sleep_for(2)
|
16
|
+
frame = get_frame(browser, :id, 'zohoiam')
|
17
|
+
set_text_field(frame, :id, 'lid', 'joeklienwatir@gmail.com')
|
18
|
+
set_text_field(frame, :name, 'pwd', 'watir001')
|
19
|
+
sleep(1)
|
20
|
+
end
|
21
|
+
end
|
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: 53
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 23
|
10
|
+
version: 0.1.23
|
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-11-
|
19
|
+
date: 2012-11-15 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: watir-webdriver
|
@@ -309,6 +309,7 @@ extra_rdoc_files: []
|
|
309
309
|
files:
|
310
310
|
- .gitattributes
|
311
311
|
- .gitignore
|
312
|
+
- .yardopts
|
312
313
|
- AwetestLib Instructions.rtf
|
313
314
|
- README.md
|
314
315
|
- awetestlib.gemspec
|
@@ -389,6 +390,11 @@ files:
|
|
389
390
|
- test/demo.rb
|
390
391
|
- test/google_search1.rb
|
391
392
|
- test/google_search2.rb
|
393
|
+
- test/login.xls
|
394
|
+
- test/login_1.rb
|
395
|
+
- test/login_1a.rb
|
396
|
+
- test/login_2.rb
|
397
|
+
- test/zoho_exercise.rb
|
392
398
|
- test/zoho_util.rb
|
393
399
|
- test/zoho_variables.xls
|
394
400
|
- tmp/placeholder.html
|