Index: tst_instructions_poc/test.py =================================================================== diff -u -r8d5b89a87fac06a04c2d3fe09971cba40504b54f -rf4c31bbf4daba2faa30d995f55cd306e19250671 --- tst_instructions_poc/test.py (.../test.py) (revision 8d5b89a87fac06a04c2d3fe09971cba40504b54f) +++ tst_instructions_poc/test.py (.../test.py) (revision f4c31bbf4daba2faa30d995f55cd306e19250671) @@ -24,16 +24,33 @@ def get_text_obj(screen_obj,text): """ To obtain a text object based on text provided - @param obj_name: provides the object name on which the text must be present + @param (str) screen_obj: provides the container name on which the text must be present + @param (str) text: instruction text @returns a real name object """ names.o_instruction["container"] = screen_obj names.o_instruction["text"] = text return names.o_instruction def get_rightarrow_obj(screen_obj): + """ + To obtain object for right arrow based on container + @param (str) screen_obj: provides the container + @returns a real name object + """ names.o_right_arrow["container"] = screen_obj return names.o_right_arrow + +def get_img_obj(screen_obj,source): + """ + To obtain image object based on container + @param (str) screen_obj: provides the container + @param (str) source: image source + @returns a real name object + """ + names.o_image_path["container"] = screen_obj + names.o_image_path["source"] = source + return names.o_image_path def read_data_from_conf_file(): """ @@ -66,77 +83,62 @@ if line_count == len(contents): count_of_instructions.append(count) title_count_dict.update(dict(zip(title_list,count_of_instructions))) -# return instructions - -# def remove_space_from_instruction(instruction): -# line = instruction.split(".") -# l = line[1] -# test.log(str(l[0])) -# if l[0] == '\\' : -# line[1] = line[1][2:] -# instruction = ". ".join(line) -# test.log(str(instruction)) -# # return txt -def verify_instruction(title,index): +def verify_instruction_and_image(title,index): """ - This method is used to verify the instructions from water sample screen - @param - (str) list of instructions from Instruction.conf file + This method is used to verify the instruction and image on present screen + @param - (str) title: screen title + @param - (int) index: index of data from Instructions.conf file """ -# test.startSection("Verify the instructions from water sample screen") -# test.log(str(instructions)) + test.startSection("Verifying instruction and image from " +title+ " screen") for i in range((title_count_dict.get(title))): instruction_text = instructions[index] - test.log(str(instruction_text)) -# instruction_text = instruction_text.replace('\\n','') - test.log(str(instruction_text)) + image_text = image_names[index] +# test.log(str(instruction_text)) + instruction_text = instruction_text.replace('\\n','\n') +# test.log(str(instruction_text)) index += 1 - test.log(str(index)) +# test.log(str(index)) if instruction_text[-1] == " ": instruction_text = instruction_text.rstrip() - test.log(str(instruction_text)) - test.compare(str(waitForObject(get_text_obj(text_obj_names[0],instruction_text)).text),instruction_text, "Instruction from water sample screen should be visible and matched") +# test.log(str(instruction_text)) + image_source = waitForObjectExists(get_img_obj(text_obj_names[0],"{}{}".format(config.IMAGE_LOCATION, image_text))).source.path + test.compare(str(waitForObject(get_text_obj(text_obj_names[0],instruction_text)).text),instruction_text, "Instruction from " +title+ " screen is visible and matched") + test.compare(str(image_source),"{}{}".format(config.EXPECTED_IMAGE_LOCATION, image_text), "Image from " +title+ " screen is visible and matched") if object.exists(names.o_next_button): mouseClick(waitForObject(names.o_next_button)) if object.exists(names.o_fail_button): mouseClick(waitForObject(names.o_fail_button)) if object.exists(get_rightarrow_obj(rightarrow_obj_names[0])): mouseClick(waitForObject(get_rightarrow_obj(rightarrow_obj_names[0]))) + test.endSection() return index -# test.endSection() - -def verify_image_title_water_sample(image_names): - """ - This method is used to verify all the image titles from Instructions.conf file. - """ - test.startSection("Verify all the image titles from Instructions.conf file") - image_titles = os.listdir(utility.IMAGE_FILE_LOCATION) - image_names = list(set(image_names)) - for image in image_names: - if image in image_titles: - test.passes("Image "+ str(image) +" is present at given file location") - else: - test.fail("Image "+ str(image) +" is not present at given file location") - test.endSection() - + def main(): utils.tstStart(__file__) startApplication(config.AUT_NAME) + read_data_from_conf_file() hd_simulator.cmd_set_hd_operation_mode_data(HDOpModes.MODE_PRET.value,PreTreatmentSampleWaterStates.SAMPLE_WATER_SETUP_STATE.value) + + test.startSection("Navigating to Pre-Treatment Sample screen") hd_simulator.cmd_send_pre_treatment_state_data(sub_mode=HDOpSubModes.SUBMODE_WAIT_FOR_TREATMENT.value, water_sample_state=PreTreatmentSampleWaterStates.SAMPLE_WATER_STATE.value,consumables_self_test_state=PreTreatmentConsumableSelfTestStates.CONSUMABLE_SELF_TESTS_INSTALL_STATE.value, no_cartridge_self_test_state=PreTreatmentNoCartSelfTestsStates.NO_CART_SELF_TESTS_START_STATE.value,installation_state=PreTreatmentCartridgeInstallStates.CARTRIDGE_INSTALL_STATE.value, dry_self_test_state=PreTreatmentDrySelfTestsStates.DRY_SELF_TESTS_START_STATE.value, prime_state=PreTreatmentPrimeStates.HD_PRIME_START_STATE.value,recirculate_state=PreTreatmentRecircStates.PRE_TREATMENT_RECIRC_STATE.value, patient_connection_state=PreTreatmentPatientConnectionStates.PATIENT_CONNECTION_STATE.value) - read_data_from_conf_file() - index = verify_instruction("Water Sample",index = 0) - index = verify_instruction("Water Sample Result",index = index) - index = verify_instruction("Water Sample Result Failed",index = index) + index = verify_instruction_and_image("Water Sample",index = 0) + index = verify_instruction_and_image("Water Sample Result",index = index) + index = verify_instruction_and_image("Water Sample Result Failed",index = index) + test.endSection() + + test.startSection("Navigating to Pre-Treatment Consumables screen") hd_simulator.cmd_send_pre_treatment_state_data(sub_mode=HDOpSubModes.SUBMODE_WAIT_FOR_DISINFECT.value, water_sample_state=PreTreatmentSampleWaterStates.SAMPLE_WATER_SETUP_STATE.value,consumables_self_test_state=PreTreatmentConsumableSelfTestStates.CONSUMABLE_SELF_TESTS_INSTALL_STATE.value, no_cartridge_self_test_state=PreTreatmentNoCartSelfTestsStates.NO_CART_SELF_TESTS_START_STATE.value,installation_state=PreTreatmentCartridgeInstallStates.CARTRIDGE_INSTALL_STATE.value, dry_self_test_state=PreTreatmentDrySelfTestsStates.DRY_SELF_TESTS_START_STATE.value, prime_state=PreTreatmentPrimeStates.HD_PRIME_START_STATE.value,recirculate_state=PreTreatmentRecircStates.PRE_TREATMENT_RECIRC_STATE.value, patient_connection_state=PreTreatmentPatientConnectionStates.PATIENT_CONNECTION_STATE.value) text_obj_names.pop(0) - index = verify_instruction("Consumables Installation",index = index) + index = verify_instruction_and_image("Consumables Installation",index = index) rightarrow_obj_names.pop(0) + test.endSection() + test.startSection("Navigating to Pre-Treatment Disposables screen") hd_simulator.cmd_send_pre_treatment_state_data(sub_mode=HDOpSubModes.SUBMODE_DG_HEAT_DISINFECT_IN_PROGRESS.value, water_sample_state=PreTreatmentSampleWaterStates.SAMPLE_WATER_SETUP_STATE.value, consumables_self_test_state=PreTreatmentConsumableSelfTestStates.CONSUMABLE_SELF_TESTS_INSTALL_STATE.value, @@ -147,26 +149,37 @@ recirculate_state=PreTreatmentRecircStates.PRE_TREATMENT_RECIRC_STATE.value, patient_connection_state=PreTreatmentPatientConnectionStates.PATIENT_CONNECTION_STATE.value) text_obj_names.pop(0) - index = verify_instruction("Cartridge Installation",index = index) + index = verify_instruction_and_image("Cartridge Installation",index = index) text_obj_names.pop(0) rightarrow_obj_names.pop(0) - mouseClick(waitForObjectExists(names.o_next_button_cartridge_connection)) - index = verify_instruction("Cartridge Connection",index = index) + test.log("Clicking on next button in Cartridge Installation instruction page") + mouseClick(waitForObjectExists(names.o_next_button_cartridge_installation)) + index = verify_instruction_and_image("Cartridge Connection",index = index) text_obj_names.pop(0) - mouseClick(waitForObjectExists(names.o_next_button_cartridge_installation)) - index = verify_instruction("Saline Bag",index = 18) + test.log("Clicking on next button in Cartridge Connection instruction page") + mouseClick(waitForObjectExists(names.o_next_button_cartridge_connection)) + index = verify_instruction_and_image("Saline Bag",index = 18) text_obj_names.pop(0) rightarrow_obj_names.pop(0) + test.endSection() + test.log("Navigating to Pre-Treatment Ultrafiltration screen") hd_simulator.cmd_send_pre_treatment_state_data(sub_mode=PreTreatmentSubModes.HD_PRE_TREATMENT_PATIENT_CONNECTION_STATE.value, water_sample_state=0, consumables_self_test_state=0,no_cartridge_self_test_state=0, installation_state=0, dry_self_test_state=0, prime_state=0, recirculate_state=0, patient_connection_state=0) hd_simulator.cmd_send_pre_treatment_continue_to_treament_response(accepted=True, reason=0) hd_simulator.cmd_send_uf_treatment_response(accepted = True, reason = 0, volume = 120) + test.log("Clicking on skip button in BP/HR screen") mouseClick(waitForObject(names.o_skip_button)) - index = verify_instruction("Patient Connection",index = index) + test.startSection("Navigating to Pre-Treatment Patient Connection screen") + index = verify_instruction_and_image("Patient Connection",index = index) + test.endSection() + + test.startSection("Navigating to Pre-Treatment Start screen") hd_simulator.cmd_send_pre_treatment_patient_connection_confirm_response(accepted=True, reason=0) - index = verify_instruction("Start Treatment",index = index) + index = verify_instruction_and_image("Start Treatment",index = index) + test.endSection() + utils.tstDone() \ No newline at end of file