########################################################################### # # Copyright (c) 2019-2021 Diality Inc. - All Rights Reserved. # # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # @file utils.py # @author (last) LTTS # @date (last) 15-Jan-2022 # ############################################################################ import object import names import sys import squish import time import test from builtins import str as pyStr from builtins import int as pyInt from configuration import config from dialin.ui import utils from datetime import datetime from dialin.ui import utils def verify_bullet_navigation(num, num_of_instructions, screen_obj): """ Method to verify status of bullets based on number of instruction screen @param num - (int) number of indicator @param num_of_instructions- (int) count the number of instructions @param object - screen_obj - (str) Screen object """ test.startSection("instruction bullet verification for screens") for instruction in range(1, num_of_instructions): bullet_children = object.children(squish.waitForObjectExists(get_bullet_object(screen_obj,(0 + instruction) - 1))) bullet_circle_color = bullet_children[0].color.name bullet_border_color = bullet_children[0].border.color.name if instruction <= num: test.compare(bullet_circle_color, config.COMPLETE_COLOR) test.compare(bullet_border_color,config.COMPLETE_COLOR) test.log(str(instruction) + " Complete bullet") else: test.compare(bullet_circle_color, config.CURRENT_COLOR) test.compare(bullet_border_color,config.INCOMPLETE_COLOR) test.log(str(instruction) + " Incomplete bullet") test.endSection() def convert_seconds_into_min_and_sec(seconds, time_format="%M:%S"): """ Method to convert seconds into minute format. @param seconds - time in seconds. @param time_format (str) - time format. @return (int) - minute time """ seconds = int(seconds) min_and_sec = time.strftime(time_format, time.gmtime(seconds)) return min_and_sec def verify_missing_object(object_to_check): """ Method to verify the given object is invisible or is not present on the screen @param object_to_check: the object whose invisibility must be verified """ try: squish.testSettings.objectNotFoundDebugging = False squish.waitForObject(object_to_check,3000) test.fail("Given object should not be present initially") except LookupError as _: test.passes("object is not present as expected") squish.testSettings.objectNotFoundDebugging = True def get_bullet_object(screen_obj, num): """ To obtain a bullet object based on occurrence provided. @param screen_obj: provides the container on which the bullet must be present @param num: provides the occurrence value @returns a real name object """ names.o_bullet_object["container"] = screen_obj names.o_bullet_object["occurrence"] = num + 1 return names.o_bullet_object def recirculate_rejection_msg(text): names.o_recirculate_rejection_msg["text"] = text return names.o_recirculate_rejection_msg