import names import test import squish from leahi_dialin.ui.td_messaging import TD_Messaging from leahi_dialin.common.td_defs import TDOpModes, TDStandbyStates from configuration import config, utility from configparser import ConfigParser from pathlib import Path td_simulator = TD_Messaging() def navigate_to_device_settings_screen(): """ 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: squish.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 get_ini_value(conf_path: str , section: str, key: str): path = Path(conf_path) if not path.exists(): raise FileNotFoundError(f"Not found: {path}") parser = ConfigParser() # Preserve case if needed: # parser.optionxform = str parser.read(path, encoding="utf-8") if not parser.has_section(section): raise KeyError(f"Section [{section}] not found in {path}") if not parser.has_option(section, key): raise KeyError(f"Key '{key}' not found in section [{section}]") return parser.get(section, key) # Example: # value = get_ini_value("settings.conf", "database", "host") # print(value) def navigation_pageIndicator_step(vStep_name): """ Navigate to the specified page using the step indicator component. This method selects the given step from the page step indicator Args: vStep_name (str): The name of the step to navigate to as displayed in the step indicator. """ test.startSection("Method to navigation in the pretreatment page ") stepcount = squish.waitForObjectExists(names.o_preTreatmentStack_repeater_Repeater) Nextbutton = utility.setObjectText(obj =names.o_preTreatmentStack_Text, text =config.NEXT) squish.mouseClick(squish.waitForObject(Nextbutton)) autoLoadbutton = utility.setObjectText(obj =names.o_preTreatmentStack_Text, text ="Auto Load") squish.mouseClick(squish.waitForObject(autoLoadbutton)) td_simulator.td_blood_set_auto_load_response(vRejectionReason = 0) stepId = squish.waitForObjectExists(names.o_preTreatmentStack_stepIndicator_StepIndicator) values = utility.findAllObjectsById(stepId, "_text") value = get_ini_value("/home/denali/Public/luis/config/configurations/Settings/System.conf", section ="AdvancedMode", key ="AdvancedMode") if stepcount.count == 9: for input_field in values[3:]: test.log(str(input_field.text)) if str(input_field.text) == "Water Sample": squish.mouseClick(squish.waitForObject(names.o_PreTreatmentSampleStack_button_TouchRect)) if str(input_field.text) == vStep_name: break else: Nextbutton = utility.setObjectText(obj =names.o_preTreatmentStack_Text, text =config.NEXT) squish.mouseClick(Nextbutton) else: for input_field in values[3:]: test.log(str(input_field.text)) if str(input_field.text) == "Water Sample": squish.mouseClick(waitForObject(names.o_PreTreatmentSampleStack_button_TouchRect)) if str(input_field.text) == vStep_name: break else: Nextbutton = utility.setObjectText(obj =names.o_preTreatmentStack_Text, text =config.NEXT) squish.mouseClick(Nextbutton) test.endSection()