# Subject/Title: Service - SW - 02 - Service - Q&R # # Functionalities: Testing items of Service Screen # # Steps: # 1 Start Leahi Application with Argument to navigate to Manufacturing Screen, # simulate TD Service mode, and In Manufacture screen Reset Password # 2 Start Leahi Application and Simulate TD Service mode, Compare Device Settings # title text, navigate to the Screen screen and Compare Service Screen title and # Enter Password and Click conform Then Navigate to User Mode Screen and # Toggle the user mode, Verify Switch state and Click Back Button # 3 Navigate to Date and Time Screen and verify and compare Title bar text # And Verify the parameter under Date and Time screen, Toggle the NTP mode switch # Button and Verify Switch state, Click Back Button # 4 Navigate to Enable Root SSH Screen and verify and compare Title bar text # And Verify the parameter under Enable Root SSH screen and Click Back Button # 5 Navigate to Factory Reset Screen and verify and compare Title bar text # And Verify the parameter under Factory Reset screen and Click Conform button # for factory reset then Click Cancel on Popup. Again Click conform on Factory Reset # then Click conform on Popup and Click Back Button import names from configuration import config, utility, navigation from leahi_dialin.ui import utils from leahi_dialin.ui.td_messaging import TD_Messaging from leahi_dialin.common.td_defs import TDOpModes, TDStandbyStates td_simulator = TD_Messaging() def manufacture_login(): """ Method to navigate to "Manufacture Login" screen """ test.startSection("Navigating to 'Manufacture Login' menu") test_password_requirements_in_loop("a1b@C3d*E", False, "Missing 10 character (9 chars)") test_password_requirements_in_loop("noupper1@3", False, "Missing Upper Case") test_password_requirements_in_loop("NOLOWER1@3", False, "Missing Lower Case") test_password_requirements_in_loop("NoDigits!@", False, "Missing Digits") test_password_requirements_in_loop("NoSymbols123", False, "Missing Symbols") container = waitForObject(names.o_UserConfirmation_SettingsServicePassword) # Find all TextInput objects that share the id "_input" password_inputs = utility.findAllObjectsById(container, "_input") # Use enumerate to track the index (0, 1, 2) for index, input_field in enumerate(password_inputs): if index == 0: # First field gets the default password type(input_field, config.DEFAULT_SERVICE_PASSWORD_RAW) else: type(input_field, config.NEW_PASSWORD_RAW) mouseClick(names.o_userConfirmation_ConfirmButton) test.endSection() def test_password_requirements_in_loop(new_pwd_input, expected_button_state, message): """ Helper function that iterates through the dynamic input fields and applies a specific new password test case (index 1). """ container = waitForObject(names.o_UserConfirmation_SettingsServicePassword) password_inputs = utility.findAllObjectsById(container, "_input") for index, input_field in enumerate(password_inputs): # # Clear the field before typing a new value for the test case # type(input_field, "", True) if index == 0: # First field: Current password (static default) type(input_field, config.DEFAULT_SERVICE_PASSWORD_RAW) elif index == 1: # Second field: New password (the variable under test) type(input_field, new_pwd_input) elif index == 2: # Third field: Confirm password (must match the test input in field 1 for validity check) type(input_field, new_pwd_input) # After inputting all values, verify the state of the confirm button verify_confirm_button_state(expected_button_state, message) def verify_confirm_button_state(expected_state, message): """Helper function to verify the enabled/disabled state using test.compare.""" confirm_button = findObject(names.o_userConfirmation_ConfirmButton) current_state = confirm_button.enabled test.compare(current_state, expected_state, message) def service_login(): test.startSection("Navigating to 'Service Login' menu") td_simulator.td_operation_mode(TDOpModes.MODE_SERV.value, 0) headerbar_container = waitForObject(names.o_headerBar_HeaderBar, 2000) device_setting_screen_headerbar_title_text = utility.findChildByText( headerbar_container, "Device Settings" ) if device_setting_screen_headerbar_title_text is not None: test.compare( device_setting_screen_headerbar_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 ), ) grid_container = waitForObject(names.o_DeviceSettingsGrid) service_option = utility.findChildByText(grid_container, "Service") if service_option is not None: mouseClick(service_option) headerbar_container = waitForObject(names.o_headerBar_HeaderBar) service_screen_headerbar_title_text = utility.findChildByText( headerbar_container, "Service" ) if service_screen_headerbar_title_text is not None: test.compare( service_screen_headerbar_title_text.text, config.SERVICE_SCREEN_TITLE_TEXT, "{} screen is displayed and Comparison of Device Settings Screen Title text".format( config.SERVICE_SCREEN_TITLE_TEXT ), ) input_field = waitForObject(names.o_userConfirmation_TextInput) type(input_field, config.NEW_PASSWORD_RAW) confirm_button = waitForObject(names.o_userConfirmation_ConfirmButton) mouseClick(confirm_button) grid_container = waitForObject(names.o_DeviceSettingsGrid) user_modes_option = utility.findChildByText(grid_container, "User Modes") if user_modes_option is not None: mouseClick(user_modes_option) headerbar_container = waitForObject(names.o_headerBar_HeaderBar, 2000) user_modes_screen_headerbar_title_text = utility.findChildByText( headerbar_container, "Service" ) if user_modes_screen_headerbar_title_text is not None: test.compare( user_modes_screen_headerbar_title_text.text, config.USER_MODES_SCREEN_TITLE_TEXT, "{} screen is displayed and Comparison of Device Settings Screen Title text".format( config.USER_MODES_SCREEN_TITLE_TEXT ), ) # Wait for the toggle switch object user_mode_switch = waitForObject( names.o_SettingsBase_settingsUserMode_BaseSwitch, 1000 ) # Check current state and toggle it # store the initial state was_checked = user_mode_switch.checked test.log(f"Initial switch state: {'Checked' if was_checked else 'Unchecked'}") # Perform the toggle action mouseClick(user_mode_switch) # Verify the toggle state has inverted expected_state = not was_checked test.compare( user_mode_switch.checked, expected_state, f"Verify switch changed state to {expected_state}", ) # Toggle it back to original state mouseClick(user_mode_switch) test.compare( user_mode_switch.checked, was_checked, "Verify switch returned to original state", ) mouseClick(names.o_SettingsBase_backButton_BackButton) def date_and_time_screen(): grid_container = waitForObject(names.o_DeviceSettingsGrid) date_and_time_option = utility.findChildByText(grid_container, "Date and Time") if date_and_time_option is not None: mouseClick(date_and_time_option) headerbar_container = waitForObject(names.o_headerBar_HeaderBar) date_and_time_screen_headerbar_title_text = utility.findChildByText( headerbar_container, "Date and Time" ) if date_and_time_screen_headerbar_title_text is not None: test.compare( date_and_time_screen_headerbar_title_text.text, config.DATE_AND_TIME_SCREEN_TITLE_TEXT, "{} screen is displayed and Comparison of Device Settings Screen Title text".format( config.DATE_AND_TIME_SCREEN_TITLE_TEXT ), ) grid_container = waitForObject( names.o_timeContainer_LabelUnitContainer ) date_and_time_option = utility.findChildByText(grid_container, "Time") if date_and_time_option is not None: test.compare( date_and_time_option.text, "Time", "{} should be available in Date and Time Screen".format( date_and_time_option.text ), ) # Wait for the main grid/container grid_container = waitForObject(names.o_SettingsBase_SettingsDateTime) # Iterate through the list of expected texts from your config for date_and_time_parameter in config.DATE_AND_TIME_PARAMETERS_TEXTS: # Find any child within the container that matches this text found_elements = utility.findAllObjectsByText( grid_container, date_and_time_parameter ) # Verify that at least one such element was found if found_elements: # Take the first match found in the tree matched_obj = found_elements[0] test.compare( str(matched_obj.text), date_and_time_parameter, f"'{date_and_time_parameter}' found and verified in Date and Time Screen", ) # Wait for the toggle switch object ntp_mode_switch = waitForObject(names.o_SettingsBase_ntpSwitch_BaseSwitch, 1000) # Check current state and toggle it # store the initial state was_checked = ntp_mode_switch.checked test.log(f"Initial switch state: {'Checked' if was_checked else 'Unchecked'}") # Perform the toggle action mouseClick(ntp_mode_switch) # Verify the toggle state has inverted expected_state = not was_checked test.compare( ntp_mode_switch.checked, expected_state, f"Verify switch changed state to {expected_state}", ) # Toggle it back to original state mouseClick(ntp_mode_switch) test.compare( ntp_mode_switch.checked, was_checked, "Verify switch returned to original state" ) mouseClick(names.o_SettingsBase_backButton_BackButton_2) def enable_root_ssh_screen(): grid_container = waitForObject(names.o_DeviceSettingsGrid) enable_root_ssh_option = utility.findChildByText(grid_container, "Enable Root SSH") if enable_root_ssh_option is not None: mouseClick(enable_root_ssh_option) headerbar_container = waitForObject(names.o_headerBar_HeaderBar) enable_root_ssh_screen_headerbar_title_text = utility.findChildByText( headerbar_container, "Enable Root SSH" ) if enable_root_ssh_screen_headerbar_title_text is not None: test.compare( enable_root_ssh_screen_headerbar_title_text.text, config.ENABLE_ROOT_SSH_SCREEN_TITLE_TEXT, "{} screen is displayed and Comparison of Enable Root SSH Screen Title text".format( config.ENABLE_ROOT_SSH_SCREEN_TITLE_TEXT ), ) # Wait for the main grid/container grid_container = waitForObject(names.o_SettingsBase_SettingsRootSSHAccess) # Iterate through the list of expected texts from your config for enable_root_ssh_parameter in config.ENABLE_ROOT_SSH_PARAMETERS_TEXTS: # Find any child within the container that matches this text found_elements = utility.findAllObjectsByText( grid_container, enable_root_ssh_parameter ) # Verify that at least one such element was found if found_elements: # Take the first match found in the tree matched_obj = found_elements[0] test.compare( str(matched_obj.text), enable_root_ssh_parameter, f"'{enable_root_ssh_parameter}' found and verified in Enable Root SSH Screen", ) mouseClick(names.o_SettingsBase_backButton_BackButton_3) def factory_reset_screen(): grid_container = waitForObject(names.o_DeviceSettingsGrid) factory_reset_option = utility.findChildByText(grid_container, "Factory Reset") if factory_reset_option is not None: mouseClick(factory_reset_option) headerbar_container = waitForObject(names.o_headerBar_HeaderBar) factory_reset_screen_headerbar_title_text = utility.findChildByText( headerbar_container, "Factory Reset" ) if factory_reset_screen_headerbar_title_text is not None: test.compare( factory_reset_screen_headerbar_title_text.text, config.FACTORY_RESET_SCREEN_TITLE_TEXT, "{} screen is displayed and Comparison of Factory Reset Screen Title text".format( config.FACTORY_RESET_SCREEN_TITLE_TEXT ), ) factory_reset_container = waitForObject( names.o_userConfirmation_SettingsFactoryReset ) factory_reset_screen_text = utility.findChildByText( factory_reset_container, "Do you want to perform the factory reset?" ) if factory_reset_screen_text is not None: test.compare( factory_reset_screen_text.text, config.FACTORY_RESET_SCREEN_TEXT, "{} screen is displayed and Comparison of Factory Reset Screen Title text".format( config.FACTORY_RESET_SCREEN_TEXT ), ) mouseClick(names.o_factoryReset_ConfirmButton) mouseClick(names.o_cancelTouch_TouchRect) mouseClick(names.o_factoryReset_ConfirmButton) mouseClick(names.o_confirmTouch_ConfirmButton) mouseClick(names.o_userConfirmation_backButton_BackButton) def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME_AND_ARGUMENT) td_simulator.td_operation_mode(TDOpModes.MODE_SERV.value, 0) login_page_title_text = utility.get_object_from_names( names.o_loginPage_Titletext, error_message="Login Page Title text not found", timeout_ms=2000, ) if login_page_title_text.text == 'Set Password': manufacture_login() else: closeWindow(names.o_Gui_MainView) startApplication(config.AUT_NAME) service_login() date_and_time_screen() enable_root_ssh_screen() factory_reset_screen() test.endSection()