Advertisement
Guest User

Untitled

a guest
Aug 10th, 2018
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.98 KB | None | 0 0
  1. var index = require('../pages/index');
  2.  
  3. var webdriver = require('selenium-webdriver'),
  4. By = webdriver.By,
  5. until = webdriver.until;
  6. var driver = new webdriver.Builder().
  7. withCapabilities(webdriver.Capabilities.chrome()).
  8. build();
  9.  
  10.  
  11. const headingTitleExist = async function() {
  12. const headingTitleElement = await driver.wait(until.elementLocated(By.css('.page-heading__title')));
  13. return headingTitleElement.isDisplayed();
  14. }
  15.  
  16. //=========Left Panel - Notifications========
  17.  
  18. const notificationsTitleExist = async function() {
  19. const notificationsTitleElement = await driver.wait(until.elementLocated(By.css('.info-list__wrapper h4.brand')));
  20. return await notificationsTitleElement.getAttribute('innerHTML');
  21. }
  22.  
  23. const subjectEnrolmentsOpenExist = async function() {
  24. const subjectEnrolmentOpenElement = await driver.wait(until.elementLocated(By.css('.info-list li:first-child')));
  25. return await subjectEnrolmentOpenElement.getText();
  26. }
  27.  
  28. const youHaveOutstandingActionsExist = async function() {
  29. const youHaveOutstandingActionsElement = await driver.wait(until.elementLocated(By.css('.info-list li:nth-child(2)')));
  30. return await youHaveOutstandingActionsElement.getText();
  31. }
  32.  
  33. const enrolByThisDateToAvoidLateFeeExist = async function() {
  34. const enrolByThisDateToAvoidLateFeeElement = await driver.wait(until.elementLocated(By.css('.info-list li:nth-child(3)')));
  35. return await enrolByThisDateToAvoidLateFeeElement.getText();
  36. }
  37.  
  38. const subjectEnrolmentsCloseExist = async function() {
  39. const subjectEnrolmentsCloseElement = await driver.wait(until.elementLocated(By.css('.info-list li:nth-child(4)')));
  40. return await subjectEnrolmentsCloseElement.getText();
  41. }
  42.  
  43. const startOfTeachingExist = async function() {
  44. const startOfTeachingElement = await driver.wait(until.elementLocated(By.css('.info-list li:nth-child(5)')));
  45. return await startOfTeachingElement.getText();
  46. }
  47.  
  48. //========Right Panel - KBS Campus Details===========
  49.  
  50. const kbsCampusTitleExist = async function() {
  51. const kbsCampusTitleElement = await driver.wait(until.elementLocated(By.css('.dashboard__school-details h4.brand')));
  52. return await kbsCampusTitleElement.getAttribute('innerHTML');
  53. }
  54.  
  55. const telNoExist = async function() {
  56. const telNoElement = await driver.wait(until.elementLocated(By.css('.dashboard__school-details .tel span')));
  57. return await telNoElement.getAttribute('innerHTML');
  58. }
  59.  
  60. const mapExist = async function() {
  61. const mapElement = await driver.wait(until.elementLocated(By.css('.dashboard__school-details .map span')));
  62. return await mapElement.getAttribute('innerHTML');
  63. }
  64.  
  65. const studentFormTitleExist = async function() {
  66. const studentFormTitleElement = await driver.wait(until.elementLocated(By.css('.dashboard__student-forms h4')));
  67. return await studentFormTitleElement.getAttribute('innerHTML');
  68. }
  69.  
  70. const leaveOfAbsenceExist = async function() {
  71. const leaveOfAbsenceElement = await driver.wait(until.elementLocated(By.css('.student-forms__list li:first-child a')));
  72. return await leaveOfAbsenceElement.getAttribute('innerHTML');
  73. }
  74.  
  75. const intermissionOfStudiesDeferralRequestExist = async function() {
  76. const intermissionOfStudiesDeferralRequestElement = await driver.wait(until.elementLocated(By.css('.student-forms__list li:nth-child(2) a')));
  77. return await intermissionOfStudiesDeferralRequestElement.getAttribute('innerHTML');
  78. }
  79.  
  80. const campusTransferExist = async function() {
  81. const campusTransferElement = await driver.wait(until.elementLocated(By.css('.student-forms__list li:nth-child(3) a')));
  82. return await campusTransferElement.getAttribute('innerHTML');
  83. }
  84.  
  85. const viewAllStudentPdfFormsExist = async function() {
  86. const viewAllStudentPdfFormsElement = await driver.wait(until.elementLocated(By.css('.student-forms__list li:nth-child(4) a.external-link')));
  87. return await viewAllStudentPdfFormsElement.getAttribute('innerHTML');
  88. }
  89.  
  90.  
  91. //==========Actions Icons============
  92.  
  93. const basketIconExist = async function() {
  94. const basketIconElement = await driver.wait(until.elementLocated(By.css('.action-icons--item.is-dropdown-submenu-parent.opens-right:first-child')));
  95. return await basketIconElement.isDisplayed();
  96. }
  97.  
  98.  
  99. const bellIconExist = async function() {
  100. const bellIconElement = await driver.wait(until.elementLocated(By.css('.action-icons--item.action')));
  101. return await bellIconElement.isDisplayed();
  102. }
  103.  
  104. const userIconExist = async function() {
  105. const userIconElement = await driver.wait(until.elementLocated(By.css('.action-icons--item.is-dropdown-submenu-parent.opens-right:nth-child(3)')));
  106. return await userIconElement.isDisplayed();
  107. }
  108.  
  109.  
  110. //=======Common method===========
  111.  
  112. const openUrl = function() {
  113. const username = 'kaplan';
  114. const password = '7espuy';
  115. driver.get('https://'+username+':'+password+'@d22au4ni7coabp.cloudfront.net/');
  116. // https://kaplan:7espuy@d22au4ni7coabp.cloudfront.net/
  117. }
  118.  
  119. const clickSignIn = function() {
  120. driver.findElement(webdriver.By.css('.button')).click();
  121. }
  122.  
  123. const closeBrowser = function() {
  124. driver.quit();
  125. }
  126.  
  127. const setUserLogin = async function(username,password) {
  128. await driver.wait(until.elementLocated(By.id('userNameInput')));
  129. const setUserName = await driver.findElement(webdriver.By.id('userNameInput')).sendKeys(username);
  130. const setPassword = await driver.findElement(webdriver.By.id('passwordInput')).sendKeys(password);
  131. const clickBtn = await driver.findElement(webdriver.By.id('submitButton')).click();
  132. }
  133.  
  134. const enterUserLoginAs = async function(userobj) {
  135. return setUserLogin(userobj.username, userobj.password);
  136. }
  137.  
  138.  
  139. module.exports = {
  140. openUrl : openUrl,
  141. closeBrowser : closeBrowser,
  142. clickSignIn : clickSignIn,
  143. enterUserLoginAs : enterUserLoginAs,
  144. notificationsTitleExist : notificationsTitleExist,
  145. subjectEnrolmentsOpenExist : subjectEnrolmentsOpenExist,
  146. youHaveOutstandingActionsExist : youHaveOutstandingActionsExist,
  147. enrolByThisDateToAvoidLateFeeExist : enrolByThisDateToAvoidLateFeeExist,
  148. subjectEnrolmentsCloseExist : subjectEnrolmentsCloseExist,
  149. startOfTeachingExist : startOfTeachingExist,
  150. kbsCampusTitleExist : kbsCampusTitleExist,
  151. telNoExist : telNoExist,
  152. mapExist : mapExist,
  153. studentFormTitleExist : studentFormTitleExist,
  154. leaveOfAbsenceExist : leaveOfAbsenceExist,
  155. intermissionOfStudiesDeferralRequestExist : intermissionOfStudiesDeferralRequestExist,
  156. campusTransferExist : campusTransferExist,
  157. viewAllStudentPdfFormsExist : viewAllStudentPdfFormsExist,
  158. headingTitleExist : headingTitleExist
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement