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

Method save_data_to_logs

seleniumbase/fixtures/base_case.py:4704–4723  ·  view source on GitHub ↗

Saves data to the "latest_logs/" data folder of the current test. If no file_name, file_name becomes: "data_1.txt", "data_2.txt", etc. Useful variables for getting the "latest_logs/" or test data folders: self.log_path OR self.log_abspath (For the top-level folder)

(self, data, file_name=None)

Source from the content-addressed store, hash-verified

4702 return page_actions.save_page_source(self.driver, name, test_logpath)
4703
4704 def save_data_to_logs(self, data, file_name=None):
4705 """Saves data to the "latest_logs/" data folder of the current test.
4706 If no file_name, file_name becomes: "data_1.txt", "data_2.txt", etc.
4707 Useful variables for getting the "latest_logs/" or test data folders:
4708 self.log_path OR self.log_abspath (For the top-level folder)
4709 self.data_path OR self.data_abspath (Individual test folders)
4710 If a file_name is given with no extension, adds ".txt" to the end."""
4711 test_logpath = os.path.join(self.log_path, self.__get_test_id())
4712 self.__create_log_path_as_needed(test_logpath)
4713 if file_name:
4714 file_name = str(file_name)
4715 if not file_name or len(file_name) == 0:
4716 self.__logs_data_count += 1
4717 file_name = "data_%s.txt" % self.__logs_data_count
4718 elif "." not in file_name:
4719 file_name = "%s.txt" % file_name
4720 self.__last_data_file = file_name
4721 sb_config._has_logs = True
4722 destination_folder = test_logpath
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.

Callers

nothing calls this directly

Calls 2

__get_test_idMethod · 0.95

Tested by

no test coverage detected