Index: shared/scripts/configuration/utility.py =================================================================== diff -u -r956fd22d63adc5ebecc6320221df8a60ce069a4a -r9173ebd0962929fe8ab341b7f731d6adb39a0368 --- shared/scripts/configuration/utility.py (.../utility.py) (revision 956fd22d63adc5ebecc6320221df8a60ce069a4a) +++ shared/scripts/configuration/utility.py (.../utility.py) (revision 9173ebd0962929fe8ab341b7f731d6adb39a0368) @@ -12,15 +12,16 @@ # ############################################################################ - +import names import sys import test -import names import object import squish from configuration import config from builtins import int as pyInt +from builtins import str as pyStr + def start_application(app_name): """ @@ -152,14 +153,14 @@ test.endSection() -def training_screen_indicator_verification(current_indicator, training_items_object): +def instruction_screen_indicator_verification(current_indicator, training_items_object): """ Method to verify the pre treatment tutorial indicators on top of the screen which indicates the steps passed, current, remained] @param current_indicator :(int) Current pre-treatment tutorial indicator @param training_items_object :(dictionary) pre_treatment bullet object @return N/A """ - test.startSection("Method to verify the Page Step indicators from patient connection section") + test.startSection("Method to verify the Page Step indicators from training screen") for page in range(config.TRAINING_INDICATOR_SCREEN): occurrence_index = 10 + page #1-9 occurrence of object belongs to page indicators, 10 - 13 occurrence of object belongs to training indicators training_items_object["occurrence"] = occurrence_index @@ -187,3 +188,70 @@ test.endSection() + +def verify_color_of_entry(entry = 0, vital_parameter = None, input_field = None): + """ + Method to verify the color of entry of systolic, diastolic and heart rate + @param entry: (int) user entered value + @param vital_parameter - (str) parameter name under which user is entering value (sys/dia/heart rate) + @param input_field - (obj) object of input field + """ + test.startSection("Verify the color of {} value {}".format(vital_parameter, entry)) + input_field_color = input_field.color.name + entry = pyInt(entry) + if vital_parameter is config.SYSTOLIC_TEXT: + if (entry < config.SYSTOLIC_LOWER_LIMIT) or (entry > config.SYSTOLIC_UPPER_LIMIT): + test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "systolic value {} is out of range, systolic value should be in range of {} and {}".format(entry, config.SYSTOLIC_LOWER_LIMIT, config.SYSTOLIC_UPPER_LIMIT)) + elif (entry >= config.SYSTOLIC_LOWER_LIMIT) and (entry <= config.SYSTOLIC_UPPER_LIMIT): + test.compare(input_field_color, config.ENABLED_COLOR, "systolic value {} is in range of {} and {}".format(entry, config.SYSTOLIC_LOWER_LIMIT, config.SYSTOLIC_UPPER_LIMIT)) + elif vital_parameter is config.DIASTOLIC_TEXT: + if (entry < config.DIASTOLIC_LOWER_LIMIT) or (entry > config.DIASTOLIC_UPPER_LIMIT): + test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "diastolic value {} is out of range, diastolic value should be in range of {} and {}".format(entry, config.DIASTOLIC_LOWER_LIMIT, config.DIASTOLIC_UPPER_LIMIT)) + elif (entry >= config.DIASTOLIC_LOWER_LIMIT) and (entry <= config.DIASTOLIC_UPPER_LIMIT): + test.compare(input_field_color, config.ENABLED_COLOR, "diastolic value {} is in range of {} and {}".format(entry, config.DIASTOLIC_LOWER_LIMIT, config.DIASTOLIC_UPPER_LIMIT)) + elif vital_parameter is config.HEART_RATE_TITLE: + if (entry < config.HEART_RATE_LOWER_LIMIT) or (entry > config.HEART_RATE_UPPER_LIMIT): + test.compare(input_field_color, config.OUT_OF_RANGE_COLOR, "Heart Rate value {} is out of range, Heart Rate value should be in range of {} and {}".format(entry, config.HEART_RATE_LOWER_LIMIT, config.HEART_RATE_UPPER_LIMIT)) + elif (entry >= config.HEART_RATE_LOWER_LIMIT) and (entry <= config.HEART_RATE_UPPER_LIMIT): + test.compare(input_field_color,config.ENABLED_COLOR, "Heart Rate value {} is in range of {} and {}".format(entry, config.HEART_RATE_LOWER_LIMIT, config.HEART_RATE_UPPER_LIMIT)) + test.endSection() + + +def keypad_input(key_value): + """ + Method to enter values using application UI keyboard + @param key_value: (str) User expected value + """ + if key_value is not None: + names.o_keypad_input["text"] = key_value + return names.o_keypad_input + else: + test.log("Invalid text for object.") + names.o_keypad_input["text"] = None + + +def enter_keypad_value(entry): + """ + Method to enter user desired + value using keypad + @param entry: (str) User expected value + """ + test.startSection("Entering {}".format(entry)) + entry = pyStr(entry) #type casted into string format + for value in entry: + squish.mouseClick(squish.waitForObject(keypad_input(value))) + test.endSection() + + +def erase_entered_value(input_field): + """ + Method to erase the entered value + @param input_field - (obj) object of input field + """ + input_field = squish.waitForObject(input_field).text + for value in input_field: + squish.mouseClick(squish.waitForObjectExists(names.o_back_space_key)) + + test.log("user cleared pre-used value") + +