def capture_page_screenshot_extension(prefix="", postfix="", add_time_stamp=True, add_test_case_name=True, add_file_path_to_list="${list of screenshots}", output_dir="Artifacts/Screenshots"): output_dir_normalized = validate_create_artifacts_dir(output_dir) if add_time_stamp: current_time = " " + DateTime.get_current_date(result_format="%Y.%m.%d_%H.%M.%S") else: current_time = "" if add_test_case_name: test_case_name = bi().get_variable_value("${TEST_NAME}") else: test_case_name = "" output_file = output_dir_normalized + "/" + prefix + test_case_name + postfix + current_time + ".png" output_file_normalized = os.path.normpath(output_file) # s2l()_current_browser().get_screenshot_as_file(output_file_normalized) s2l().capture_page_screenshot(output_file_normalized) results = bi().run_keyword_and_return_status("Variable Should Exist", add_file_path_to_list) if not results: bi()._get_var_name(add_file_path_to_list) list_with_files = bi().create_list(output_file_normalized) bi().set_test_variable(add_file_path_to_list, list_with_files) else: list_with_files = bi().create_list(output_file_normalized) list_with_files = bi().run_keyword("Combine Lists", add_file_path_to_list, list_with_files) bi().set_test_variable(add_file_path_to_list, list_with_files) return output_file_normalized
def log_variable_to_file(name, comment="", output_file="Artifacts/variables.csv"): log_file = validate_create_artifacts_dir(output_file) logger.debug("Log to file " + log_file) fieldnames = [ 'Time', 'Test Case Name', 'Variable Name', 'Variable Value', 'Comment' ] current_time = DateTime.get_current_date( result_format="%Y.%m.%d %H:%M:%S") test_case_name = str(bi().get_variable_value("${TEST_NAME}")) suite_name = str(bi().get_variable_value("${SUITE_NAME}")) variable_value = name # TODO # get variable name is not working # variable_name = _Variables._get_var_name(bi(),str(name)) # bi().get_variable_value("${" + variable_name + "}", "Missing!!!") with open(log_file, 'a') as csv_file: writer_csv = csv.writer(csv_file, dialect='excel') if os.stat(log_file).st_size < 10: writer_csv.writerow(fieldnames) writer_csv.writerow([ current_time, suite_name + "." + test_case_name, name, variable_value, comment ])
def log_variable_to_file(self, name, comment="", output_file="Artifacts/variables.csv"): log_file = validate_create_artifacts_dir(output_file) logger.debug("Log to file " + log_file) fieldnames = [ "Time", "Test Case Name", "Variable Name", "Variable Value", "Comment", ] current_time = DateTime.get_current_date( result_format="%Y.%m.%d %H:%M:%S") test_case_name = str(bi().get_variable_value("${TEST_NAME}")) suite_name = str(bi().get_variable_value("${SUITE_NAME}")) variable_value = name with open(log_file, "a") as csv_file: writer_csv = csv.writer(csv_file, dialect="excel") if os.stat(log_file).st_size < 10: writer_csv.writerow(fieldnames) writer_csv.writerow([ current_time, suite_name + "." + test_case_name, name, variable_value, comment, ])
def log_variable_to_file(name, comment="", output_file="Artifacts/variables.csv"): log_file = validate_create_artifacts_dir(output_file) logger.debug("Log to file " + log_file) fieldnames = ['Time', 'Test Case Name', 'Variable Name', 'Variable Value', 'Comment'] current_time = DateTime.get_current_date(result_format="%Y.%m.%d %H:%M:%S") test_case_name = str(bi().get_variable_value("${TEST_NAME}")) suite_name = str(bi().get_variable_value("${SUITE_NAME}")) variable_value = name # TODO # get variable name is not working # variable_name = _Variables._get_var_name(bi(),str(name)) # bi().get_variable_value("${" + variable_name + "}", "Missing!!!") with open(log_file, 'ab') as csv_file: writer_csv = csv.writer(csv_file, dialect='excel') if os.stat(log_file).st_size < 10: writer_csv.writerow(fieldnames) writer_csv.writerow([current_time, suite_name + "." + test_case_name, name, variable_value, comment])
def csv_writer_with_time(self, *values): current_time = DateTime.get_current_date( result_format="%Y.%m.%d %H:%M:%S") extra_list = list(values) extra_list.insert(0, current_time) self.csv_writer(*extra_list)
def csv_writer_with_time(self, *values): current_time = DateTime.get_current_date(result_format="%Y.%m.%d %H:%M:%S") extra_list = list(values) extra_list.insert(0, current_time) self.csv_writer(*extra_list)
def get_current_date_time(timeZone='local', increment=0, resultFormat='timestamp', excludeMillis=False): return DateTime.get_current_date(timeZone, increment, resultFormat, excludeMillis)