Advertisement
Guest User

Untitled

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