Guest User

Untitled

a guest
Jun 30th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.31 KB | None | 0 0
  1. import XCTest
  2.  
  3.  
  4. class UIBottleFeedsTestCase: UITestCase {
  5.  
  6. var loginTestScreen: UITestLoginScreen!
  7. var mainMenuTestScreen: UIMainMenuTestScreen!
  8. var dailyMenuTestScreen: UIDailyMenuTestScreen!
  9. var bottleFeedsTestScreen: UIBottleFeedsTestScreen!
  10. var calendarTestScreen: UICalendarTestScreen!
  11. var bottlesTestScreen: UIBottlesTestScreen!
  12. var pinScreen: UIPinLoginTestScreen!
  13. var parentMainMenu: UIMainParentMenuTestScreen!
  14. var parentSideChildrenMenu: UIParentSideChildrenMenuTestScreen!
  15. var bottleFeedsParentTestScreen: UIBottleFeedsParentTestScreen!
  16. var calendarParentTestScreen: UICalendarParentTestScreen!
  17. var bottlesParentTestScreen: UIBottlesParentTestScreen!
  18.  
  19. override func initTestScreens() {
  20. loginTestScreen = UITestLoginScreen(testCase: self)
  21. mainMenuTestScreen = UIMainMenuTestScreen(testCase: self)
  22. dailyMenuTestScreen = UIDailyMenuTestScreen(testCase: self)
  23. bottleFeedsTestScreen = UIBottleFeedsTestScreen(testCase: self)
  24. calendarTestScreen = UICalendarTestScreen(testCase: self)
  25. bottlesTestScreen = UIBottlesTestScreen(testCase: self)
  26. pinScreen = UIPinLoginTestScreen(testCase: self)
  27. parentMainMenu = UIMainParentMenuTestScreen(testCase: self)
  28. parentSideChildrenMenu = UIParentSideChildrenMenuTestScreen(testCase: self)
  29. bottleFeedsParentTestScreen = UIBottleFeedsParentTestScreen(testCase: self)
  30. calendarParentTestScreen = UICalendarParentTestScreen(testCase: self)
  31. bottlesParentTestScreen = UIBottlesParentTestScreen(testCase: self)
  32. }
  33.  
  34. func test_J3_04_Daily_BottleFeeds_iOS_TC1() {
  35. loginTestScreen.loginWithDevelopCredentials(reLogin: false)
  36.  
  37. mainMenuTestScreen.waitForBecomeVisible()
  38. mainMenuTestScreen.selectDailyMenuItem()
  39.  
  40. dailyMenuTestScreen.waitForBecomeVisible()
  41. dailyMenuTestScreen.selectMenuItem(identifier: bottleFeedsIdentifier)
  42.  
  43. bottleFeedsTestScreen.waitForBecomeVisible()
  44. bottleFeedsTestScreen.findChild()
  45. bottleFeedsTestScreen.addBottleFeed()
  46. bottleFeedsTestScreen.checkChanges()
  47.  
  48. sleep(5)
  49. }
  50.  
  51. func test_J3_04_Daily_BottleFeeds_iOS_TC2() {
  52. loginTestScreen.loginWithDevelopCredentials(reLogin: false)
  53.  
  54. mainMenuTestScreen.waitForBecomeVisible()
  55. mainMenuTestScreen.selectDailyMenuItem()
  56.  
  57. dailyMenuTestScreen.waitForBecomeVisible()
  58. dailyMenuTestScreen.selectMenuItem(identifier: bottleFeedsIdentifier)
  59.  
  60. bottleFeedsTestScreen.waitForBecomeVisible()
  61. bottleFeedsTestScreen.findChild()
  62. bottleFeedsTestScreen.openCalendar()
  63.  
  64. calendarTestScreen.selectDate()
  65.  
  66. bottlesTestScreen.addBottleFeed()
  67. bottlesTestScreen.goBack()
  68.  
  69. calendarTestScreen.goBack()
  70.  
  71. bottleFeedsTestScreen.waitForBecomeVisible()
  72. bottleFeedsTestScreen.checkChanges()
  73.  
  74. sleep(5)
  75. }
  76.  
  77. func test_J3_04_Daily_BottleFeeds_iOS_TC3() {
  78. loginTestScreen.loginWithDevelopCredentials(reLogin: false)
  79.  
  80. mainMenuTestScreen.waitForBecomeVisible()
  81. mainMenuTestScreen.selectDailyMenuItem()
  82.  
  83. dailyMenuTestScreen.waitForBecomeVisible()
  84. dailyMenuTestScreen.selectMenuItem(identifier: bottleFeedsIdentifier)
  85.  
  86. bottleFeedsTestScreen.waitForBecomeVisible()
  87. bottleFeedsTestScreen.findChild()
  88. bottleFeedsTestScreen.openCalendar()
  89.  
  90. calendarTestScreen.selectDate()
  91.  
  92. bottlesTestScreen.addBottleFeed()
  93. bottlesTestScreen.deleteBottle()
  94. sleep(2)
  95. XCTAssertFalse(bottlesTestScreen.bottleExists())
  96. bottlesTestScreen.goBack()
  97.  
  98. calendarTestScreen.goBack()
  99.  
  100. bottleFeedsTestScreen.waitForBecomeVisible()
  101. bottleFeedsTestScreen.checkChangesAfterDeleting()
  102.  
  103. sleep(5)
  104. }
  105.  
  106. func test_J3_04_Daily_BottleFeeds_iOS_TC4() {
  107. loginTestScreen.loginWithCredentials(username: Credentials.parent2UserName, password: Credentials.password)
  108.  
  109. parentMainMenu.waitForBecomeVisible()
  110. parentMainMenu.selectMenuItem(name: childrenIdentifier)
  111.  
  112. parentSideChildrenMenu.selectMenuItem(name: bottleFeedsIdentifier)
  113.  
  114. bottleFeedsParentTestScreen.waitForBecomeVisible()
  115. let initialBottlesCount = bottleFeedsParentTestScreen.childHasBottles()
  116. bottleFeedsParentTestScreen.addBottleFeed()
  117. XCTAssertTrue(bottleFeedsParentTestScreen.checkBottlesAdded(amount: initialBottlesCount + 1))
  118.  
  119. sleep(3)
  120. }
  121.  
  122. func test_J3_04_Daily_BottleFeeds_iOS_TC5() {
  123. loginTestScreen.loginWithCredentials(username: Credentials.parent2UserName, password: Credentials.password)
  124.  
  125. parentMainMenu.waitForBecomeVisible()
  126. parentMainMenu.selectMenuItem(name: childrenIdentifier)
  127.  
  128. parentSideChildrenMenu.selectMenuItem(name: bottleFeedsIdentifier)
  129.  
  130. bottleFeedsParentTestScreen.waitForBecomeVisible()
  131. let initialBottlesCount = bottleFeedsParentTestScreen.childHasBottles()
  132. bottleFeedsParentTestScreen.openCalendar()
  133.  
  134. calendarParentTestScreen.selectDate()
  135. bottlesParentTestScreen.addBottleFeed()
  136. sleep(2)
  137. bottlesParentTestScreen.goBack()
  138. calendarParentTestScreen.waitForBecomeVisible()
  139. calendarParentTestScreen.goBack()
  140.  
  141.  
  142. bottleFeedsParentTestScreen.waitForBecomeVisible()
  143. XCTAssertTrue(bottleFeedsParentTestScreen.checkBottlesAdded(amount: initialBottlesCount + 1))
  144.  
  145. sleep(3)
  146. }
  147.  
  148. func test_J3_04_Daily_BottleFeeds_iOS_TC6() {
  149. loginTestScreen.loginWithCredentials(username: Credentials.parent2UserName, password: Credentials.password)
  150.  
  151. parentMainMenu.waitForBecomeVisible()
  152. parentMainMenu.selectMenuItem(name: childrenIdentifier)
  153.  
  154. parentSideChildrenMenu.selectMenuItem(name: bottleFeedsIdentifier)
  155.  
  156. bottleFeedsParentTestScreen.waitForBecomeVisible()
  157. bottleFeedsParentTestScreen.addBottleFeed()
  158. let initialBottlesCount = bottleFeedsParentTestScreen.childHasBottles()
  159. sleep(2)
  160. bottleFeedsParentTestScreen.goToMainMenu()
  161.  
  162. parentMainMenu.waitForBecomeVisible()
  163. parentMainMenu.logout()
  164.  
  165. reloginAsAdmin()
  166.  
  167. mainMenuTestScreen.waitForBecomeVisible()
  168. mainMenuTestScreen.selectDailyMenuItem()
  169.  
  170. dailyMenuTestScreen.waitForBecomeVisible()
  171. dailyMenuTestScreen.selectMenuItem(identifier: bottleFeedsIdentifier)
  172.  
  173. bottleFeedsTestScreen.waitForBecomeVisible()
  174. bottleFeedsTestScreen.findChild()
  175. bottleFeedsTestScreen.openCalendar()
  176.  
  177. calendarTestScreen.selectDate()
  178. bottlesTestScreen.deleteBottle()
  179. bottlesTestScreen.goToMainMenu()
  180.  
  181. mainMenuTestScreen.waitForBecomeVisible()
  182. mainMenuTestScreen.logout()
  183.  
  184. reloginAsParent()
  185.  
  186. parentMainMenu.waitForBecomeVisible()
  187. parentMainMenu.selectMenuItem(name: childrenIdentifier)
  188.  
  189. parentSideChildrenMenu.selectMenuItem(name: bottleFeedsIdentifier)
  190.  
  191. bottleFeedsParentTestScreen.waitForBecomeVisible()
  192. XCTAssertTrue(bottleFeedsParentTestScreen.checkBottlesAdded(amount: initialBottlesCount))
  193.  
  194. sleep(3)
  195. }
  196.  
  197. func test_J3_04_Daily_BottleFeeds_iOS_TC7() {
  198.  
  199. loginTestScreen.loginWithDevelopCredentials(reLogin: false)
  200.  
  201. mainMenuTestScreen.waitForBecomeVisible()
  202. mainMenuTestScreen.selectDailyMenuItem()
  203.  
  204. dailyMenuTestScreen.waitForBecomeVisible()
  205. dailyMenuTestScreen.selectMenuItem(identifier: bottleFeedsIdentifier)
  206.  
  207. bottleFeedsTestScreen.waitForBecomeVisible()
  208. bottleFeedsTestScreen.findChild()
  209. bottleFeedsTestScreen.addBottleFeed()
  210. sleep(1)
  211. bottleFeedsTestScreen.addBottleFeed()
  212. bottleFeedsTestScreen.addBottleFeed()
  213.  
  214. bottleFeedsTestScreen.goToMainMenu()
  215.  
  216. mainMenuTestScreen.logout()
  217.  
  218. pinScreen.waitForBecomeVisible()
  219. pinScreen.goToLoginScreen(title: "Admin Dev-14")
  220. sleep(3)
  221. loginTestScreen.loginWithCredentials(username: Credentials.parent2UserName, password: Credentials.password)
  222. parentMainMenu.waitForBecomeVisible()
  223. parentMainMenu.selectMenuItem(name: childrenIdentifier)
  224.  
  225. parentSideChildrenMenu.selectMenuItem(name: bottleFeedsIdentifier)
  226.  
  227. bottleFeedsParentTestScreen.waitForBecomeVisible()
  228. XCTAssertTrue(bottleFeedsParentTestScreen.checkBottlesAdded(amount: 3))
  229.  
  230. sleep(5)
  231. }
  232.  
  233. private func reloginAsParent() {
  234. sleep(3)
  235. pinScreen.waitForBecomeVisible()
  236. pinScreen.goToLoginScreen(title: "Admin Dev-14")
  237. sleep(3)
  238. loginTestScreen.loginWithCredentials(username: Credentials.parent2UserName, password: Credentials.password)
  239. sleep(3)
  240. }
  241.  
  242. private func reloginAsAdmin() {
  243. sleep(3)
  244. pinScreen.waitForBecomeVisible()
  245. pinScreen.goToLoginScreen(title: Credentials.parent2FullName)
  246. sleep(3)
  247. loginTestScreen.loginWithCredentials(username: "admin", password: "admin")
  248. sleep(3)
  249. }
  250. }
Add Comment
Please, Sign In to add comment