Index: suite_leahi/tst_service_export_logs/test.py =================================================================== diff -u -rb421c6c45a7e2c173565968657a2f76139200c8f -rf7c5babf0cceeac7cacd155523b3fca43ac25a95 --- suite_leahi/tst_service_export_logs/test.py (.../test.py) (revision b421c6c45a7e2c173565968657a2f76139200c8f) +++ suite_leahi/tst_service_export_logs/test.py (.../test.py) (revision f7c5babf0cceeac7cacd155523b3fca43ac25a95) @@ -37,77 +37,21 @@ import glob import shutil -from pathlib import Path -from configuration import application_init as application_init -from configuration import config, utility -from leahi_dialin.ui.td_messaging import TD_Messaging -from leahi_dialin.common.td_defs import TDOpModes, TDStandbyStates -from leahi_dialin.ui import utils +from configuration import application_init +from configuration import config, utility, navigation +from leahi_dialin.ui import utils -td_simulator = TD_Messaging() - -def custom_object_for_export_log(text): - """ - Method to set custom object property for export option - @param text : (string) parameter text - """ - names.o_OptionComboBox["text"] = text - return names.o_OptionComboBox - - -def navigate_to_service_menu(): - """ - Method to navigate to "Service" screen - """ - td_simulator.td_operation_mode( - TDOpModes.MODE_STAN.value, 0 - ) - settings_menu_object = utility.get_object_from_names( - names.o_Settings_Menu, - error_message="Settings menu object missing", - timeout_ms=1000, - ) - if settings_menu_object is not None: - mouseClick(settings_menu_object) - - device_setting_screen_title_text = utility.get_object_from_names( - names.o_DeviceSettingsTitleText, - error_message="Device Settings Screen title text object missing", - timeout_ms=2000, - ) - if device_setting_screen_title_text is not None: - test.compare( - device_setting_screen_title_text.text, - config.DEVICE_SETTINGS_SCREEN_TITLE_TEXT, - "{} screen is displayed and Comparison of Device Settings Screen Title text".format( - config.DEVICE_SETTINGS_SCREEN_TITLE_TEXT - ), - ) - - -def findChildByText(parent_object, target_text): - """Recursively finds a child object by its text property.""" - for child in object.children(parent_object): - if hasattr(child, 'text') and str(child.text) == target_text: - return child - found = findChildByText(child, target_text) - if found: - return found - return None - - def navigate_to_export_logs(): - grid_container = waitForObject(names.o_DeviceSettingsGrid) - export_logs_item = findChildByText(grid_container, "Export Logs") + grid_container = utility.get_object_from_names(names.o_DeviceSettingsGrid) + export_logs_item = utility.findChildByText(grid_container, config.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, + headerbar_container = utility.get_object_from_names(names.o_headerBar_HeaderBar, 2000) + export_log_screen_title_text = utility.findChildByText( + headerbar_container, config.EXPORT_LOG_TEXT ) if export_log_screen_title_text is not None: test.compare( @@ -126,7 +70,6 @@ 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( @@ -142,14 +85,18 @@ """ tests the case that the usb is ejected, requires restarting the application to get original state """ - mouseClick(waitForObjectExists(names.o_ExportButton)) + export_button = utility.get_object_from_names( + names.o_ExportButton, + error_message="Export button was not enabled", + ) + if export_button is not None: + mouseClick(export_button) 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: @@ -165,22 +112,20 @@ 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" + 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( - custom_object_for_export_log( + 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], @@ -189,19 +134,17 @@ 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( @@ -219,12 +162,23 @@ def select_a_log_file_and_export(): - mouseClick(waitForObjectExists(names.o_ExportLogsProgressRect)) - mouseClick(waitForObjectExists(names.o_ExportButton)) + select_a_file = utility.get_object_from_names( + names.o_ExportLogsProgressRect, + error_message="eject o_ExportLogsProgressRect object not found", + ) + if select_a_file is not None: + mouseClick(select_a_file) + + export_button = utility.get_object_from_names( + names.o_ExportButton, + error_message="Export button was not enabled", + ) + if export_button is not None: + mouseClick(export_button) + 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( @@ -284,17 +238,17 @@ test.startSection("Export Application log files") application_init.delete_existing_files_usb_folders() - startApplication(config.AUT_NAME) - navigate_to_service_menu() + startApplication(utility.aut("-q")) + 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) - navigate_to_service_menu() + + startApplication(utility.aut("-q")) + navigation.navigate_to_device_settings_screen() navigate_to_export_logs() select_different_log_type(1) closeWindow(names.o_Gui_MainView) @@ -303,9 +257,9 @@ test.startSection("Export single log file") application_init.delete_existing_files_usb_folders() - startApplication(config.AUT_NAME) - navigate_to_service_menu() + startApplication(utility.aut("-q")) + navigation.navigate_to_device_settings_screen() navigate_to_export_logs() select_a_log_file_and_export() - utils.tstDone() + utils.tstDone() \ No newline at end of file