Mu_Area_D

Untitled

Aug 26th, 2017
36
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. var loginLogic = require('path/to/my/function');
  20.  
  21. /* This user is an officer who can login without certificate */
  22. var testedValidPassword = "trackforce123";
  23.  
  24. module.exports = {
  25.     tags: ['loginpreprodguardtek'],
  26.  
  27.     /* Trying to login with an invalid password for 5 time should raise an error saying "Invalid username or password" in an alert box */
  28.     'TC_LOG_008_loginInvalidDataFirstAttempt#1' : function(client) {
  29.         loginLogic.run(client, urlWebSite, usernameBox, passwordBox, testedValidUsername, testedInvalidPassword);
  30.     },
  31.  
  32.  
  33.     'TC_LOG_008_loginInvalidDataFirstAttempt#2' : function(client) {
  34.         client
  35.             .url(urlWebSite)
  36.             .waitForElementVisible("body", 2000)
  37.             .clearValue(usernameBox)
  38.             .expect.element(usernameBox).text.to.equal('');                                        
  39.                                                          
  40.         client.setValue(usernameBox, testedValidUsername).pause(500)
  41.  
  42.             .clearValue(passwordBox)
  43.             .expect.element(passwordBox).text.to.equal('');
  44.  
  45.         client.setValue(passwordBox, testedInvalidPassword).pause(500)
  46.             .click(submitButton)
  47.             .expect.element(".alert").to.be.visible.after(1000);
  48.  
  49.         client.expect.element(".alert > div > span").to.contain.text("Invalid username or password");              
  50.     },
  51.  
  52.     'TC_LOG_008_loginInvalidDataFirstAttempt#3' : function(client) {
  53.         client
  54.             .url(urlWebSite)
  55.             .waitForElementVisible("body", 2000)
  56.             .clearValue(usernameBox)
  57.             .expect.element(usernameBox).text.to.equal('');                                        
  58.                                                          
  59.         client.setValue(usernameBox, testedValidUsername).pause(500)
  60.  
  61.             .clearValue(passwordBox)
  62.             .expect.element(passwordBox).text.to.equal('');
  63.  
  64.         client.setValue(passwordBox, testedInvalidPassword).pause(500)
  65.             .click(submitButton)
  66.             .expect.element(".alert").to.be.visible.after(1000);
  67.  
  68.         client.expect.element(".alert > div > span").to.contain.text("Invalid username or password");              
  69.     },
  70.  
  71.     'TC_LOG_008_loginInvalidDataFirstAttempt#4' : function(client) {
  72.         client
  73.             .url(urlWebSite)
  74.             .waitForElementVisible("body", 2000)
  75.             .clearValue(usernameBox)
  76.             .expect.element(usernameBox).text.to.equal('');                                        
  77.                                                          
  78.         client.setValue(usernameBox, testedValidUsername).pause(500)
  79.  
  80.             .clearValue(passwordBox)
  81.             .expect.element(passwordBox).text.to.equal('');
  82.  
  83.         client.setValue(passwordBox, testedInvalidPassword).pause(500)
  84.             .click(submitButton)
  85.             .expect.element(".alert").to.be.visible.after(1000);
  86.  
  87.         client.expect.element(".alert > div > span").to.contain.text("Invalid username or password");      
  88.     },
  89.  
  90.     'TC_LOG_008_loginInvalidDataFirstAttempt#5' : function(client) {
  91.         client
  92.             .url(urlWebSite)
  93.             .waitForElementVisible("body", 2000)
  94.             .clearValue(usernameBox)
  95.             .expect.element(usernameBox).text.to.equal('');                                        
  96.                                                          
  97.         client.setValue(usernameBox, testedValidUsername).pause(500)
  98.  
  99.             .clearValue(passwordBox)
  100.             .expect.element(passwordBox).text.to.equal('');
  101.  
  102.         client.setValue(passwordBox, testedInvalidPassword).pause(500)
  103.             .click(submitButton)
  104.             .expect.element(".alert").to.be.visible.after(1000);
  105.  
  106.         client.expect.element(".alert > div > span").to.contain.text("Invalid username or password");      
  107.     },
  108.  
  109.     'TC_LOG_004_loginValidData#1' : function(client) {
  110.         client
  111.             .url(urlWebSite)
  112.             .waitForElementVisible("body", 2000)
  113.             .clearValue(usernameBox)
  114.             .expect.element(usernameBox).text.to.equal('');                                        
  115.                                                          
  116.         client.setValue(usernameBox, testedValidUsername).pause(500)
  117.  
  118.             .clearValue(passwordBox)
  119.             .expect.element(passwordBox).text.to.equal('');
  120.  
  121.         client.setValue(passwordBox, testedValidPassword).pause(500)
  122.             .click(submitButton)
  123.             .expect.element(".alert").to.be.visible.after(1000);
  124.  
  125.         client.expect.element(".alert > div > span").to.contain.text("Too Many bad login attempt, please retry later");
  126.     },
  127.  
  128.     'TC_LOG_014_waitingForThirtySeconds' : function(client) {
  129.         client
  130.             .url(urlWebSite)
  131.             .waitForElementVisible("body", 2000)
  132.             .pause(30000);
  133.     },
  134.  
  135.     'TC_LOG_004_loginValidData#2' : function(client) {
  136.         client
  137.             .url(urlWebSite)
  138.             .waitForElementVisible("body", 2000)
  139.             .clearValue(usernameBox)
  140.             .expect.element(usernameBox).text.to.equal('');                                        
  141.                                                          
  142.         client.setValue(usernameBox, testedValidUsername).pause(500)
  143.  
  144.             .clearValue(passwordBox)
  145.             .expect.element(passwordBox).text.to.equal('');
  146.  
  147.         client.setValue(passwordBox, testedValidPassword).pause(500)
  148.             .click(submitButton)
  149.             .waitForElementVisible("#topheader", 2000)
  150.             .expect.element(".main-nav").to.be.visible;
  151.     }
  152.     'TC_LOG_008_loginInvalidDataFirstAttempt#1': function(client) {
  153.         client
  154.             .url(urlWebSite)
  155.             .url().Maxpower()
  156.             .end();
  157.     }
  158. };
Add Comment
Please, Sign In to add comment