def _write_to_file(self, html_node: HtmlElement, path): if html_node: try: FileUtils.write_file(path + ".html", html_node.to_string()) self._debug_info("HTML created") except Exception as e: self._print_stack_trace(e)
def create_log_report(self): result: str = str() path: str = self.__report_path + '/' + self.__suite_name + 'ConsoleLogReport.txt' if os.path.exists(self.__report_path + '/' + self.__suite_name + 'ConsoleLogReport.txt'): file_text = FileUtils.read_file(path) result += '' if file_text is None else file_text for test_case_info in self.__test_cases: result += self.get_logs_from_all_threads(test_case_info) if result: FileUtils.write_file(path, result)
def __save_exception_into_file(self, exception: str, __id: str): self.__logger.begin() try: os.makedirs(self.get_report_path() + '/' + AutomationConstants.EXCEPTIONS_FOLDER, exist_ok=True) FileUtils.write_file( self.get_report_path() + '/' + AutomationConstants.EXCEPTIONS_FOLDER + self.get_timestamp() + '.e' + __id + '.txt', exception) except IOError: self.__logger.error('Saving Exception into file') self.__logger.end()
def write_file(file_path: str, text: str): FileUtils.write_file(InteractionObject.get_path_with_resources(file_path), text)