MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / append_data_to_logs

Method append_data_to_logs

seleniumbase/fixtures/base_case.py:4725–4745  ·  view source on GitHub ↗

Saves data to the "latest_logs/" folder of the current test. If no file_name, file_name becomes the last data file used in save_data_to_logs() or append_data_to_logs(). If neither method was called before, creates "data_1.txt".

(self, data, file_name=None)

Source from the content-addressed store, hash-verified

4723 page_utils._save_data_as(data, destination_folder, file_name)
4724
4725 def append_data_to_logs(self, data, file_name=None):
4726 """Saves data to the "latest_logs/" folder of the current test.
4727 If no file_name, file_name becomes the last data file used in
4728 save_data_to_logs() or append_data_to_logs().
4729 If neither method was called before, creates "data_1.txt"."""
4730 test_logpath = os.path.join(self.log_path, self.__get_test_id())
4731 self.__create_log_path_as_needed(test_logpath)
4732 if file_name:
4733 file_name = str(file_name)
4734 if (not file_name or len(file_name) == 0) and self.__last_data_file:
4735 file_name = self.__last_data_file
4736 elif not file_name or len(file_name) == 0:
4737 if self.__logs_data_count == 0:
4738 self.__logs_data_count += 1
4739 file_name = "data_%s.txt" % self.__logs_data_count
4740 elif "." not in file_name:
4741 file_name = "%s.txt" % file_name
4742 self.__last_data_file = file_name
4743 sb_config._has_logs = True
4744 destination_folder = test_logpath
4745 page_utils._append_data_to_file(data, destination_folder, file_name)
4746
4747 def save_page_source(self, name, folder=None):
4748 """Saves the page HTML to the current directory (or given subfolder).

Callers

nothing calls this directly

Calls 2

__get_test_idMethod · 0.95

Tested by

no test coverage detected