def test_2menu_click_Validation_in_sequence(setup):
    print("2menu_click_Validation_in_sequence called........")
    BankAPP_CommonFunctions.login_bankApp(driver,
                                          BankAPP_CommonFunctions.username,
                                          BankAPP_CommonFunctions.Password)
    BankAPP_CommonFunctions.close_popup(driver)
    dict_menu = {
        "Manag": "Manager",
        "New Cust": "New Customer",
        "Edit Cust": "Edit Customer",
        "Delete Cust": "Delete Customer",
        "New Acc": "new account",
        "Edit Acc": "Edit Account",
        "Delete Acc": "Delete Account",
        "Deposit": "Deposit",
        "Withdrawal": "Withdrawal",
        "Fund Transfer": "Fund transfer",
        "Change Pass": "******",
        "Balance Enq": "Balance Enquiry",
        "Mini State": "Mini Statement",
        "Customised State": "Customized Statement"
    }

    TC_MenuClickInSequenceTest.menu_click_sequence(driver, dict_menu)
    BankAPP_CommonFunctions.logout(driver)
def test_5delete_customer(setup):
    print("5delete_customer called..............")
    BankAPP_CommonFunctions.login_bankApp(driver,
                                          BankAPP_CommonFunctions.username,
                                          BankAPP_CommonFunctions.Password)
    BankAPP_CommonFunctions.click_menu_by_partial_link_text(
        driver, "Delete Cust", "Delete Customer")
    TC_DeleteCustomerTest.search_cust_BYID_Delete(driver, "19943", "Yes")
    BankAPP_CommonFunctions.logout(driver)
def test_8delete_account(setup):
    print("8delete_account called............")
    BankAPP_CommonFunctions.login_bankApp(driver,
                                          BankAPP_CommonFunctions.username,
                                          BankAPP_CommonFunctions.Password)
    BankAPP_CommonFunctions.close_popup(driver)
    account_id_delete = TC_DeleteAccountTest.create_dummy_account(driver)
    print("Acc id to delete:", account_id_delete)
    BankAPP_CommonFunctions.close_popup(driver)
    BankAPP_CommonFunctions.click_menu_by_partial_link_text(
        driver, "Delete Acc", "Delete Account")
    TC_DeleteAccountTest.search_acc_BYID_Delete(driver, account_id_delete,
                                                "Yes")
    BankAPP_CommonFunctions.logout(driver)
def test_3add_customer(setup):
    print("3add_customer called..........")
    BankAPP_CommonFunctions.login_bankApp(driver,
                                          BankAPP_CommonFunctions.username,
                                          BankAPP_CommonFunctions.Password)
    BankAPP_CommonFunctions.click_menu_by_partial_link_text(
        driver, "New Cust", "New Customer")
    TC_AddCustomerTest.add_customer(driver, "M")
    TC_AddCustomerTest.validate_custinfo(driver)

    # Click Continue
    driver.find_element_by_xpath(
        "//*[@id='customer']/tbody/tr[14]/td/a").click()
    driver.implicitly_wait(1)
    BankAPP_CommonFunctions.logout(driver)
def test_4edit_customer(setup):
    print("4edit_customer................")
    BankAPP_CommonFunctions.login_bankApp(driver,
                                          BankAPP_CommonFunctions.username,
                                          BankAPP_CommonFunctions.Password)
    BankAPP_CommonFunctions.click_menu_by_partial_link_text(
        driver, "Edit Cust", "Edit Customer")
    cust_id_modify = BankAPP_CommonFunctions.get_cust_id_frm_repo(
        "LastAdded_CustID.txt", 0)
    bool_true = TC_EditCustmerTest.search_cust_BYID(driver, cust_id_modify)
    print("ID has Searched?:", bool_true)

    TC_EditCustmerTest.edit_address(driver, cust_id_modify)
    # Click Continue
    driver.find_element_by_xpath(
        "//*[@id='customer']/tbody/tr[14]/td/a").click()
    driver.implicitly_wait(1)
    BankAPP_CommonFunctions.logout(driver)
def test_7edit_account(setup):
    print("7edit_account called........")
    BankAPP_CommonFunctions.login_bankApp(driver,
                                          BankAPP_CommonFunctions.username,
                                          BankAPP_CommonFunctions.Password)
    BankAPP_CommonFunctions.close_popup(driver)
    BankAPP_CommonFunctions.click_menu_by_partial_link_text(
        driver, "Edit Acc", "Edit Account")
    acc_id = BankAPP_CommonFunctions.get_cust_id_frm_repo(
        "LastAdded_AccountID_CustID.txt", 1)
    searched = TC_EditAccountTest.search_account_BYID(driver, acc_id)
    print(searched)
    TC_EditAccountTest.edit_account_type(driver)

    # Click continue
    driver.find_element_by_xpath(
        "//*[@id='account']/tbody/tr[11]/td/a").click()
    driver.implicitly_wait(1)
    BankAPP_CommonFunctions.logout(driver)
def test_6add_account(setup):
    print("6add_account called............")
    BankAPP_CommonFunctions.login_bankApp(driver,
                                          BankAPP_CommonFunctions.username,
                                          BankAPP_CommonFunctions.Password)
    BankAPP_CommonFunctions.close_popup(driver)
    BankAPP_CommonFunctions.click_menu_by_perform_mouse_action(
        driver, "New Acc", "new account")
    cust_id = BankAPP_CommonFunctions.get_cust_id_frm_repo(
        "LastAdded_CustID.txt", 0)
    account_type, initial_amt = TC_AddAccountTest.add_account_details(
        driver, cust_id, "Current", 3000)
    print(account_type, initial_amt)
    TC_AddAccountTest.validate_account_info(driver, account_type, initial_amt)

    # Click continue
    driver.find_element_by_xpath(
        "//*[@id='account']/tbody/tr[11]/td/a").click()
    driver.implicitly_wait(1)
    BankAPP_CommonFunctions.logout(driver)
    def login_with_diff_credentials(driver, excel_path, excel_sheet, app_url):
        rows = Excelutility.get_row_count(excel_path, excel_sheet)
        # self.site_open()

        for row in range(2, rows + 1):
            print(row)
            username = Excelutility.read_data(excel_path, excel_sheet, row, 1)
            print("Current username:"******"Current Password:"******"uid").send_keys(username)
            driver.find_element_by_name("password").send_keys(password)
            time.sleep(1)
            error = "Shri"
            try:
                driver.find_element_by_xpath(
                    "/html/body/form/table/tbody/tr[3]/td[2]/input[1]").click(
                    )
                time.sleep(1)
                if BankAPP_CommonFunctions.get_modal_alert(driver):
                    error = driver.switch_to.alert.text
                    driver.switch_to.alert.accept()
                    print("Login Failed with :", error)
                    Excelutility.write_data(excel_path, excel_sheet, row, 3,
                                            "Test Failed")
                else:
                    if "Guru99 Bank Manager HomePage" in driver.title:
                        print("Login is successful")
                        Excelutility.write_data(excel_path, excel_sheet, row,
                                                3, "Test Passed")
                    else:
                        print("Failed to login")
                        Excelutility.write_data(excel_path, excel_sheet, row,
                                                3, "Test Failed")
            except Exception as e:
                print('Error on line {}'.format(sys.exc_info()[-1].tb_lineno),
                      type(e).__name__, e)
                # print("Failed to login as", error)
                Excelutility.write_data(excel_path, excel_sheet, row, 3,
                                        "Test Failed")
                driver.refresh()
                driver.get(app_url)
                driver.set_page_load_timeout(10)
            finally:
                print("Completed Iteration with excel row no :", row)

            if "User or Password is not valid" not in error:
                BankAPP_CommonFunctions.close_popup(driver)
                driver.execute_script(
                    "window.scrollBy(0,document.body.scrollHeight)")
                time.sleep(1)
                BankAPP_CommonFunctions.logout(driver)

    # def test_validationNavigation(self):
    #     self.login_with_diff_credentials(self.driver,self.Path,self.SheetName,self.url)

    # @classmethod
    # def tearDownClass(cls):
    #     cls.driver.close()


# if __name__ == "__main__":
#     unittest.main()