Index: tst_settings_date_and_time/test.py =================================================================== diff -u -raabf1b3f92efc95e93c54ef70fe9d2bb374ef6fc -r8a2443814a96ee0a320eebf6ce267673b16901c3 --- tst_settings_date_and_time/test.py (.../test.py) (revision aabf1b3f92efc95e93c54ef70fe9d2bb374ef6fc) +++ tst_settings_date_and_time/test.py (.../test.py) (revision 8a2443814a96ee0a320eebf6ce267673b16901c3) @@ -45,8 +45,8 @@ 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 ", ] +EMPTY_INPUT_FIELD = "" - def settings_text_obj(text): names.o_settings_home_text_obj["text"] = text return names.o_settings_home_text_obj @@ -190,14 +190,12 @@ mouseClick(hour_input_field) utility.erase_entered_value(hour_input_field) utility.enter_keypad_value(hour) - test.compare(hour_input_field.text, hour, "Hour value should be {}".format(hour)) - verify_color_of_entry(entry=hour, date_time_parameter=HOUR_TEXT, input_field=hour_input_field) + verify_valid_and_invalid_entry_and_its_color(entry=hour, date_time_parameter=HOUR_TEXT, input_field=hour_input_field) test.log("Entering minute") mouseClick(minute_input_field) utility.erase_entered_value(minute_input_field) utility.enter_keypad_value(min) - test.compare(minute_input_field.text, min, "Minute value should be {}".format(min)) - verify_color_of_entry(entry=min, date_time_parameter=MINUTE_TEXT, input_field=minute_input_field) + verify_valid_and_invalid_entry_and_its_color(entry=min, date_time_parameter=MINUTE_TEXT, input_field=minute_input_field) MONTH_PARENT_INDEX = 1 DAY_PARENT_INDEX = 3 YEAR_PARENT_INDEX = -1 @@ -214,58 +212,67 @@ mouseClick(month_input_field) utility.erase_entered_value(month_input_field) utility.enter_keypad_value(month) - test.compare(month_input_field.text, month, "Month value should be {}".format(month)) - verify_color_of_entry(entry=month, date_time_parameter=MONTH_TEXT, input_field=month_input_field) + verify_valid_and_invalid_entry_and_its_color(entry=month, date_time_parameter=MONTH_TEXT, input_field=month_input_field) test.log("Entering Day") mouseClick(day_input_field) utility.erase_entered_value(day_input_field) utility.enter_keypad_value(day) - test.compare(day_input_field.text, day, "Day value should be {}".format(day)) - verify_color_of_entry(entry=day, date_time_parameter=DAY_TEXT, input_field=day_input_field) + verify_valid_and_invalid_entry_and_its_color(entry=day, date_time_parameter=DAY_TEXT, input_field=day_input_field) test.log("Entering Year") mouseClick(year_input_field) utility.erase_entered_value(year_input_field) utility.enter_keypad_value(year) - test.compare(year_input_field.text, year, "Year value should be {}".format(year)) - verify_color_of_entry(entry=year, date_time_parameter=YEAR_TEXT, input_field=year_input_field) + verify_valid_and_invalid_entry_and_its_color(entry=year, date_time_parameter=YEAR_TEXT, input_field=year_input_field) verify_confirm_btn(valid_parameter_passed) test.endSection() -def verify_color_of_entry(entry, date_time_parameter, input_field): +def verify_valid_and_invalid_entry_and_its_color(entry, date_time_parameter, input_field): """ - Method to verify the color of entry + Method to verify the valid and invalid color of entry of date and time @param entry: (int) user user entered value @param date_time_parameter - (str) parameter name under which user is entering value (hour/minute/day/month/year) @param input_field - (obj) object of input field """ test.startSection("Verify the color of {} value {}".format(date_time_parameter, entry)) + actual_value = str(input_field.text) + actual_value = builtins.int(actual_value) input_field_color = input_field.color.name entry = builtins.int(entry) if date_time_parameter is HOUR_TEXT: if (entry < HOUR_LOWER_LIMIT) or (entry > HOUR_UPPER_LIMIT): + test.compare(actual_value, entry, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, entry)) test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Hour value {} is out of range, hour value should be in range of {} and {}".format(entry, HOUR_LOWER_LIMIT, HOUR_UPPER_LIMIT)) elif (entry >= HOUR_LOWER_LIMIT) and (entry <= HOUR_UPPER_LIMIT): + test.xcompare(actual_value, EMPTY_INPUT_FIELD, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, EMPTY_INPUT_FIELD)) test.compare(input_field_color, config.IN_RANGE_COLOR, "Hour value {} is in range of {} and {}".format(entry, HOUR_LOWER_LIMIT, HOUR_UPPER_LIMIT)) elif date_time_parameter is MINUTE_TEXT: if (entry < MINUTE_LOWER_LIMIT) or (entry > MINUTE_UPPER_LIMIT): + test.compare(actual_value, entry, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, entry)) test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Minute value {} is out of range, minute value should be in range of {} and {}".format(entry, MINUTE_LOWER_LIMIT, MINUTE_UPPER_LIMIT)) elif (entry >= MINUTE_LOWER_LIMIT) and (entry <= MINUTE_UPPER_LIMIT): - test.compare(input_field_color, config.IN_RANGE_COLOR, "diastolic value {} is in range of {} and {}".format(entry, MINUTE_LOWER_LIMIT, MINUTE_UPPER_LIMIT)) + test.xcompare(actual_value, EMPTY_INPUT_FIELD, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, EMPTY_INPUT_FIELD)) + test.compare(input_field_color, config.IN_RANGE_COLOR, "Minute value {} is in range of {} and {}".format(entry, MINUTE_LOWER_LIMIT, MINUTE_UPPER_LIMIT)) elif date_time_parameter is DAY_TEXT: if (entry < DAY_LOWER_LIMIT) or (entry > DAY_UPPER_LIMIT): + test.compare(actual_value, entry, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, entry)) test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Day value {} is out of range, Day value should be in range of {} and {}".format(entry, DAY_LOWER_LIMIT, DAY_UPPER_LIMIT)) elif (entry >= DAY_LOWER_LIMIT) and (entry <= DAY_UPPER_LIMIT): + test.xcompare(actual_value, EMPTY_INPUT_FIELD, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, EMPTY_INPUT_FIELD)) test.compare(input_field_color,config.IN_RANGE_COLOR, "Day value {} is in range of {} and {}".format(entry, DAY_LOWER_LIMIT, DAY_UPPER_LIMIT)) elif date_time_parameter is MONTH_TEXT: if (entry < MONTH_LOWER_LIMIT) or (entry > MONTH_UPPER_LIMIT): + test.compare(actual_value, entry, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, entry)) test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Month value {} is out of range, Month value should be in range of {} and {}".format(entry, MONTH_LOWER_LIMIT, MONTH_UPPER_LIMIT)) elif (entry >= MONTH_LOWER_LIMIT) and (entry <= MONTH_UPPER_LIMIT): + test.xcompare(actual_value, EMPTY_INPUT_FIELD, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, EMPTY_INPUT_FIELD)) test.compare(input_field_color, config.IN_RANGE_COLOR, "Month value {} is in range of {} and {}".format(entry, MONTH_LOWER_LIMIT, MONTH_UPPER_LIMIT)) elif date_time_parameter is YEAR_TEXT: if (entry < YEAR_LOWER_LIMIT) or (entry > YEAR_UPPER_LIMIT): + test.compare(actual_value, entry, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, entry)) test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Year value {} is out of range, Year value should be in range of {} and {}".format(entry, YEAR_LOWER_LIMIT, YEAR_UPPER_LIMIT)) elif (entry >= YEAR_LOWER_LIMIT) and (entry <= YEAR_UPPER_LIMIT): + test.xcompare(actual_value, EMPTY_INPUT_FIELD, "{} value {} should be equal to {}".format(date_time_parameter, actual_value, EMPTY_INPUT_FIELD)) test.compare(input_field_color, config.IN_RANGE_COLOR, "Year value {} is in range of {} and {}".format(entry, YEAR_LOWER_LIMIT, YEAR_UPPER_LIMIT)) test.endSection()