2121# This tool allows testers to quickly verify pages while assisted by automation
2222
2323
24- class __MasterQATestCase__ (BaseCase ):
24+ class MasterQA (BaseCase ):
2525
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 ):
2764 return str (int (time .time () * 1000 ))
2865
29- def manual_check_setup (self ):
66+ def __manual_check_setup (self ):
3067 self .manual_check_count = 0
3168 self .manual_check_successes = 0
3269 self .incomplete_runs = 0
3370 self .page_results_list = []
34- self .clear_out_old_logs (archive_past_runs = False )
71+ self .__clear_out_old_logs (archive_past_runs = False )
3572
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 ):
3775 abs_path = os .path .abspath ('.' )
3876 file_path = abs_path + "/%s" % LATEST_REPORT_DIR
3977 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):
5896 for f in filelist :
5997 os .remove ("%s/%s" % (file_path , f ))
6098
61- def jq_confirm_dialog (self , question ):
99+ def __jq_confirm_dialog (self , question ):
62100 count = self .manual_check_count + 1
63101 title_content = ('<center><font color="#7700bb">Manual Check #%s:'
64102 '</font></center><hr><font color="#0066ff">%s</font>'
@@ -97,7 +135,7 @@ def jq_confirm_dialog(self, question):
97135 });""" % title_content )
98136 self .execute_script (jqcd )
99137
100- def manual_page_check (self , * args ):
138+ def __manual_page_check (self , * args ):
101139 if not args :
102140 instructions = DEFAULT_VALIDATION_MESSAGE # self.verify()
103141 else :
@@ -133,7 +171,7 @@ def manual_page_check(self, *args):
133171
134172 if use_jqc :
135173 # Use the jquery_confirm library for manual page checks
136- self .jq_confirm_dialog (question )
174+ self .__jq_confirm_dialog (question )
137175 time .sleep (0.02 )
138176 waiting_for_response = True
139177 while waiting_for_response :
@@ -163,7 +201,7 @@ def manual_page_check(self, *args):
163201 {window.master_qa_result="Success!"}
164202 else{window.master_qa_result="Failure!"}''' % question )
165203 time .sleep (0.05 )
166- self .wait_for_special_alert_absent ()
204+ self .__wait_for_special_alert_absent ()
167205 text = self .execute_script ('return window.master_qa_result' )
168206 else :
169207 try :
@@ -175,7 +213,7 @@ def manual_page_check(self, *args):
175213 # Fix for https://github.com/mozilla/geckodriver/issues/431
176214 pass
177215 time .sleep (0.05 )
178- self .wait_for_special_alert_absent ()
216+ self .__wait_for_special_alert_absent ()
179217 text = self .execute_script ('return window.master_qa_result' )
180218 status = text
181219
@@ -193,7 +231,7 @@ def manual_page_check(self, *args):
193231 "-" ,
194232 current_url ,
195233 self .browser ,
196- self .get_timestamp ()[:- 3 ],
234+ self .__get_timestamp ()[:- 3 ],
197235 instructions ,
198236 "*" ))
199237 return 1
@@ -207,12 +245,13 @@ def manual_page_check(self, *args):
207245 bad_page_name ,
208246 current_url ,
209247 self .browser ,
210- self .get_timestamp ()[:- 3 ],
248+ self .__get_timestamp ()[:- 3 ],
211249 instructions ,
212250 "*" ))
213251 return 0
214252
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 ):
216255 for x in range (int (timeout * 20 )):
217256 try :
218257 alert = self .driver .switch_to .alert
@@ -226,7 +265,7 @@ def wait_for_special_alert_absent(self, timeout=MAX_IDLE_TIME_BEFORE_QUIT):
226265 raise Exception (
227266 "%s seconds passed without human action! Stopping..." % timeout )
228267
229- def add_failure (self , exception = None ):
268+ def __add_failure (self , exception = None ):
230269 exc_info = None
231270 if exception :
232271 if hasattr (exception , 'msg' ):
@@ -246,7 +285,7 @@ def add_failure(self, exception=None):
246285 error_page ,
247286 self .driver .current_url ,
248287 self .browser ,
249- self .get_timestamp ()[:- 3 ],
288+ self .__get_timestamp ()[:- 3 ],
250289 "-" ,
251290 exc_info ))
252291 try :
@@ -257,7 +296,7 @@ def add_failure(self, exception=None):
257296 except Exception :
258297 pass
259298
260- def add_bad_page_log_file (self ):
299+ def __add_bad_page_log_file (self ):
261300 abs_path = os .path .abspath ('.' )
262301 file_path = abs_path + "/%s" % LATEST_REPORT_DIR
263302 log_file = "%s/%s" % (file_path , BAD_PAGE_LOG )
@@ -270,7 +309,7 @@ def add_bad_page_log_file(self):
270309 f .write ("%s\n " % line )
271310 f .close ()
272311
273- def add_results_page (self , html ):
312+ def __add_results_page (self , html ):
274313 abs_path = os .path .abspath ('.' )
275314 file_path = abs_path + "/%s" % LATEST_REPORT_DIR
276315 results_file_name = RESULTS_PAGE
@@ -280,7 +319,7 @@ def add_results_page(self, html):
280319 f .close ()
281320 return results_file
282321
283- def process_manual_check_results (self , auto_close_results_page = False ):
322+ def __process_manual_check_results (self , auto_close_results_page = False ):
284323 perfection = True
285324 failures_count = self .manual_check_count - self .manual_check_successes
286325 print ("\n \n *** Test Result: ***" )
@@ -301,9 +340,9 @@ def process_manual_check_results(self, auto_close_results_page=False):
301340 print ("WARNING: No manual checks were performed!" )
302341 else :
303342 pass
304- self .add_bad_page_log_file () # Includes successful results
343+ self .__add_bad_page_log_file () # Includes successful results
305344
306- log_string = self .clear_out_old_logs (get_log_folder = True )
345+ log_string = self .__clear_out_old_logs (get_log_folder = True )
307346 log_folder = log_string .split ('/' )[- 1 ]
308347 abs_path = os .path .abspath ('.' )
309348 file_path = abs_path + "/%s" % ARCHIVE_DIR
@@ -371,7 +410,7 @@ def process_manual_check_results(self, auto_close_results_page=False):
371410 summary_table , log_table , failure_table )
372411 report_html = '<html><head>%s</head><body>%s</body></html>' % (
373412 style , table_view )
374- results_file = self .add_results_page (report_html )
413+ results_file = self .__add_results_page (report_html )
375414 archived_results_file = log_path + '/' + RESULTS_PAGE
376415 shutil .copyfile (results_file , archived_results_file )
377416 print (
@@ -385,41 +424,3 @@ def process_manual_check_results(self, auto_close_results_page=False):
385424 print ("\n *** Close the html report window to continue ***" )
386425 while len (self .driver .window_handles ):
387426 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