Best Python code snippet using SeleniumBase
master_qa.py
Source:master_qa.py
...279 self.driver.close()280 self.driver.switch_to_window(self.driver.window_handles[0])281 except Exception:282 pass283 def __add_bad_page_log_file(self):284 abs_path = os.path.abspath('.')285 file_path = abs_path + "/%s" % self.LATEST_REPORT_DIR286 log_file = "%s/%s" % (file_path, self.BAD_PAGE_LOG)287 f = open(log_file, 'w')288 h_p1 = '''"Num","Result","Screenshot","URL","Browser","Epoch Time",'''289 h_p2 = '''"Verification Instructions","Additional Info"\n'''290 page_header = h_p1 + h_p2291 f.write(page_header)292 for line in self.page_results_list:293 f.write("%s\n" % line)294 f.close()295 def __add_results_page(self, html):296 abs_path = os.path.abspath('.')297 file_path = abs_path + "/%s" % self.LATEST_REPORT_DIR298 results_file_name = self.RESULTS_PAGE299 results_file = "%s/%s" % (file_path, results_file_name)300 f = open(results_file, 'w')301 f.write(html)302 f.close()303 return results_file304 def __process_manual_check_results(self, auto_close_results_page=False):305 perfection = True306 failures_count = self.manual_check_count - self.manual_check_successes307 print("\n\n*** Test Result: ***")308 if self.manual_check_successes == self.manual_check_count:309 pass310 else:311 print("WARNING: There were page issues detected!")312 perfection = False313 if self.incomplete_runs > 0:314 print("WARNING: Not all tests finished running!")315 perfection = False316 if perfection:317 if self.manual_check_count > 0:318 print("SUCCESS: Everything checks out OKAY!")319 else:320 print("WARNING: No manual checks were performed!")321 else:322 pass323 self.__add_bad_page_log_file() # Includes successful results324 log_string = self.__clear_out_old_logs(get_log_folder=True)325 log_folder = log_string.split('/')[-1]326 abs_path = os.path.abspath('.')327 file_path = abs_path + "/%s" % self.ARCHIVE_DIR328 log_path = "%s/%s" % (file_path, log_folder)329 web_log_path = "file://%s" % log_path330 tf_color = "#11BB11"331 if failures_count > 0:332 tf_color = "#EE3A3A"333 ir_color = "#11BB11"334 if self.incomplete_runs > 0:335 ir_color = "#EE3A3A"336 summary_table = '''<div><table><thead><tr>337 <th>TESTING SUMMARY</th>...
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!!