Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import unittest
- import sys
- import xmlrunner
- sys.path.append(os.path.join(os.path.dirname(__file__), '../../..'))
- from lib import q2_library
- from pages.ngam import main_page, login_page
- from pages.ngam.commercial.payments import payments, payment_setup_page
- from pages.ngam.transactions import activity_center
- class AchPaymentApproveTest(unittest.TestCase):
- driver = None
- util = None
- trackingId = None
- authorizedBy = None
- ENV = 'CI'
- BROWSER = 'CHROME_MAC'
- @classmethod
- def setUpClass(cls):
- cls.util = q2_library.Utilities()
- cls.util.load_config(cls)
- cls.input = cls.util.read_data_file('payments/ach_payment_data.dat')["achPaymentData"]
- cls.driver = cls.util.get_browser()
- cls.url = cls.util.get_config("base_url")
- cls.user = cls.util.get_credentials('payments1')
- cls.password = cls.util.get_credentials('passwordp1')
- def test_01_navigation(self):
- self.driver.get(self.url)
- self.driver.maximize_window()
- self.assertIn("4", self.driver.title, "Checking the title has the correct value")
- def test_02_login_successful(self):
- login = login_page.LoginPage(self.driver)
- login.enter_username(self.user)
- login.enter_password(self.password)
- self.main_page = login.click_submit_button()
- msg = self.main_page.validate_welcome_msg()
- self.assertIn('Welcome back', msg, "Login was successful")
- def test_03_payments(self):
- self.menu = main_page.Menu(self.driver)
- self.menu.open_menu_item('Commercial')
- self.payment_page = self.menu.open_menu_child_item('Payments')
- self.payment_page.wait_for_page_to_load()
- self.assertTrue(self.payment_page.is_page_loaded(), "Checking that the Payments Page got loaded")
- def test_04_ach_payments(self):
- self.payment_page = payments.PaymentsPage(self.driver)
- self.payment_page.click_new_payment_drop_down()
- self.payment_page.click_new_payment_dropdown_val("ACH Payment")
- self.assertTrue(payment_setup_page.PaymentsSetupPage(self.driver).is_ach_rec_or_setup_wire_loaded(), "Checking that the Receipient & Amount tab got loaded")
- def test_05_recipient_amount_tab(self):
- self.payment_setup_page = payment_setup_page.PaymentsSetupPage(self.driver)
- self.payment_setup_page.choose_recipient(self.input["type"], self.input["recipient"], 1, 1, 'List')
- self.payment_setup_page.wait_for_account_and_addendum_fields()
- self.payment_setup_page.enter_amount(self.input["type"], self.input["recipient"], self.input["amount"], 1,'List')
- self.payment_setup_page.enter_addendum(self.input["recipient"], self.input["addendum"], 'List')
- self.payment_setup_common_functions = payment_setup_page.PaymentsSetupCommonFunctions(self.driver)
- self.payment_setup_common_functions.click_next_button()
- self.assertTrue(self.payment_setup_page.is_ach_subsidiary_page_loaded(), "Checking that the Subsidiary tab got loaded")
- def test_06_subsidiary_tab(self):
- self.payment_setup_page = payment_setup_page.PaymentsSetupPage(self.driver)
- self.payment_setup_page.choose_subsidiary(self.input["type"], self.input["subsidiary"], 1, 0, 'List')
- self.payment_setup_common_functions = payment_setup_page.PaymentsSetupCommonFunctions(self.driver)
- self.payment_setup_common_functions.click_next_button()
- self.assertTrue(self.payment_setup_page.is_ach_from_acc_page_loaded, "Checking that the Account tab got loaded")
- def test_07_accounts_tab(self):
- self.payment_setup_page = payment_setup_page.PaymentsSetupPage(self.driver)
- self.payment_setup_page.choose_from_account(self.input["type"], self.input["account"])
- self.payment_setup_common_functions = payment_setup_page.PaymentsSetupCommonFunctions(self.driver)
- self.payment_setup_common_functions.click_next_button()
- self.assertTrue(self.payment_setup_page.is_ach_review_page_loaded(), "Checking that the Review & Submit tab got loaded")
- def test_08_review_submit_tab(self):
- self.payment_setup_page = payment_setup_page.PaymentsSetupPage(self.driver)
- self.payment_setup_page.choose_date()
- isAchClassCodeCorrect = self.payment_setup_page.get_ach_class_code_in_overview(self.input["type"]) == self.input["ach_class_code_in_overview"]
- isTotalAmountCorrect = self.payment_setup_page.get_total_amt_in_overview(self.input["type"]) == self.input["total_amount_in_overview"]
- isSendPaymentAsCorrect = self.payment_setup_page.get_send_payment_as_str(self.input["type"]) == self.input["subsidiary"]
- isFromAccountCorrect = self.payment_setup_page.get_txt_frm_acc_overview(self.input["type"]) == self.input["from_acount_in_overview"]
- isRecipientCorrect = self.payment_setup_page.get_rec_display_name(self.input["type"]) == self.input["recipient"]
- self.assertTrue(isAchClassCodeCorrect and isTotalAmountCorrect and isSendPaymentAsCorrect and
- isFromAccountCorrect and isRecipientCorrect, "Checking that overview information is correct")
- self.payment_setup_page.page.screenshot()
- def test_09_validate_modal(self):
- self.payment_setup_page = payment_setup_page.PaymentsSetupPage(self.driver)
- self.payment_setup_page.click_approve(self.input["type"])
- isTitleCorrect = self.payment_setup_page.get_modal_title(self.input["type"], self.input["modal_type"]) == self.input["modal_title"]
- isColorCorrect = self.payment_setup_page.get_modal_color(self.input["type"], self.input["modal_type"]) == self.input["modal_color"]
- isSubsidiaryCorrect = self.payment_setup_page.get_ach_approve_modal_data("From Subsidiary") == self.input["modal_from_subsidiary"]
- isAccountCorrect = self.payment_setup_page.get_ach_approve_modal_data("From Account") == self.input["modal_from_account"]
- isAmountCorrect = self.payment_setup_page.get_ach_approve_modal_data("Amount") == self.input["modal_amount"]
- isDateCorrect = self.payment_setup_page.get_selected_date() in self.payment_setup_page.get_ach_approve_modal_data("Date")
- global authorizedBy
- authorizedBy = payment_setup_page.PaymentsSetupCommonFunctions(self.driver).get_drafted_by()
- isDraftedByCorrect = authorizedBy in self.payment_setup_page.get_ach_approve_modal_data("Drafted By")
- global trackingId
- trackingId = self.payment_setup_page.get_ach_approve_modal_tracking_id()
- isTrackingIdValid = len(trackingId) > 0
- self.assertTrue(isColorCorrect and isTitleCorrect and isAmountCorrect and isAccountCorrect and
- isSubsidiaryCorrect and isDateCorrect and isDraftedByCorrect and isTrackingIdValid, "Checking that the modal information is correct")
- self.payment_setup_page.page.screenshot()
- def test_10_go_to_activity_center(self):
- self.payment_setup_page = payment_setup_page.PaymentsSetupPage(self.driver)
- self.payment_setup_page.go_to_activity_center(self.input["type"], self.input["modal_type"])
- self.activity_center = activity_center.ActivityCenterPage(self.driver)
- self.activity_center.wait_for_page_to_load()
- self.assertTrue(self.activity_center.is_single_transactions_tab_loaded() and self.activity_center.is_row_expanded(1), "Checking that the Activity Center got loaded")
- def test_11_validate_title_line_activity_center(self):
- global trackingId
- self.activity_center = activity_center.ActivityCenterPage(self.driver)
- isHeaderDateValid = len(self.activity_center.return_header_date()) > 0
- areHeaderApprovalsCorrect = self.activity_center.return_header_approvals() == self.input["header_approvals"]
- isHeaderStatusCorrect = self.activity_center.return_header_status() == self.input["header_status"]
- isTransactionTypeCorrect = self.activity_center.return_header_trans_type() == 'ACH Payment - Tracking ID: ' + trackingId
- isAccountCorrect = self.activity_center.return_header_account() == self.input["header_account"]
- isAmountCorrect = self.activity_center.return_header_amount() == '$' + self.input["amount"]
- self.assertTrue(isHeaderDateValid and areHeaderApprovalsCorrect and isHeaderStatusCorrect and
- isTransactionTypeCorrect and isAccountCorrect and isAmountCorrect,"Checking that the header fields are correct")
- def test_12_validate_data_activity_center(self):
- global trackingId
- global authorizedBy
- self.activity_center = activity_center.ActivityCenterPage(self.driver)
- isTrackingIdCorrect = trackingId == self.activity_center.return_tracking_id
- isCreatedDateValid = len(self.activity_center.return_created_date()) > 0
- isCreatedByCorrect = self.activity_center.return_created_by() == authorizedBy
- isAuthDateValid = len(self.activity_center.return_auth_date()) > 0
- isProcessDateValid = len(self.activity_center.return_process_date()) > 0
- isAmountCorrect = self.activity_center.return_item_amount()
- isFromAccountCorrect = self.activity_center.return_item_from_account() == self.input["header_account"]
- isRecipientNameCorrect = self.activity_center.return_item_recipient_name() == self.input["recipient"]
- isRecipientAchNameCorrect = self.activity_center.return_item_recipient_ach_name() == self.input["recipient"]
- isRecipientAccountNumberCorrect = self.activity_center.return_item_rec_account_num() == self.input["recipient_account"]
- isAchClassCodeCorrect = self.activity_center.return_item_recipient_ach_class_code() == self.input["ach_class_code"]
- isAddendaCorrect = self.activity_center.return_item_rec_addenda() == self.input["ach_recipient_addenda"]
- isAchHeaderCorrect = self.activity_center.return_item_ach_header() == self.input["ach_header"]
- self.assertTrue(isTrackingIdCorrect and isCreatedDateValid and isCreatedByCorrect and isAmountCorrect and isAuthDateValid and isProcessDateValid and
- isFromAccountCorrect and isRecipientAccountNumberCorrect and isRecipientAchNameCorrect and isRecipientNameCorrect and
- isAchClassCodeCorrect and isAddendaCorrect and isAchHeaderCorrect,
- "Checking that the data from activity center is correct")
- def setUp(self):
- self.util.set_up(self)
- def tearDown(self):
- self.util.tear_down(self)
- @classmethod
- def tearDownClass(cls):
- cls.util.close_the_browser(cls.driver)
- if __name__ == '__main__':
- if len(sys.argv) == 2:
- AchPaymentApproveTest.ENV = sys.argv.pop()
- if len(sys.argv) == 3:
- AchPaymentApproveTest.BROWSER = sys.argv.pop()
- AchPaymentApproveTest.ENV = sys.argv.pop()
- with open('test-reports/junit.xml', 'wb') as output:
- unittest.main(testRunner=xmlrunner.XMLTestRunner(output=output),
- failfast=False, buffer=False, catchbreak=False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement