# Subject/Title: LDT-1057 Device Settings - SW - 02 - Export Log - Q&R # # Functionalities: Testing all functionalities of Device Settings Export Log Screen # # Steps: # 1. Export Application log files # - Delete existing files from USB folders # - Start Leahi Application # - Navigate to Device Settings Screen # - Navigate to Export logs Screen # - Click on Export Button to transfer Application files from SD Card to USB # - Compare Export Log Status "Application log export to USB is complete" # - Check if the USB eject button enabled and Click on it # - Close Application # 2. Export Service log files # - Start Leahi Application # - Navigate to Device Settings Screen # - Navigate to Export logs screen # - Click on log type combo box and select a Service log type # - Click on Export Button to transfer Service files from SD Card to USB # - Compare Export In Progress Log Status "Service log export to USB in progress ... " # - Check if the USB eject button enabled and Click on it # - Close Application # 3. Export Service log files # - Delete existing files from USB folders # - Start Leahi Application # - Navigate to Device Settings Screen # - Navigate to Export logs screen # - Selects the first application log file that is currently displayed. # - Click on Export Button to transfer Selected Application file from SD Card to USB # - Compare Export Log Status "Application log export to USB is complete" # - Check if the USB eject button enabled and Click on it # - Close Application import names import os import glob import shutil from configuration import application_init from configuration import config, utility, navigation from leahi_dialin.ui import utils def navigate_to_export_logs(): grid_container = waitForObject(names.o_DeviceSettingsGrid) export_logs_item = utility.findChildByText(grid_container, "Export Logs") if export_logs_item is not None: mouseClick(export_logs_item) export_log_screen_title_text = utility.get_object_from_names( names.o_ExportLogsPageTitleText, error_message="export log screen title text object missing", timeout_ms=1000, ) if export_log_screen_title_text is not None: test.compare( export_log_screen_title_text.text, config.EXPORT_LOG_TEXT, "{} screen is displayed and Comparison of Export Log Screen Title text".format( config.EXPORT_LOG_TEXT ), ) def check_eject_usb_button(is_enabled, is_clicking_button=False): """ For checking enabled/disabled state of the usb eject button """ eject_usb_button = utility.get_object_from_names( names.o_USBEjectButton, error_message="eject usb button object not found", timeout_ms=3000, ) if eject_usb_button is not None: test.compare( eject_usb_button.enabled, is_enabled, f"Check if the USB eject button enabled = {is_enabled}", ) if is_clicking_button: mouseClick(eject_usb_button) def test_export_logs_eject_usb_case(): """ tests the case that the usb is ejected, requires restarting the application to get original state """ mouseClick(waitForObjectExists(names.o_ExportButton)) utils.waitForGUI( 1 ) # This wait is to verify that the Application log export to USB is complete. Increase seconds in waitForGUI if the test compare fails. export_log_status = utility.get_object_from_names( names.o_ExportLogsNotificationBar, error_message="export log status missing", timeout_ms=3000, ) if export_log_status is not None: test.compare( export_log_status.text, config.EXPORT_LOG_STATUS, "Verification Export log status is 'Application log export to USB is complete'".format( config.EXPORT_LOG_STATUS ), ) check_eject_usb_button(config.ENABLED, is_clicking_button=True) def select_different_log_type(whichTypeIndex): log_type_combo_box = utility.get_object_from_names( names.o_LogTypeComboBox, error_message="Combo box object is missing" ) if log_type_combo_box is not None: mouseClick(waitForObjectExists(names.o_LogTypeComboBox)) log_type_option = utility.get_object_from_names( utility.setObjectText(names.o_OptionComboBox, config.EXPORT_LOGS_OPTIONS[whichTypeIndex]), error_message=f"Option {config.EXPORT_LOGS_OPTIONS[whichTypeIndex]} object is missing", timeout_ms=500, ) if log_type_option is not None: mouseClick(log_type_option) combo_box_text = utility.get_object_from_names( names.o_LogTypeComboBox, error_message="unable to select from Combo Box", timeout_ms=1000, ) test.compare( config.EXPORT_LOGS_OPTIONS[whichTypeIndex], combo_box_text.displayText, "User should able to select {} log type".format( config.EXPORT_LOGS_OPTIONS[whichTypeIndex] ), ) export_button = utility.get_object_from_names( names.o_ExportButton, error_message="Export button was not enabled", timeout_ms=2000, ) if export_button is not None: mouseClick(export_button) export_log_progress_status = utility.get_object_from_names( names.o_ExportLogsNotificationBar, error_message="export log progress status missing", timeout_ms=2000, ) if export_log_progress_status is not None: test.compare( export_log_progress_status.text, config.EXPORT_LOG_PROGRESS_STATUS, "Verification Export log status is 'Service log export to USB in progress ...'".format( config.EXPORT_LOG_PROGRESS_STATUS ), ) check_eject_usb_button(config.ENABLED, is_clicking_button=True) return True return False # default return if not successful def select_a_log_file_and_export(): mouseClick(waitForObjectExists(names.o_ExportLogsProgressRect)) mouseClick(waitForObjectExists(names.o_ExportButton)) export_log_status = utility.get_object_from_names( names.o_ExportLogsNotificationBar, error_message="export log status missing", timeout_ms=3000, ) if export_log_status is not None: test.compare( export_log_status.text, config.EXPORT_LOG_STATUS, "Verification Export log status is 'Application log export to USB is complete'".format( config.EXPORT_LOG_STATUS ), ) check_eject_usb_button(config.ENABLED, is_clicking_button=True) test.endSection() def copy_all_files_from_testdata_to_sdcard_service(): # Getting the directory of the currently executing script file script_dir = os.path.dirname(os.path.abspath(__file__)) # Join the script's directory with the testdata subfolder path. source_subfolder = os.path.join(script_dir, "testdata") # Defining the destination directory (OS Desktop sd-card service ) destination_dir = os.path.expanduser("~/Desktop/sd-card/service") # Check if the destination directory exists, and create it if not if not os.path.exists(destination_dir): try: os.makedirs(destination_dir) test.log("Directory created successfully.") except OSError as e: test.log(f"Failed to create destination directory {destination_dir}: {e}") return # Stop execution if folder cannot be created # Find all files in the source_subfolder using '*' files_to_copy = glob.glob(os.path.join(source_subfolder, "*")) if not files_to_copy: test.log(f"No files found in the source directory: {source_subfolder}") return # Using shutil.copy() to copy all files for file_path in files_to_copy: file_name = os.path.basename(file_path) destination_path = os.path.join(destination_dir, file_name) shutil.copy(file_path, destination_path) test.log("Finished processing files from testdata folder.") def main(): utils.tstStart(__file__) application_init.setup_post_log_successful_start() #copy all files from testdata to sdcard service folder copy_all_files_from_testdata_to_sdcard_service() test.startSection("Export Application log files") application_init.delete_existing_files_usb_folders() startApplication(config.AUT_NAME) navigation.navigate_to_device_settings_screen() navigate_to_export_logs() test_export_logs_eject_usb_case() closeWindow(names.o_Gui_MainView) test.endSection() test.startSection("Export Service log files") startApplication(config.AUT_NAME) navigation.navigate_to_device_settings_screen() navigate_to_export_logs() select_different_log_type(1) closeWindow(names.o_Gui_MainView) test.endSection() test.startSection("Export single log file") application_init.delete_existing_files_usb_folders() startApplication(config.AUT_NAME) navigation.navigate_to_device_settings_screen() navigate_to_export_logs() select_a_log_file_and_export() utils.tstDone()