Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import absolute_import
- import datetime
- import os
- import unittest
- import sys
- from xmlrunner import XMLTestRunner
- from proboscis import test
- from proboscis.asserts import assert_true
- from proboscis.asserts import assert_false
- from lib.q2_framework import Q2Framework
- from lib.q2_testcase import Q2TestCase
- from lib.q2_testcase import critical
- from lib import q2_library
- from pages.ngam.billpay.billpay_page import BillpayPage
- sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
- billpayPage = None
- class NDMBPUT(Q2Framework, Q2TestCase):
- ENV = 'QA430'
- BROWSER = 'CHROME_MAC'
- def __init__(self, testName, args=None):
- global billpayPage
- self.__name__ = "MBPUT"
- self.now = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S-%f')
- self.args = args
- Q2TestCase.__init__(self, testName)
- Q2Framework.__init__(self)
- self.util = q2_library.Utilities()
- self.util.load_config(self)
- self.url = self.util.get_config("base_url")
- ## Really only need one copy.
- if None == billpayPage:
- billpayPage = BillpayPage(self.getDriver())
- self.billpayPage = billpayPage
- @critical
- @test
- def testLoad(self):
- """Load the URL"""
- if None != self.url:
- url = self.url
- else:
- url = None
- self.billpayPage.load(url)
- return self
- @critical
- @test
- def testLogin(self):
- """Login to the app"""
- user = self.args['userautorettmp'] if '19430' in self.url else self.args['userautoret']
- password = self.args['passw']
- self.billpayPage.login(user, password)
- result = self.billpayPage.ensure(1, 'gte', self.billpayPage.get('MAIN_MENU'))
- assert_true(result, "Log into the app")
- return self
- @test
- def testClickMenuIPay(self):
- """Open the iPay Billpays menu"""
- mainMenu = self.args[0]
- subMenu = self.args[1]
- self.billpayPage.click_menu(mainMenu)
- self.billpayPage.wait_til_element_is_clickable(20,
- "//*[contains(@class, 'menu-text') and contains(text(), '" + subMenu + "')]")
- assert_true(True, "The " + mainMenu + " menu failed ot open")
- return self
- @critical
- @test
- def testClickMenuIPayMulti(self):
- """Go to the iPay Multi-Billpay page"""
- subMenu = self.args[1]
- target = self.args[2]
- self.billpayPage.click_menu(subMenu)
- self.billpayPage.wait_til_element_is_clickable(20, "//*[" + self.billpayPage.pageElements[target] + "]")
- assert_true(True, "The " + subMenu + " menu failed ot open")
- return self
- @test
- def testSendAmount(self):
- self.billpayPage.send_key_amount("100", "1")
- return self
- @test
- def testReviewButtonWithoutAmountAndDate(self):
- """Click on the ipay Multi-Billpay Button review """
- self.billpayPage.click_review_payments_button()
- assert_true(self.billpayPage.check_if_error_banner_is_present())
- @test
- def testCloseBanner(self):
- self.billpayPage.close_banner_error_multi_bill_payment()
- assert_false(self.billpayPage.check_if_error_banner_is_present())
- return self
- @critical
- @test
- def testLogoff(self):
- """Log out of the app"""
- self.billpayPage.pause(5)
- self.billpayPage.logoff()
- self.billpayPage.wait_for_element(2, self.billpayPage.get('USERNAME'))
- result = self.billpayPage.ensure(1, 'gte', self.billpayPage.get('USERNAME'))
- self.billpayPage.quit()
- assert_true(result, "Log out of the app")
- return self
- def suite():
- """Define the test suite to run."""
- testData = {
- 'userautoret' : 'autoret',
- 'userautorettmp' : 'autorettmp',
- 'passw' : 'abc1234',
- 'tabTitle' : 'QA_430_Main',
- "menus": [
- (
- "iPay Billpays",
- "iPay Multi-Billpay",
- "payBillsTab"
- ),
- (
- "Commercial",
- "Payments",
- "dummy"
- ),
- (
- "Transactions",
- "Activity Center",
- "dummy"
- ),
- (
- "iPay Billpays",
- "iPay Multi-Billpay",
- "payBillsTab"
- )
- ],
- 'payments' : {
- 'payee' : 'AT&T happy dance',
- 'acct' : 'Reg Chk: XXXX938',
- 'amount' : '345'
- }
- }
- loadSuite = unittest.TestSuite()
- loadSuite.addTest(NDMBPUT("testLoad", testData))
- loginSuite = unittest.TestSuite()
- loginSuite.addTest(NDMBPUT("testLogin", testData))
- navSuite = unittest.TestSuite()
- navSuite.addTest(NDMBPUT("testClickMenuIPay", testData['menus'][0]))
- navSuite.addTest(NDMBPUT("testClickMenuIPayMulti", testData['menus'][0]))
- for menu in testData['menus']:
- navSuite.addTest(NDMBPUT("testClickMenuIPay", menu))
- actionSuite = unittest.TestSuite()
- logoffSuite = unittest.TestSuite()
- logoffSuite.addTest(NDMBPUT("testLogoff"))
- noDateSuite = unittest.TestSuite()
- noDateSuite.addTest(NDMBPUT("testSendAmount"))
- reviewSuite = unittest.TestSuite()
- reviewSuite.addTest(NDMBPUT("testReviewButtonWithoutAmountAndDate"))
- close_banner_suite = unittest.TestSuite()
- close_banner_suite.addTest(NDMBPUT("testCloseBanner"))
- return unittest.TestSuite((loadSuite, loginSuite, navSuite, actionSuite, noDateSuite, reviewSuite, close_banner_suite, logoffSuite))
- if __name__ == '__main__':
- if len(sys.argv) == 2:
- NDMBPUT.ENV = sys.argv.pop()
- if len(sys.argv) == 3:
- NDMBPUT.BROWSER = sys.argv.pop()
- NDMBPUT.ENV = sys.argv.pop()
- with open('./test-reports/junit.xml', 'wb') as output:
- testRunner = XMLTestRunner(output=output)
- testRunner.run(suite())
Add Comment
Please, Sign In to add comment