21
21
# This tool allows testers to quickly verify pages while assisted by automation
22
22
23
23
24
- class __MasterQATestCase__ (BaseCase ):
24
+ class MasterQA (BaseCase ):
25
25
26
- def get_timestamp (self ):
26
+ def setUp (self ):
27
+ self .check_count = 0
28
+ self .auto_close_results_page = False
29
+ super (MasterQA , self ).setUp (masterqa_mode = True )
30
+ self .__manual_check_setup ()
31
+ if self .headless :
32
+ self .auto_close_results_page = True
33
+ if START_IN_FULL_SCREEN_MODE :
34
+ self .maximize_window ()
35
+
36
+ def verify (self , * args ):
37
+ warn_msg = "\n WARNING: MasterQA skips manual checks in headless mode!"
38
+ self .check_count += 1
39
+ if self .headless :
40
+ if self .check_count == 1 :
41
+ print (warn_msg )
42
+ return
43
+ # This is where the magic happens
44
+ self .__manual_page_check (* args )
45
+
46
+ def auto_close_results (self ):
47
+ ''' If this method is called, the results page will automatically close
48
+ at the end of the test run, rather than waiting on the user to close
49
+ the results page manually.
50
+ '''
51
+ self .auto_close_results_page = True
52
+
53
+ def tearDown (self ):
54
+ if self .headless and self .check_count > 0 :
55
+ print ("WARNING: %s manual checks were skipped!" % self .check_count )
56
+ if sys .exc_info ()[1 ]:
57
+ self .__add_failure (sys .exc_info ()[1 ])
58
+ self .__process_manual_check_results (self .auto_close_results_page )
59
+ super (MasterQA , self ).tearDown ()
60
+
61
+ ####################
62
+
63
+ def __get_timestamp (self ):
27
64
return str (int (time .time () * 1000 ))
28
65
29
- def manual_check_setup (self ):
66
+ def __manual_check_setup (self ):
30
67
self .manual_check_count = 0
31
68
self .manual_check_successes = 0
32
69
self .incomplete_runs = 0
33
70
self .page_results_list = []
34
- self .clear_out_old_logs (archive_past_runs = False )
71
+ self .__clear_out_old_logs (archive_past_runs = False )
35
72
36
- def clear_out_old_logs (self , archive_past_runs = True , get_log_folder = False ):
73
+ def __clear_out_old_logs (
74
+ self , archive_past_runs = True , get_log_folder = False ):
37
75
abs_path = os .path .abspath ('.' )
38
76
file_path = abs_path + "/%s" % LATEST_REPORT_DIR
39
77
if not os .path .exists (file_path ):
@@ -58,7 +96,7 @@ def clear_out_old_logs(self, archive_past_runs=True, get_log_folder=False):
58
96
for f in filelist :
59
97
os .remove ("%s/%s" % (file_path , f ))
60
98
61
- def jq_confirm_dialog (self , question ):
99
+ def __jq_confirm_dialog (self , question ):
62
100
count = self .manual_check_count + 1
63
101
title_content = ('<center><font color="#7700bb">Manual Check #%s:'
64
102
'</font></center><hr><font color="#0066ff">%s</font>'
@@ -97,7 +135,7 @@ def jq_confirm_dialog(self, question):
97
135
});""" % title_content )
98
136
self .execute_script (jqcd )
99
137
100
- def manual_page_check (self , * args ):
138
+ def __manual_page_check (self , * args ):
101
139
if not args :
102
140
instructions = DEFAULT_VALIDATION_MESSAGE # self.verify()
103
141
else :
@@ -133,7 +171,7 @@ def manual_page_check(self, *args):
133
171
134
172
if use_jqc :
135
173
# Use the jquery_confirm library for manual page checks
136
- self .jq_confirm_dialog (question )
174
+ self .__jq_confirm_dialog (question )
137
175
time .sleep (0.02 )
138
176
waiting_for_response = True
139
177
while waiting_for_response :
@@ -163,7 +201,7 @@ def manual_page_check(self, *args):
163
201
{window.master_qa_result="Success!"}
164
202
else{window.master_qa_result="Failure!"}''' % question )
165
203
time .sleep (0.05 )
166
- self .wait_for_special_alert_absent ()
204
+ self .__wait_for_special_alert_absent ()
167
205
text = self .execute_script ('return window.master_qa_result' )
168
206
else :
169
207
try :
@@ -175,7 +213,7 @@ def manual_page_check(self, *args):
175
213
# Fix for https://github.com/mozilla/geckodriver/issues/431
176
214
pass
177
215
time .sleep (0.05 )
178
- self .wait_for_special_alert_absent ()
216
+ self .__wait_for_special_alert_absent ()
179
217
text = self .execute_script ('return window.master_qa_result' )
180
218
status = text
181
219
@@ -193,7 +231,7 @@ def manual_page_check(self, *args):
193
231
"-" ,
194
232
current_url ,
195
233
self .browser ,
196
- self .get_timestamp ()[:- 3 ],
234
+ self .__get_timestamp ()[:- 3 ],
197
235
instructions ,
198
236
"*" ))
199
237
return 1
@@ -207,12 +245,13 @@ def manual_page_check(self, *args):
207
245
bad_page_name ,
208
246
current_url ,
209
247
self .browser ,
210
- self .get_timestamp ()[:- 3 ],
248
+ self .__get_timestamp ()[:- 3 ],
211
249
instructions ,
212
250
"*" ))
213
251
return 0
214
252
215
- def wait_for_special_alert_absent (self , timeout = MAX_IDLE_TIME_BEFORE_QUIT ):
253
+ def __wait_for_special_alert_absent (
254
+ self , timeout = MAX_IDLE_TIME_BEFORE_QUIT ):
216
255
for x in range (int (timeout * 20 )):
217
256
try :
218
257
alert = self .driver .switch_to .alert
@@ -226,7 +265,7 @@ def wait_for_special_alert_absent(self, timeout=MAX_IDLE_TIME_BEFORE_QUIT):
226
265
raise Exception (
227
266
"%s seconds passed without human action! Stopping..." % timeout )
228
267
229
- def add_failure (self , exception = None ):
268
+ def __add_failure (self , exception = None ):
230
269
exc_info = None
231
270
if exception :
232
271
if hasattr (exception , 'msg' ):
@@ -246,7 +285,7 @@ def add_failure(self, exception=None):
246
285
error_page ,
247
286
self .driver .current_url ,
248
287
self .browser ,
249
- self .get_timestamp ()[:- 3 ],
288
+ self .__get_timestamp ()[:- 3 ],
250
289
"-" ,
251
290
exc_info ))
252
291
try :
@@ -257,7 +296,7 @@ def add_failure(self, exception=None):
257
296
except Exception :
258
297
pass
259
298
260
- def add_bad_page_log_file (self ):
299
+ def __add_bad_page_log_file (self ):
261
300
abs_path = os .path .abspath ('.' )
262
301
file_path = abs_path + "/%s" % LATEST_REPORT_DIR
263
302
log_file = "%s/%s" % (file_path , BAD_PAGE_LOG )
@@ -270,7 +309,7 @@ def add_bad_page_log_file(self):
270
309
f .write ("%s\n " % line )
271
310
f .close ()
272
311
273
- def add_results_page (self , html ):
312
+ def __add_results_page (self , html ):
274
313
abs_path = os .path .abspath ('.' )
275
314
file_path = abs_path + "/%s" % LATEST_REPORT_DIR
276
315
results_file_name = RESULTS_PAGE
@@ -280,7 +319,7 @@ def add_results_page(self, html):
280
319
f .close ()
281
320
return results_file
282
321
283
- def process_manual_check_results (self , auto_close_results_page = False ):
322
+ def __process_manual_check_results (self , auto_close_results_page = False ):
284
323
perfection = True
285
324
failures_count = self .manual_check_count - self .manual_check_successes
286
325
print ("\n \n *** Test Result: ***" )
@@ -301,9 +340,9 @@ def process_manual_check_results(self, auto_close_results_page=False):
301
340
print ("WARNING: No manual checks were performed!" )
302
341
else :
303
342
pass
304
- self .add_bad_page_log_file () # Includes successful results
343
+ self .__add_bad_page_log_file () # Includes successful results
305
344
306
- log_string = self .clear_out_old_logs (get_log_folder = True )
345
+ log_string = self .__clear_out_old_logs (get_log_folder = True )
307
346
log_folder = log_string .split ('/' )[- 1 ]
308
347
abs_path = os .path .abspath ('.' )
309
348
file_path = abs_path + "/%s" % ARCHIVE_DIR
@@ -371,7 +410,7 @@ def process_manual_check_results(self, auto_close_results_page=False):
371
410
summary_table , log_table , failure_table )
372
411
report_html = '<html><head>%s</head><body>%s</body></html>' % (
373
412
style , table_view )
374
- results_file = self .add_results_page (report_html )
413
+ results_file = self .__add_results_page (report_html )
375
414
archived_results_file = log_path + '/' + RESULTS_PAGE
376
415
shutil .copyfile (results_file , archived_results_file )
377
416
print (
@@ -385,41 +424,3 @@ def process_manual_check_results(self, auto_close_results_page=False):
385
424
print ("\n *** Close the html report window to continue ***" )
386
425
while len (self .driver .window_handles ):
387
426
time .sleep (0.1 )
388
-
389
-
390
- class MasterQA (__MasterQATestCase__ ):
391
-
392
- def setUp (self ):
393
- self .check_count = 0
394
- self .auto_close_results_page = False
395
- super (__MasterQATestCase__ , self ).setUp (masterqa_mode = True )
396
- self .manual_check_setup ()
397
- if self .headless :
398
- self .auto_close_results_page = True
399
- if START_IN_FULL_SCREEN_MODE :
400
- self .maximize_window ()
401
-
402
- def verify (self , * args ):
403
- warn_msg = "\n WARNING: MasterQA skips manual checks in headless mode!"
404
- self .check_count += 1
405
- if self .headless :
406
- if self .check_count == 1 :
407
- print (warn_msg )
408
- return
409
- # This is where the magic happens
410
- self .manual_page_check (* args )
411
-
412
- def auto_close_results (self ):
413
- ''' If this method is called, the results page will automatically close
414
- at the end of the test run, rather than waiting on the user to close
415
- the results page manually.
416
- '''
417
- self .auto_close_results_page = True
418
-
419
- def tearDown (self ):
420
- if self .headless and self .check_count > 0 :
421
- print ("WARNING: %s manual checks were skipped!" % self .check_count )
422
- if sys .exc_info ()[1 ]:
423
- self .add_failure (sys .exc_info ()[1 ])
424
- self .process_manual_check_results (self .auto_close_results_page )
425
- super (__MasterQATestCase__ , self ).tearDown ()
0 commit comments