Advertisement
Maksya

Untitled

Aug 26th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* jshint expr: true */
  2. /*************************************************
  3.  @test: TS_LOG_002_badAttemptsLoginProcess
  4.  @author: Anastasiia Oskilko
  5.  @date: 2017-08-04
  6.  @Description: Testing the Login process with bad attempts
  7.  *************************************************/
  8.  
  9.  
  10. var urlWebSite = "https://preprod.guardtek.net/#!/authentication/signin";  
  11. var usernameBox = "#username";
  12. var passwordBox = "#password";
  13. var submitButton = "button[type='submit']";
  14. var logoutButton = "#ctl00_m_CmdLogout";
  15.  
  16. /* This user's login is correct & password is wrong */
  17. var testedValidUsername = "j.tribbiani";
  18. var testedInvalidPassword = "trackforce1234";
  19.  
  20. /* This user is an officer who can login without certificate */
  21. var testedValidPassword = "trackforce123";
  22.  
  23. module.exports = {
  24.     tags: ['loginpreprodguardtek'],
  25.  
  26.     /* Trying to login with an invalid password for 5 time should raise an error saying "Invalid username or password" in an alert box */
  27.     'TC_LOG_008_loginInvalidDataFirstAttempt#1': function (client) {
  28.         client
  29.             .url(urlWebSite)
  30.             .waitForElementVisible("body", 2000)
  31.             .clearValue(usernameBox)
  32.             .expect.element(usernameBox).text.to.equal('');
  33.  
  34.         client.setValue(usernameBox, testedValidUsername).pause(500)
  35.  
  36.             .clearValue(passwordBox)
  37.             .expect.element(passwordBox).text.to.equal('');
  38.  
  39.         client.setValue(passwordBox, testedInvalidPassword).pause(500)
  40.             .click(submitButton)
  41.             .expect.element(".alert").to.be.visible.after(1000);
  42.  
  43.         client.expect.element(".alert > div > span").to.contain.text("Invalid username or password");
  44.         for(var i=0; i < 5; i++){
  45.             loginLogic.invalidData();
  46.         }
  47.         loginLogic.validData();
  48.         setTimeout(function() {
  49.             loginLogic.invalidData();
  50.         }, 40000);
  51.     },
  52.  
  53.  
  54.     'TC_LOG_008_loginInvalidDataFirstAttempt#2': function (client) {
  55.         client
  56.             .url(urlWebSite)
  57.             .waitForElementVisible("body", 2000)
  58.             .clearValue(usernameBox)
  59.             .expect.element(usernameBox).text.to.equal('');
  60.  
  61.         client.setValue(usernameBox, testedValidUsername).pause(500)
  62.  
  63.             .clearValue(passwordBox)
  64.             .expect.element(passwordBox).text.to.equal('');
  65.  
  66.         client.setValue(passwordBox, testedInvalidPassword).pause(500)
  67.             .click(submitButton)
  68.             .expect.element(".alert").to.be.visible.after(1000);
  69.  
  70.         client.expect.element(".alert > div > span").to.contain.text("Invalid username or password");
  71.     },
  72.  
  73.     'TC_LOG_008_loginInvalidDataFirstAttempt#3': function (client) {
  74.         client
  75.             .url(urlWebSite)
  76.             .waitForElementVisible("body", 2000)
  77.             .clearValue(usernameBox)
  78.             .expect.element(usernameBox).text.to.equal('');
  79.  
  80.         client.setValue(usernameBox, testedValidUsername).pause(500)
  81.  
  82.             .clearValue(passwordBox)
  83.             .expect.element(passwordBox).text.to.equal('');
  84.  
  85.         client.setValue(passwordBox, testedInvalidPassword).pause(500)
  86.             .click(submitButton)
  87.             .expect.element(".alert").to.be.visible.after(1000);
  88.  
  89.         client.expect.element(".alert > div > span").to.contain.text("Invalid username or password");
  90.     },
  91.  
  92.     'TC_LOG_008_loginInvalidDataFirstAttempt#4': function (client) {
  93.         client
  94.             .url(urlWebSite)
  95.             .waitForElementVisible("body", 2000)
  96.             .clearValue(usernameBox)
  97.             .expect.element(usernameBox).text.to.equal('');
  98.  
  99.         client.setValue(usernameBox, testedValidUsername).pause(500)
  100.  
  101.             .clearValue(passwordBox)
  102.             .expect.element(passwordBox).text.to.equal('');
  103.  
  104.         client.setValue(passwordBox, testedInvalidPassword).pause(500)
  105.             .click(submitButton)
  106.             .expect.element(".alert").to.be.visible.after(1000);
  107.  
  108.         client.expect.element(".alert > div > span").to.contain.text("Invalid username or password");
  109.     },
  110.  
  111.     'TC_LOG_008_loginInvalidDataFirstAttempt#5': function (client) {
  112.         client
  113.             .url(urlWebSite)
  114.             .waitForElementVisible("body", 2000)
  115.             .clearValue(usernameBox)
  116.             .expect.element(usernameBox).text.to.equal('');
  117.  
  118.         client.setValue(usernameBox, testedValidUsername).pause(500)
  119.  
  120.             .clearValue(passwordBox)
  121.             .expect.element(passwordBox).text.to.equal('');
  122.  
  123.         client.setValue(passwordBox, testedInvalidPassword).pause(500)
  124.             .click(submitButton)
  125.             .expect.element(".alert").to.be.visible.after(1000);
  126.  
  127.         client.expect.element(".alert > div > span").to.contain.text("Invalid username or password");
  128.     },
  129.  
  130.     'TC_LOG_004_loginValidData#1': function (client) {
  131.         client
  132.             .url(urlWebSite)
  133.             .waitForElementVisible("body", 2000)
  134.             .clearValue(usernameBox)
  135.             .expect.element(usernameBox).text.to.equal('');
  136.  
  137.         client.setValue(usernameBox, testedValidUsername).pause(500)
  138.  
  139.             .clearValue(passwordBox)
  140.             .expect.element(passwordBox).text.to.equal('');
  141.  
  142.         client.setValue(passwordBox, testedValidPassword).pause(500)
  143.             .click(submitButton)
  144.             .expect.element(".alert").to.be.visible.after(1000);
  145.  
  146.         client.expect.element(".alert > div > span").to.contain.text("Too Many bad login attempt, please retry later");
  147.     },
  148.  
  149.     'TC_LOG_014_waitingForThirtySeconds': function (client) {
  150.         client
  151.             .url(urlWebSite)
  152.             .waitForElementVisible("body", 2000)
  153.             .pause(30000);
  154.     },
  155.  
  156.     'TC_LOG_004_loginValidData#2': function (client) {
  157.         client
  158.             .url(urlWebSite)
  159.             .waitForElementVisible("body", 2000)
  160.             .clearValue(usernameBox)
  161.             .expect.element(usernameBox).text.to.equal('');
  162.  
  163.         client.setValue(usernameBox, testedValidUsername).pause(500)
  164.  
  165.             .clearValue(passwordBox)
  166.             .expect.element(passwordBox).text.to.equal('');
  167.  
  168.         client.setValue(passwordBox, testedValidPassword).pause(500)
  169.             .click(submitButton)
  170.             .waitForElementVisible("#topheader", 2000)
  171.             .expect.element(".main-nav").to.be.visible;
  172.     }
  173.  
  174.  
  175. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement