Index: tst_settings_date_and_time/test.py =================================================================== diff -u -re91712057f27742e36df123ac4519564c4e35399 -r3037246670bc9f00dff0acc09f82b5aca6cd2bb8 --- tst_settings_date_and_time/test.py (.../test.py) (revision e91712057f27742e36df123ac4519564c4e35399) +++ tst_settings_date_and_time/test.py (.../test.py) (revision 3037246670bc9f00dff0acc09f82b5aca6cd2bb8) @@ -16,14 +16,12 @@ from configuration import config, utility from dialin.ui.hd_simulator import HDSimulator -from dialin.common.hd_defs import HDOpModes +from dialin.common.hd_defs import HDOpModes, HDOpSubModes from dialin.ui import utils -from configuration.config import SERVICE_CONF_LOCATION from calendar import isleap hd_simulator = HDSimulator() -SERVICES_TITLE_TEXT = "Please Enter The Service Password" SET_DATE_AND_TIME_TEXT = "Set Date And Time" TIME_TITLE = "Time (HH:MM)" DATE_TITLE_TEXT = "Date (MM/DD/YYYY)" @@ -42,80 +40,61 @@ MONTH_LOWER_LIMIT = 1 YEAR_UPPER_LIMIT = 2100 YEAR_LOWER_LIMIT = 1970 +CONFIRMATION_MESSAGE = "Setting date and time ..." HD_DATE_AND_TIME_MESSAGE = "AdjustHDDateTime" DG_DATE_AND_TIME_MESSAGE = "AdjustDGDateTime" -INCORRECT_PASSWORD = "abcd" -INCORRECT_PASSWORD_MSG = "Incorrect service password" -SERVICE_SCREEN_OPTIONS = ["Information", "Volume And Brightness", "Wi-Fi", "Bluetooth Cuff", "Dialysate Generator Settings", "Set Date And Time", "Set Language", "Software Update", "Factory Reset", "Calibration ", ] +SERVICE_SCREEN_OPTIONS = ["Information", "Volume And Brightness", "Wi-Fi", "Bluetooth Cuff", "DG Cleaning", "Set Date And Time", "Export Logs" ] EMPTY_INPUT_FIELD = "" +def service_text_obj(text): + names.o_service_home_text_obj["text"] = text + return names.o_service_home_text_obj + def settings_text_obj(text): - names.o_settings_home_text_obj["text"] = text - return names.o_settings_home_text_obj + names.o_set_date_and_time_text_obj["text"] = text + return names.o_set_date_and_time_text_obj -def services_screen_text_obj(text): - names.o_services_screen_text_obj["text"] = text - return names.o_services_screen_text_obj - def date_time_screen_text_obj(text): names.o_settings_date_and_time_text["text"] = text return names.o_settings_date_and_time_text -def navigate_to_settings_screen(): +def navigate_to_service_screen(): """ - Method to navigate to "Settings" screen + Method to navigate to "Service" screen """ - test.startSection("Navigating to 'Device Settings' screen") - hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_STAN.value, sub_mode=HDOpModes.MODE_FAUL.value) - utils.waitForGUI(1) - mouseClick(waitForObjectExists(names.o_settings_Text)) - device_settings_text = waitForObjectExists(settings_text_obj(config.DEVICE_SETTINGS_TEXT)) - test.compare(device_settings_text.text, config.DEVICE_SETTINGS_TEXT, "{} screen is displayed".format(config.DEVICE_SETTINGS_TEXT)) + test.startSection("Navigating to 'Service' screen") + hd_simulator.cmd_send_hd_operation_mode(op_mode=HDOpModes.MODE_SERV.value, sub_mode=HDOpSubModes.STANDBY_START_STATE.value) + utils.waitForGUI(0.5) + service_screen_text = waitForObjectExists(service_text_obj(config.SERVICE_SCREEN_TITLE_TEXT)) + test.compare(service_screen_text.text, config.SERVICE_SCREEN_TITLE_TEXT, "{} screen is displayed".format(config.SERVICE_SCREEN_TITLE_TEXT)) test.endSection() -def navigate_to_services_password_screen_and_enter_password(): - """ - Method to navigate to services screen - and verify the "Please Enter The Service Password" - title is displayed and enter password, verify the - password and click on confirm button - """ - test.startSection("Navigating to 'services password' screen and enter password") - mouseClick(waitForObjectExists(settings_text_obj(config.SERIVCES_TITLE))) - services_password_title = waitForObjectExists(services_screen_text_obj(SERVICES_TITLE_TEXT)) - test.compare(services_password_title.text, SERVICES_TITLE_TEXT, "{} should display once user is navigated to services password screen".format(SERVICES_TITLE_TEXT)) - utils.waitForGUI(0.5) - mouseClick(waitForObjectExists(names.o_switch_keyboard_to_keypad)) - mouseClick(waitForObjectExists(names.o_password_text_field)) - with open(SERVICE_CONF_LOCATION, "r") as file: - lines = file.readlines() - for index, line in enumerate(lines): - if "Service Password" in line: - services_password = lines[index+1][:-1] - break - else: - continue - utility.enter_keyboard_numeric_value(entry=str(services_password)) - mouseClick(waitForObjectExists(names.o_show_password)) - test.log("Verifying the entered password") - password = str((waitForObjectExists(names.o_password_text_field)).text) - test.compare(password, str(services_password), "Entered password should be {}".format(str(services_password))) - mouseClick(waitForObjectExists(services_screen_text_obj(config.CONFIRM_TEXT))) - test.endSection() - def navigate_to_set_date_and_time(): """ Method to navigate to set date and time screen and verify its title 'Set Date And Time' """ test.startSection("Navigating 'Set Date And Time' screen") utils.waitForGUI(0.5) - mouseClick(waitForObjectExists(settings_text_obj(SET_DATE_AND_TIME_TEXT))) - set_date_and_time_title = waitForObjectExists(date_time_screen_text_obj(SET_DATE_AND_TIME_TEXT)) + mouseClick(waitForObjectExists(names.o_set_date_and_time_text)) + set_date_and_time_title = waitForObjectExists(settings_text_obj(SET_DATE_AND_TIME_TEXT)) test.compare(set_date_and_time_title.text, SET_DATE_AND_TIME_TEXT, "{} should be displayed when user is navigated to 'Set Date And Time' screen".format(SET_DATE_AND_TIME_TEXT)) test.endSection() +def verify_back_btn(): + """ + Method to verify the back button and click + """ + test.startSection("Verify the 'BACK' button") + test.compare(str(waitForObjectExists(settings_text_obj(config.BACK_TEXT)).text), config.BACK_TEXT,"'BACK' button text should be {}".format(config.BACK_TEXT)) + utils.waitForGUI(0.1) + test.compare(waitForObjectExists(settings_text_obj(config.BACK_TEXT)).enabled , True, "'BACK' button should be enabled") + mouseClick(waitForObjectExists(names.o_back_btn)) + utils.waitForGUI(0.5) + mouseClick(waitForObjectExists(names.o_set_date_and_time_text)) + test.endSection() + def verify_entered_date_and_time(hour, min, day, month, year, valid_parameter_passed): """ Method to enter date and time and verify the @@ -256,23 +235,28 @@ button and click on confirm button @param valid_paramter_passed - (bool) True/False whether hour/minute/day/month/year is valid """ + test.startSection("Verify the status of confirm button and click on confirm button") if valid_parameter_passed is config.VALID: if object.exists(date_time_screen_text_obj(text=config.CONFIRM_TEXT)): confirm_btn = waitForObjectExists(date_time_screen_text_obj(text=config.CONFIRM_TEXT)) test.compare(confirm_btn.enabled, config.ENABLED, "Confirm Button should be enabled") mouseClick(confirm_btn) + confirm_msg = waitForObjectExists(settings_text_obj(CONFIRMATION_MESSAGE)) + test.compare(confirm_msg.visible, config.VISIBLE, "{} message should be displayed".format(CONFIRMATION_MESSAGE)) else: if not(object.exists(date_time_screen_text_obj(text=config.CONFIRM_TEXT))): test.passes("Confirm button is not available") + test.endSection() + def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME) - navigate_to_settings_screen() - navigate_to_services_password_screen_and_enter_password() + navigate_to_service_screen() navigate_to_set_date_and_time() + verify_back_btn() verify_entered_date_and_time(hour="24", min="33", day="1", month="3", year="2022", valid_parameter_passed=config.INVALID) verify_entered_date_and_time(hour="00", min="60", day="29", month="2", year="2020", valid_parameter_passed=config.INVALID) verify_entered_date_and_time(hour="13", min="33", day="32", month="2", year="2022", valid_parameter_passed=config.INVALID) @@ -284,4 +268,4 @@ utility.get_current_log_details(message_text=DG_DATE_AND_TIME_MESSAGE) utils.tstDone() - + \ No newline at end of file