Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import importer
- import unittest
- import xmlrunner
- from lib import q2_library, modal_page
- from pages.ngam import main_page, login_page
- from pages.ngam.commercial.payments import payments
- from pages.ngam.transactions import activity_center_page
- class TSTR_1947_dualactionzerolimit_ach_batch_approve(unittest.TestCase):
- driver = None
- util = 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/tstr_1947_data.json')
- cls.driver = cls.util.get_browser(5)
- cls.url = cls.util.get_config("base_url")
- cls.user = cls.util.get_credentials('dual_action_user')
- cls.password = cls.util.get_credentials('password_ma')
- cls.user2 = cls.util.get_credentials('dual_actionfx_user')
- cls.current_page = None
- cls.tracking_id = None
- def test_01_login_successful(self):
- """Login the app"""
- self.driver.get(self.url)
- self.driver.maximize_window()
- 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_02_payments(self):
- """Going to payments menu page"""
- self.menu = main_page.Menu(self.driver)
- self.menu.open_menu_item(self.input['commercial_menu'])
- self.payment_page = self.menu.open_menu_child_item(self.input['payments_menu'])
- self.payment_page.wait_for_page_to_load()
- self.__class__.current_page = self.payment_page
- self.assertTrue(self.payment_page.is_page_loaded(), "Checking that the Payments Page got loaded")
- def test_03_ach_batch_template(self):
- """Setting the template"""
- self.payment_page = payments.PaymentsPage(self.driver)
- self.payment_page.click_new_payment_drop_down()
- recipient_and_amount_page = self.payment_page.click_new_payment_dropdown_val(self.input['template_type'])
- recipient_and_amount_page.wait_for_page_to_load()
- self.__class__.current_page = recipient_and_amount_page
- self.assertTrue(recipient_and_amount_page.is_page_loaded(), "Checking that the Info and Users tab got loaded")
- def test_04_recipient_amount_tab(self):
- """Going to Subsidiary Tab"""
- recipient_amount_tab = self.current_page
- recipient_amount_tab.select_list_view()
- recipient_amount_tab.choose_recipient(self.input["recipient1"])
- recipient_amount_tab.wait_for_amount_and_addendum_fields()
- recipient_amount_tab.enter_amount(self.input["recipient1"], self.input["amount1"])
- recipient_amount_tab.enter_addendum(self.input["recipient1"], self.input["addendum1"])
- recipient_amount_tab.choose_recipient(self.input["recipient2"])
- recipient_amount_tab.wait_for_amount_and_addendum_fields()
- recipient_amount_tab.enter_amount(self.input["recipient2"], self.input["amount2"])
- recipient_amount_tab.enter_addendum(self.input["recipient2"], self.input["addendum2"])
- subsidiary_tab = recipient_amount_tab.click_next_button()
- self.__class__.current_page = subsidiary_tab
- self.assertTrue(subsidiary_tab.is_page_loaded(), "Checking that the Subsidiary tab got loaded")
- def test_05_go_subsidiary_tab(self):
- """Going to Account tab"""
- subsidiary_tab = self.current_page
- account_tab = subsidiary_tab.click_next_button()
- self.__class__.current_page = account_tab
- self.assertTrue(account_tab.is_page_loaded(), "Checking that the Account tab got loaded")
- def test_06_go_accounts_tab(self):
- """Going to Review and submit tab """
- account_tab = self.current_page
- account_tab.choose_from_account(self.input["account"])
- account_tab.scroll_the_page(x=0, y=-1)
- review_submit_tab = account_tab.click_next_button()
- self.__class__.current_page = review_submit_tab
- self.assertTrue(review_submit_tab.is_page_loaded(), "Checking that the Review & Submit tab got loaded")
- def test_07_go_review_submit_tab(self):
- """Submitting transaction """
- review_submit_tab = self.current_page
- review_submit_tab.select_date()
- review_submit_tab.page.scroll_the_page(x=0, y=-50)
- is_alert_present = review_submit_tab.is_error_message_present('You cannot approve this transaction: Action required by other user')
- review_submit_tab.page.scroll_the_page(x=0, y=300)
- is_draft_disabled = review_submit_tab.is_draft_enabled()
- is_approve_disabled = not review_submit_tab.is_approve_enabled()
- is_ach_class_code_correct = review_submit_tab.get_ach_class_code_in_overview() == self.input[
- "ach_class_code_in_overview"]
- is_total_amount_correct = review_submit_tab.get_total_amt_in_overview() == self.input[
- "total_amount_in_overview"]
- is_send_payment_as_correct = review_submit_tab.get_send_payment_as_str() == self.input["subsidiary"]
- is_from_account_correct = self.input[
- "from_account_in_overview"] in review_submit_tab.get_txt_frm_acc_overview()
- is_recipient1_correct = review_submit_tab.get_rec_display_name(1) == self.input["recipient1"]
- is_recipient2_correct = review_submit_tab.get_rec_display_name(2) == self.input["recipient2"]
- self.assertTrue(
- is_alert_present and is_draft_disabled and is_approve_disabled and is_ach_class_code_correct and is_total_amount_correct and is_send_payment_as_correct and
- is_from_account_correct and is_recipient1_correct and is_recipient2_correct,
- "Checking that overview information is correct")
- def test_08_draft_review_tab(self):
- """Click on draft button"""
- review_submit_tab = self.current_page
- review_submit_tab.page.scroll_the_page(x=1, y=-1)
- draft_modal_page = review_submit_tab.click_draft()
- self.__class__.current_page = draft_modal_page
- draft_ach_color = draft_modal_page.get_modal_color() == self.input["ach_batch_color"]
- draft_ach_message = draft_modal_page.get_modal_text() == self.input[
- "ach_batch_message"]
- self.__class__.tracking_id = draft_modal_page.get_ach_draft_modal_data("Tracking ID").split("Tracking ID: #", 1)[1]
- draft_modal_page.go_to_activity_center()
- self.assertTrue(draft_ach_color and draft_ach_message, "Check if one of the previous validations are false")
- def test_09_go_to_activity_center(self):
- """Going to Activity Center Page"""
- self.__class__.current_page = activity_center_page.ActivityCenterPage(self.driver)
- activity_center_p = self.current_page
- activity_center_p.wait_for_page_to_load()
- self.assertTrue(activity_center_p.is_activity_center_page_loaded())
- def test_10_check_transaction(self):
- """Checking the transaction information """
- activity_center_p = self.current_page
- header_status = activity_center_p.return_header_status() == self.input["header_status"]
- approval_header = activity_center_p.return_header_approvals() == self.input["header_approvals"]
- approval_dropdown_element = not activity_center_p.is_actions_menu_item_present(self.input["dropdown_action"])
- step_state = str(activity_center_p.get_trans_fld_data(self.input["trans_approve_fld"], "1.")).split(".")[1] == self.input["trans_draft_fld"]
- self.assertTrue(header_status and approval_header and approval_dropdown_element and step_state,
- "Check if one or more validations are correct")
- def test_11_log_off(self):
- """Logging off the app"""
- self.menu = main_page.Menu(self.driver)
- self.menu.open_menu_item('Log Off')
- self.__class__.current_page = login_page.LoginPage(self.driver)
- self.current_page.wait_for_page_to_load()
- self.assertTrue(self.current_page.is_login_page_loaded(), "Checking that the user logged off correctly")
- def test_12_login_successful(self):
- """Login into the app"""
- self.current_page.enter_username(self.user2)
- self.current_page.enter_password(self.password)
- self.__class__.current_page = self.current_page.click_submit_button()
- msg = self.current_page.validate_welcome_msg()
- self.assertIn('Welcome back', msg, "Login was successful")
- def test_13_go_to_activity_center(self):
- """Going to Activity Center Page"""
- self.menu = main_page.Menu(self.driver)
- self.menu.open_menu_item(self.input['transaction_menu'])
- self.activity_center_page = self.menu.open_menu_child_item(self.input['activity_center'])
- self.activity_center_page.wait_for_page_to_load()
- self.assertTrue(self.activity_center_page.is_page_loaded(), "Checking that the Activity Center page got loaded")
- def test_14_check_transaction(self):
- """Checking the transaction information """
- self.__class__.current_page = activity_center_page.ActivityCenterPage(self.driver)
- activity_center_p = self.current_page
- activity_center_p.filter_by_trans_id(self.tracking_id)
- activity_center_p.select_transaction_type_from_dropdown(self.input["transaction_type"])
- activity_center_p.click_column_to_display(self.input["checkbox_filter_option"])
- activity_center_p.click_apply_filter()
- activity_center_p.expand_transaction()
- header_status = activity_center_p.return_header_status() == self.input["header_status"]
- approval_header = activity_center_p.return_header_approvals() == self.input["header_approvals"]
- is_approval_option_present = activity_center_p.is_actions_menu_item_present(self.input["dropdown_action"])
- step_state = str(activity_center_p.get_trans_fld_data(self.input["trans_approve_fld"], "1.")).split(".")[1] == \
- self.input["trans_draft_fld"]
- self.assertTrue(header_status and approval_header and is_approval_option_present and step_state,
- "Check for some of the previous validations to ensure those are True")
- def test_15_approve_transaction(self):
- """Approving the transaction"""
- activity_center_p = self.current_page
- activity_center_p.scroll_the_page(x=0, y=100)
- activity_center_p.click_actions_menu_item(self.input["dropdown_action"])
- activity_center_p.click_confirm()
- approve_modal_page = modal_page.ModalPage(self.driver)
- approve_draft_color = approve_modal_page.return_title_color() == self.input["ach_approval_color"]
- approve_modal_page.click_close_modal()
- self.assertTrue(approve_draft_color, "The Title color is not green for the Approval Modal")
- def test_16_go_to_activity_center(self):
- """Going to Activity Center Page"""
- activity_center_p = self.current_page
- header_status = activity_center_p.return_header_status() == self.input["header_status_auth"]
- approval_header = activity_center_p.return_header_approvals() == self.input["header_approvals_auth"]
- activity_center_p.scroll_the_page(x=0, y=100)
- approval_dropdown_element = activity_center_p.is_actions_menu_item_present(self.input["dropdown_action"])
- step_state = str(activity_center_p.get_trans_fld_data(self.input["trans_approve_fld"], "1.")).split("\n")[1] == self.input["trans_draft_fld_auth"]
- self.assertTrue(header_status and approval_header and approval_dropdown_element == False and step_state,
- "Check if one or more validations are correct")
- def test_17_log_off(self):
- """Logging off the app"""
- self.menu = main_page.Menu(self.driver)
- self.menu.open_menu_item('Log Off')
- self.__class__.current_page = login_page.LoginPage(self.driver)
- self.current_page.wait_for_page_to_load()
- self.assertTrue(self.current_page.is_login_page_loaded(), "Checking that the user logged off correctly")
- 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__':
- q2_library.Utilities().set_parameters_to_this(TSTR_1947_dualactionzerolimit_ach_batch_approve)
- with open('test-reports/TSTR_1947_dualactionzerolimit_ach_batch_approve.xml', 'wb') as output:
- unittest.main(testRunner=xmlrunner.XMLTestRunner(output=output, verbosity=2),
- failfast=False, buffer=False, catchbreak=False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement