Best Python code snippet using SeleniumBase
master_qa.py
Source:master_qa.py
...39 if self.check_count == 1:40 print(warn_msg)41 return42 # This is where the magic happens43 self.__manual_page_check(*args)44 def auto_close_results(self):45 ''' If this method is called, the results page will automatically close46 at the end of the test run, rather than waiting on the user to close47 the results page manually.48 '''49 self.auto_close_results_page = True50 def tearDown(self):51 if self.headless and self.check_count > 0:52 print("WARNING: %s manual checks were skipped!" % self.check_count)53 if sys.exc_info()[1]:54 self.__add_failure(sys.exc_info()[1])55 self.__process_manual_check_results(self.auto_close_results_page)56 super(MasterQA, self).tearDown()57 ####################58 def __get_timestamp(self):59 return str(int(time.time() * 1000))60 def __manual_check_setup(self):61 self.manual_check_count = 062 self.manual_check_successes = 063 self.incomplete_runs = 064 self.page_results_list = []65 self.__clear_out_old_logs(archive_past_runs=False)66 def __clear_out_old_logs(67 self, archive_past_runs=True, get_log_folder=False):68 abs_path = os.path.abspath('.')69 file_path = abs_path + "/%s" % self.LATEST_REPORT_DIR70 if not os.path.exists(file_path):71 os.makedirs(file_path)72 if archive_past_runs:73 archive_timestamp = int(time.time())74 if not os.path.exists("%s/../%s/" % (file_path, self.ARCHIVE_DIR)):75 os.makedirs("%s/../%s/" % (file_path, self.ARCHIVE_DIR))76 archive_dir = "%s/../%s/log_%s" % (77 file_path, self.ARCHIVE_DIR, archive_timestamp)78 shutil.move(file_path, archive_dir)79 os.makedirs(file_path)80 if get_log_folder:81 return archive_dir82 else:83 # Just delete bad pages to make room for the latest run.84 filelist = [f for f in os.listdir(85 "./%s" % self.LATEST_REPORT_DIR) if (86 f.startswith("failed_")) or (87 f == self.RESULTS_PAGE) or (88 f.startswith("automation_failure")) or (89 f == self.BAD_PAGE_LOG)]90 for f in filelist:91 os.remove("%s/%s" % (file_path, f))92 def __jq_confirm_dialog(self, question):93 count = self.manual_check_count + 194 title = self.DEFAULT_VALIDATION_TITLE95 title_content = ('<center><font color="#7700bb">%s #%s:'96 '</font></center><hr><font color="#0066ff">%s</font>'97 '' % (title, count, question))98 title_content = js_utils.escape_quotes_if_needed(title_content)99 jqcd = ("""jconfirm({100 boxWidth: '32.5%%',101 useBootstrap: false,102 containerFluid: false,103 animationBounce: 1,104 type: 'default',105 theme: 'bootstrap',106 typeAnimated: true,107 animation: 'scale',108 draggable: true,109 dragWindowGap: 1,110 container: 'body',111 title: '%s',112 content: '',113 buttons: {114 fail_button: {115 btnClass: 'btn-red',116 text: 'NO / FAIL',117 action: function(){118 $jqc_status = "Failure!"119 }120 },121 pass_button: {122 btnClass: 'btn-green',123 text: 'YES / PASS',124 action: function(){125 $jqc_status = "Success!"126 }127 }128 }129 });""" % title_content)130 self.execute_script(jqcd)131 def __manual_page_check(self, *args):132 if not args:133 instructions = self.DEFAULT_VALIDATION_MESSAGE # self.verify()134 else:135 instructions = str(args[0])136 if len(args) > 1:137 pass138 question = "Approve?" # self.verify("")139 if instructions and "?" not in instructions:140 question = instructions + " <> Approve?"141 elif instructions and "?" in instructions:142 question = instructions143 wait_time_before_verify = self.WAIT_TIME_BEFORE_VERIFY144 if self.verify_delay:145 wait_time_before_verify = float(self.verify_delay)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!