Guest User

Untitled

a guest
Apr 19th, 2017
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.08 KB | None | 0 0
  1. from __future__ import absolute_import
  2. import datetime
  3. import os
  4. import unittest
  5. import sys
  6. from xmlrunner import XMLTestRunner
  7.  
  8. from proboscis import test
  9. from proboscis.asserts import assert_true
  10. from proboscis.asserts import assert_false
  11.  
  12. from lib.q2_framework import Q2Framework
  13.  
  14. from lib.q2_testcase import Q2TestCase
  15. from lib.q2_testcase import critical
  16.  
  17. from lib import q2_library
  18.  
  19. from pages.ngam.billpay.billpay_page import BillpayPage
  20.  
  21.  
  22. sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
  23.  
  24. billpayPage = None
  25.  
  26. class NDMBPUT(Q2Framework, Q2TestCase):
  27. ENV = 'QA430'
  28. BROWSER = 'CHROME_MAC'
  29.  
  30. def __init__(self, testName, args=None):
  31. global billpayPage
  32.  
  33. self.__name__ = "MBPUT"
  34. self.now = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S-%f')
  35. self.args = args
  36.  
  37. Q2TestCase.__init__(self, testName)
  38. Q2Framework.__init__(self)
  39.  
  40. self.util = q2_library.Utilities()
  41. self.util.load_config(self)
  42. self.url = self.util.get_config("base_url")
  43.  
  44. ## Really only need one copy.
  45. if None == billpayPage:
  46. billpayPage = BillpayPage(self.getDriver())
  47.  
  48. self.billpayPage = billpayPage
  49.  
  50. @critical
  51. @test
  52. def testLoad(self):
  53. """Load the URL"""
  54.  
  55. if None != self.url:
  56. url = self.url
  57. else:
  58. url = None
  59.  
  60. self.billpayPage.load(url)
  61. return self
  62.  
  63.  
  64. @critical
  65. @test
  66. def testLogin(self):
  67. """Login to the app"""
  68.  
  69. user = self.args['userautorettmp'] if '19430' in self.url else self.args['userautoret']
  70. password = self.args['passw']
  71.  
  72. self.billpayPage.login(user, password)
  73. result = self.billpayPage.ensure(1, 'gte', self.billpayPage.get('MAIN_MENU'))
  74. assert_true(result, "Log into the app")
  75. return self
  76.  
  77. @test
  78. def testClickMenuIPay(self):
  79. """Open the iPay Billpays menu"""
  80.  
  81. mainMenu = self.args[0]
  82. subMenu = self.args[1]
  83.  
  84. self.billpayPage.click_menu(mainMenu)
  85. self.billpayPage.wait_til_element_is_clickable(20,
  86. "//*[contains(@class, 'menu-text') and contains(text(), '" + subMenu + "')]")
  87. assert_true(True, "The " + mainMenu + " menu failed ot open")
  88. return self
  89.  
  90. @critical
  91. @test
  92. def testClickMenuIPayMulti(self):
  93. """Go to the iPay Multi-Billpay page"""
  94.  
  95. subMenu = self.args[1]
  96. target = self.args[2]
  97.  
  98. self.billpayPage.click_menu(subMenu)
  99. self.billpayPage.wait_til_element_is_clickable(20, "//*[" + self.billpayPage.pageElements[target] + "]")
  100. assert_true(True, "The " + subMenu + " menu failed ot open")
  101. return self
  102.  
  103. @test
  104. def testSendAmount(self):
  105. self.billpayPage.send_key_amount("100", "1")
  106. return self
  107.  
  108. @test
  109. def testReviewButtonWithoutAmountAndDate(self):
  110. """Click on the ipay Multi-Billpay Button review """
  111. self.billpayPage.click_review_payments_button()
  112. assert_true(self.billpayPage.check_if_error_banner_is_present())
  113.  
  114.  
  115. @test
  116. def testCloseBanner(self):
  117. self.billpayPage.close_banner_error_multi_bill_payment()
  118. assert_false(self.billpayPage.check_if_error_banner_is_present())
  119. return self
  120. @critical
  121. @test
  122. def testLogoff(self):
  123. """Log out of the app"""
  124.  
  125. self.billpayPage.pause(5)
  126. self.billpayPage.logoff()
  127. self.billpayPage.wait_for_element(2, self.billpayPage.get('USERNAME'))
  128. result = self.billpayPage.ensure(1, 'gte', self.billpayPage.get('USERNAME'))
  129. self.billpayPage.quit()
  130. assert_true(result, "Log out of the app")
  131. return self
  132.  
  133. def suite():
  134. """Define the test suite to run."""
  135. testData = {
  136. 'userautoret' : 'autoret',
  137. 'userautorettmp' : 'autorettmp',
  138. 'passw' : 'abc1234',
  139. 'tabTitle' : 'QA_430_Main',
  140.  
  141. "menus": [
  142. (
  143. "iPay Billpays",
  144. "iPay Multi-Billpay",
  145. "payBillsTab"
  146. ),
  147. (
  148. "Commercial",
  149. "Payments",
  150. "dummy"
  151. ),
  152. (
  153. "Transactions",
  154. "Activity Center",
  155. "dummy"
  156. ),
  157. (
  158. "iPay Billpays",
  159. "iPay Multi-Billpay",
  160. "payBillsTab"
  161. )
  162. ],
  163. 'payments' : {
  164. 'payee' : 'AT&T happy dance',
  165. 'acct' : 'Reg Chk: XXXX938',
  166. 'amount' : '345'
  167. }
  168. }
  169.  
  170. loadSuite = unittest.TestSuite()
  171. loadSuite.addTest(NDMBPUT("testLoad", testData))
  172.  
  173. loginSuite = unittest.TestSuite()
  174. loginSuite.addTest(NDMBPUT("testLogin", testData))
  175.  
  176. navSuite = unittest.TestSuite()
  177. navSuite.addTest(NDMBPUT("testClickMenuIPay", testData['menus'][0]))
  178. navSuite.addTest(NDMBPUT("testClickMenuIPayMulti", testData['menus'][0]))
  179.  
  180. for menu in testData['menus']:
  181. navSuite.addTest(NDMBPUT("testClickMenuIPay", menu))
  182.  
  183. actionSuite = unittest.TestSuite()
  184.  
  185. logoffSuite = unittest.TestSuite()
  186. logoffSuite.addTest(NDMBPUT("testLogoff"))
  187.  
  188. noDateSuite = unittest.TestSuite()
  189. noDateSuite.addTest(NDMBPUT("testSendAmount"))
  190.  
  191. reviewSuite = unittest.TestSuite()
  192. reviewSuite.addTest(NDMBPUT("testReviewButtonWithoutAmountAndDate"))
  193.  
  194. close_banner_suite = unittest.TestSuite()
  195. close_banner_suite.addTest(NDMBPUT("testCloseBanner"))
  196. return unittest.TestSuite((loadSuite, loginSuite, navSuite, actionSuite, noDateSuite, reviewSuite, close_banner_suite, logoffSuite))
  197.  
  198.  
  199. if __name__ == '__main__':
  200. if len(sys.argv) == 2:
  201. NDMBPUT.ENV = sys.argv.pop()
  202. if len(sys.argv) == 3:
  203. NDMBPUT.BROWSER = sys.argv.pop()
  204. NDMBPUT.ENV = sys.argv.pop()
  205. with open('./test-reports/junit.xml', 'wb') as output:
  206. testRunner = XMLTestRunner(output=output)
  207. testRunner.run(suite())
Add Comment
Please, Sign In to add comment