def click_element(element, x, y, button): picture = element + '_' + locale + ".png" the_complete_picture = l_base_dir + 'on till regression test\\general_buttons.sikuli\\' + picture # is there a localized version of the picture, if not use the general version if os.path.isfile(the_complete_picture): print('local version exists: ' + picture) else: picture = element + '.png' print('local version does NOT exist: ' + picture) print("picture we're trying to find: " + picture) wait(picture, 30) click(Pattern(picture).targetOffset(x, y).similar(0.70)) ''' else: similarity = 0.85 while not (exists(Pattern(picture).targetOffset(x, y).similar(similarity))): similarity = similarity - 0.01 # print("similarity: " + str(similarity)) click(Pattern(picture).targetOffset(x, y).similar(similarity)) ''' general_functions.writeTestResults("def " + element, "data", "x-coordinate: " + str(x), "y-coordinate: " + str(y), button, "", "", "")
def pick_up(): general_functions.errorhandling("ABORT") general_functions.start_of_test_case('pick up') l_general_test_settings = test_settings.general_test_settings() general_buttons.main_page_footer_menu_btns_click('OTHER') general_buttons.main_page_other_menu_btns_click('PICK UP') general_functions.four_eyes(l_general_test_settings[4], l_general_test_settings[5]) time.sleep(6) for x in range(0, l_general_test_settings[9]): time.sleep(0.5) number_of_items = l_test_settings type(str(number_of_items[x])) time.sleep(0.5) type(Key.ENTER) time.sleep(0.5) general_functions.writeTestResults("def pick up", "GUI", "data", str(x), "", "number of denominations", "", "") x += 1 general_buttons.pick_up_page_click('TAKE OVER') type(Key.ENTER) general_functions.close_drawer_msg()
def price_override_tc_0010(test_case_description): picture = "price_override_" + locale + ".png" if exists(Pattern(picture).similar(0.70)): test_result = "OK" reg = find(Pattern(picture).similar(0.70)) else: test_result = "NOK" reg = "" general_functions.writeTestResults(test_case_description, "GUI", "price_override_tc_0010", test_result, "", " basket page", reg, picture)
def local_employee_discount_tc_0010(test_case_description): picture = "employee_discount_btns_" + locale + ".png" if exists(Pattern(picture).similar(0.70)): test_result = "OK" reg = find(Pattern(picture).similar(0.70)) else: test_result = "NOK" reg = "" general_functions.writeTestResults(test_case_description, "GUI", "local_employee_discount_tc_0010", test_result, "", "employee discount menu", reg, picture)
def basic_sale_off_line_card_tc_0020(test_case_description): picture = 'basket_page_key_pad_and_footer_menu_' + locale + '.png' if exists(Pattern(picture).similar(0.85)): test_result = "OK" reg = find(Pattern(picture).similar(0.85)) else: test_result = "NOK" reg = "" print("test result for function: " + test_result) general_functions.writeTestResults(test_case_description, "GUI", "basic_sale_off_line_card_TC_0020", test_result, "", "basket page", reg, picture)
def basic_sale_off_line_card_tc_0010(test_case_description): picture = 'off_line_cards_payment_procesed_pop_up_' + locale + '.png' if exists(Pattern(picture).similar(0.60)): test_result = "OK" reg = find(Pattern(picture).similar(0.60)) else: test_result = "NOK" reg = "" print("test result for function: " + test_result) general_functions.writeTestResults(test_case_description, "GUI", "basic_sale_off_line_card_TC_0010", test_result, "", "basket page", reg, picture)
def gui_screens_tc_0010_002(): picture = 'select_sales_person_' + locale + '.png' if exists(Pattern(picture).similar(0.70)): test_result = "OK" reg = find(Pattern(picture).similar(0.70)) else: test_result = "NOK" reg = "" print("test result for function: " + test_result) general_functions.writeTestResults('check sales person screen layout', "GUI", "gui_test_tc_0010_002", test_result, "", "main page", reg, picture)
def gui_screens_tc_0010_003(): picture = 'article_search_form_' + locale + '.png' if exists(Pattern(picture).similar(0.70)): test_result = "OK" reg = find(Pattern(picture).similar(0.70)) else: test_result = "NOK" reg = "" print("test result for function: " + test_result) general_functions.writeTestResults('check article search form screen layout', "GUI", "gui_test_tc_0010_003", test_result, "", "main page", reg, picture)
def drop_off_tc_0010(test_case_description): picture = "drop_off_amount_" + locale + '.png' if exists(Pattern(picture).similar(0.85)): test_result = "OK" reg = find(Pattern(picture).similar(0.85)) else: test_result = "NOK" reg = "" # general_functions.writeTestResults("drop off", "GUI", "drop off TC 0010", test_result, "", "") general_functions.writeTestResults( test_case_description, "GUI", "home_page_TC_0010_002", test_result, "", "menu level 1 home", reg, picture)
def check_gui_element(element): general_functions.start_of_test_case('GUI test ' + country + ' ' + brand + ' ' + element) picture = country + '_' + brand + '_' + element + '.png' if exists(Pattern(picture).similar(0.70)): test_result = "OK" reg = find(Pattern(picture).similar(0.70)) else: test_result = "NOK" reg = "" print("test result for function: " + test_result) general_functions.writeTestResults('test result', "GUI", element, test_result, "", "", reg, picture)
def errors_and_warnings_tc_0030(test_case_description): # "does the cancellation warning pop up" print("picture: " + "item_not_found_error_" + locale + ".png") picture = "item_not_found_error_" + locale + ".png" if exists(Pattern(picture).similar(0.85)): test_result = "OK" reg = find(Pattern(picture).similar(0.85)) else: test_result = "NOK" reg = "" general_functions.writeTestResults(test_case_description, "GUI", "does the cancellation warning pop up", test_result, "", "item not found page", reg, picture)
def item_not_found_tc_0010(test_case_description): l_general_test_settings = test_settings.general_test_settings() print("l_general_test_settings 1: " + l_general_test_settings[8]) picture = 'main_screen_complete_' + locale + '.png' if exists(Pattern(picture).similar(0.85)): test_result = "OK" reg = find(Pattern(picture).similar(0.85)) else: test_result = "NOK" reg = "" print("test result for function: " + test_result) general_functions.writeTestResults(test_case_description, "GUI", "home_page_TC_0010_002", test_result, "", "main page", reg, picture)
def errors_and_warnings_tc_0020(test_case_description): print("l_general_test_settings 1: " + l_general_test_settings[8]) # "item_not_found_error_en_GB.png" print("picture: " + "item_not_found_error_" + locale + ".png") picture = "item_not_found_error_" + locale + ".png" if exists(Pattern(picture).similar(0.85)): test_result = "OK" reg = find(Pattern(picture).similar(0.85)) else: test_result = "NOK" reg = "" general_functions.writeTestResults(test_case_description, "GUI", "home_page_TC_0010_002", test_result, "", "item not found page", reg, picture)
def drop_off(): general_functions.errorhandling("ABORT") general_functions.start_of_test_case('drop off') general_functions.four_eyes(l_general_test_settings[4], l_general_test_settings[5]) time.sleep(6) # TEST CASE if is_gui_test == 'YES': gui_screens.check_gui_element('drop_off') for x in range(0, l_general_test_settings[9]): time.sleep(0.5) number_of_items = l_test_settings type(str(number_of_items[x])) time.sleep(0.5) type(Key.ENTER) time.sleep(0.5) general_functions.writeTestResults("def drop_off", "GUI", "data", str(x), "", "number of denominations", "", "") x += 1 general_buttons.drop_off_page_click('TAKE OVER') # TEST CASE if is_gui_test == 'YES': gui_screens.check_gui_element('drop_off_overview') type(Key.ENTER) general_functions.close_drawer_msg() # general end of test case general_functions.end_of_test_case()
def perform_click(btns, button_name): for btn in btns: if btn[0] == button_name: # save picture of button time_stamp = "T " + time.strftime("%Y%m%d-%H%M%S") + "-" + str(datetime.now( ).microsecond) file = time_stamp + "_" + button_name path = l_base_dir + "test_run\\test_results\\buttons\\" print('region: ' + btn[0] + ' ' + str(btn[1]-50) + ', ' + str(btn[2]-50) + ', ' + str(btn[1]-50 + 100)+ ', ' + str(btn[2]-50 + 100)) r = Region(btn[1]-100, btn[2]-50, 200, 100) img = capture(r) # img is an image file .png in temp folder now shutil.move(img, path + file + ".png") # the target directory must exist # click button click(Location(btn[1], btn[2])) # write click to log general_functions.writeTestResults("click button", button_name, "x-coordinate: " + str(btn[1]), "y-coordinate: " + str(btn[2]), "", "", "", "") break
def click_element_in_region(element, x, y, button, search_area, similarity): picture = element + '_' + locale + ".png" the_complete_picture = l_base_dir + 'on till regression test\\general_buttons.sikuli\\' + picture print('element to click: ' + the_complete_picture) # is there a localized version of the picture, if not use the general version if os.path.isfile(the_complete_picture): print('local version exists: ' + picture) else: picture = element + '.png' print('local version does NOT exist: ' + picture) # print("picture we're trying to find: " + picture) #search_area.highlight(3) search_area.wait(Pattern(picture).targetOffset(x, y).similar(similarity), 30) search_area.click(Pattern(picture).targetOffset(x, y).similar(similarity)) general_functions.writeTestResults("def " + element, "data", "x-coordinate " + str(x), "y-coordinate " + str(y), button, 'similarity ' + str(similarity), "", "")
def does_part_of_screen_exist(subject, similarity, test_case_description): picture = subject + '_' + locale + ".png" the_complete_picture = l_base_dir + 'on till regression test\\test_cases.sikuli\\' + picture print('hier: ' + the_complete_picture) # is there a localized version of the picture, if not use the general version if os.path.isfile(the_complete_picture): print('localized file does exist: ' + picture) else: picture = subject + '.png' print('localized file does NOT exist: ' + picture) print("test picture: " + picture) if exists(Pattern(picture).similar(similarity)): test_result = "OK" reg = find(Pattern(picture).similar(similarity)) else: test_result = "NOK" reg = "" general_functions.writeTestResults(test_case_description, 'GUI', subject, test_result, 'similarity: ' + str(similarity), '', reg, picture)
def gv_sale(): general_functions.errorhandling("ABORT") general_functions.start_of_test_case('gift voucher sale and redemption') wait(10) general_buttons.main_page_footer_menu_btns_click('ITEMS GV') general_buttons.main_page_items_gv_menu_btns_click('GIFT VOUCHER SALE') # TEST CASE if is_gui_test == 'YES': gui_screens.check_gui_element('sale_gift_voucher') type(l_test_settings[0]) type(Key.ENTER) general_functions.extended_wait("payment_page_key_pad_TOTAL", 300) general_buttons.main_page_key_pad_btns_click('TOTAL') general_functions.extended_wait("payment_page_key_pad", 300) # general_functions.pause_test_case_msg() receipt_meta_data_array = general_functions.get_receipt_meta_data() print('receipt_meta_data_array: ' + str(receipt_meta_data_array)) r = Region(165, 183, 221, 21) r.highlight(2) evaluation_string = r.text() print("evaluation str " + evaluation_string) evaluation_string = evaluation_string.replace("I", "1") print("evaluation str " + evaluation_string) evaluation_string = evaluation_string.replace("O", "0") print("evaluation str " + evaluation_string) evaluation_string = evaluation_string.replace("o", "0") print("evaluation str " + evaluation_string) evaluation_string = evaluation_string.replace("|", "1") print("evaluation str " + evaluation_string) evaluation_string = evaluation_string.replace("l", "1") print("evaluation str " + evaluation_string) evaluation_string = evaluation_string.replace(" ", "") print("evaluation str " + evaluation_string) evaluation_string = evaluation_string.replace("?", "9") print("evaluation str " + evaluation_string) gv_number = evaluation_string print("gv number " + gv_number) general_functions.writeTestResults("gift voucher number", "", gv_number, "", "", "", "", "") if brand == "CK": general_functions.general_message_with_subject( 'Check the GV number', 'The GV number we found is ' + gv_number + '. If this not the correct number please write the correct nunmber down on a piece of paper' ) general_functions.pay_transaction_with_multiple_tenders( [['CHINA UNION PAY', 'REST']]) general_functions.fill_basket(l_test_settings[2], l_test_settings[3]) general_buttons.main_page_key_pad_btns_click('TOTAL') general_functions.pay_transaction_with_multiple_tenders( [['GIFT VOUCHER', gv_number, 'REST']]) general_functions.end_of_test_case()
def errors_and_warnings_tc_0010(test_case_description): # non existing user type("589423287") type(Key.ENTER) # supervisor password type(l_general_test_settings[5]) # confirm authentification type(Key.ENTER) sleep(2) picture = "4_eyes_wrong_user_" + locale + ".png" if exists(Pattern(picture).similar(0.85)): test_result = "OK" reg = find(Pattern(picture).similar(0.85)) else: test_result = "NOK" reg = "" general_functions.writeTestResults(test_case_description, "GUI", "errors_and_warnings_tc_0010", test_result, "", "4 eyes form", reg, picture) sleep(2) # close error message type(Key.ENTER) sleep(2) # 4 eyes required type(l_general_test_settings[2]) type(Key.ENTER) type(l_general_test_settings[3]) type(Key.ENTER) sleep(2) picture = "4_eyes_validation_required_" + locale + ".png" if exists(Pattern(picture).similar(0.85)): test_result = "OK" reg = find(Pattern(picture).similar(0.85)) else: test_result = "NOK" reg = "" general_functions.writeTestResults(test_case_description, "GUI", "errors_and_warnings_tc_0010", test_result, "", "4 eyes form", reg, picture) sleep(2) # close error message type(Key.ENTER) sleep(2) # invalid password type(l_general_test_settings[4]) type(Key.ENTER) type("123456789") type(Key.ENTER) sleep(2) picture = "4_eyes_invalid_password_" + locale + ".png" if exists(Pattern(picture).similar(0.85)): test_result = "OK" reg = find(Pattern(picture).similar(0.85)) else: test_result = "NOK" reg = "" general_functions.writeTestResults(test_case_description, "GUI", "errors_and_warnings_tc_0010", test_result, "", "4 eyes form", reg, picture) sleep(2) # close error message type(Key.ENTER) sleep(2) # correct authorization type(l_general_test_settings[4]) type(Key.ENTER) type(l_general_test_settings[5]) type(Key.ENTER) sleep(2)