From f444e52a514bccdfa21138be1d565f39ce3bfb63 Mon Sep 17 00:00:00 2001 From: jhuerta Date: Thu, 10 Oct 2024 21:10:05 -0700 Subject: [PATCH] Added LogOut check --- loginResults.xlsx | Bin 26006 -> 27011 bytes tests/ExACT_login.js | 70 ++++++++++++++++++++++++++----------------- 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/loginResults.xlsx b/loginResults.xlsx index 412d9e573fbeb312f1cd32759c1a207a12119b23..b31ede408899f65030e6e23ff2efda0fa936ed27 100644 GIT binary patch delta 2080 zcmZXVYiJx*6vvZATB%8@G>@9J$u^JXwVAmycb?ftvX5+%-OW~Li6vHtm`u!?Z63SZ zXaz;<7e821`GaEZ2Sr4R7L_7eOCb`)N<}Lw3W|!+FA75XO|a;lea>>unahTZHO~QDAGlI+Q8+?%tZ_U(;V$L{&hRz?g%e~6Z}L2T z;tw%_7POJ`_GnSj@fjhwO@6hTsjA~If#8t%v)wG|DrzaYvw*|aPf77B^;Gx)Q1UT;UDZ~S&=~^WgwXWb>M}_F{kkDNJW_CQe_#FBV}P_yKoDxj|li9 z(gQtO`F$#Knl9l?l-yG!R*jLxoS89Fi&%;Gqh?fKwQNUA^dO!X_3bGgOG?4_HsHI_ zw&F$aYn&kVE{i%X^a9=MX|Ppa+3ltF4unUw5|3^BVq z=WoyEGWm7;ZgqNw*&hf>yNeCO{>HX4kH+bQ?BGE#(pKEoRCcy)E85bjRk*Av<5HYz zA$H_H?yJXF;U*WGGT~|pVWg>C2TA9MDDTkKtU8q1u9Vu&8Z$-pil#MXn(B5<-BF8h zIyJN4&drDtDs8&c(+`_zXHb}3=J~SdR$1(Lg0d4&xA5G>ZKE1_1%oLVMFk_T zfcHGjT@oqt=BJETb4rKUo&9RKvDs~1Tj|u|f^#{{mMt^{I=U?|B>Yp{AGVaQ+Uk<4y5X~*7Rt~a|I@kR1J>-lay za<$&}tYdR#($#kq-dV5fmq|R%hU9U)KdZVnrttTy&(-lDJf`3E_Cr`OyLR20t76~( DRZ#5XZFsm(eE?U-sr{Q*TakUoPD5`+eW< zeCK!0ef>M%JGXo{F7@wA%*-6Q80zS_7+PQL5BU5lTfZ`}<~vAEQ6s9+s7_?UC}xA3 zEuTyVH53UPk7{&6F-WmMs&O&d+4fsz2TUN2#!o1(Jc|xh=xtYLmwzDDC4z%s^nlJ z+u2&(so0dlr}iSMZHPLiso)X4jj3>E7bbNfb5o{N!%^lrPBFpJlvSM}VR&fS_@n7! z%DPEWG(GgPxh5GJ^8}xW2gN;_jej7L4V5776#a(3|SS*-S6aq+`uOg2{tpNyCpQ!o-QuAb3A^S<4F{$z9q(m@a#dFN zB>bLjGqvF6a!8HQ-8F9K9>a_t~*uSE`+h3<8FK5>?=s{=Y@JrCVa^A`8G#>NV7-rO<@pgdD{0}(XC7K<*Kw) zUT~NBkd;eLttQpWd<4%`mK+|&zj { const startTime = new Date().toISOString(); //Right Panel: -//Welcome back -const expectedWelcomeBackText = 'WELCOME BAC'; + //Welcome back +const expectedWelcomeBackText = 'WELCOME BACK!'; const expectedWelcomeBackColor = 'rgba(117, 117, 117, 1)' //gray //Login -const expectedLoginTitleText = 'Login to account'; +const expectedLoginTitleText = 'Login to your account'; const expectedLoginTitleColor = 'rgba(40, 39, 90, 1)'; //navy blue const expectedLoginTitleFont = '32px'; //Username @@ -35,7 +35,7 @@ const expectedForgotPasswordLinkColor = 'rgba(40, 39, 90, 1)'; //navy blue const expectedLoginButtonText = 'Login'; const expectedLoginButtonColor = 'rgba(48, 200, 172, 1)'; //teal //Don't have account text -const expectedDontHaveAccountText = `DON'T HAVE ACCOUNT?`; +const expectedDontHaveAccountText = `DON'T HAVE AN ACCOUNT?`; //Free trial button const expectedFreeTrialButtonText = '30 Day'; const expectedFreeTrialButtonColor = 'rgba(0, 0, 0, 0)'; //white @@ -44,12 +44,14 @@ const expectedFreeTrialButtonText = '30 Day'; const expectedAuthenticationText = 'Authentication Failed. Please check the username and password you entered and try again.'; const expectedAuthenticationColor = 'rgba(231, 76, 60, 0.88)'; //orange +//Signed in Username +const expectedUsername = 'JuanIsThe BestAdmin'; + const steps = [ { description: 'Navigate to ExACT Landing Page', action: async () => await driver.navigate().to('https://stage.edgate.com/exact/login.php') }, //PROD - https://correlation.edgate.com/exact/login.php { description: 'Expand browser', action: async () => await driver.manage().window().maximize() }, //RIGHT PANEL - //ExACT logo { description: 'Verify ExACT logo is present', @@ -74,7 +76,7 @@ const steps = [ } }, - //Welcome back text color + //Welcome back text color { description: 'Validate Welcome back text color', action: async () => { @@ -98,7 +100,7 @@ const steps = [ } }, - //Login title text + //Login title text { description: 'Validate Login title text', action: async () => { @@ -158,7 +160,7 @@ const steps = [ } }, - //Username textbox placeholder + //Username textbox placeholder { description: 'Validate Username placeholder text', action: async () => { @@ -170,7 +172,6 @@ const steps = [ } }, - //Password label text { description: 'Validate Password label text', @@ -183,7 +184,7 @@ const steps = [ } }, - //Password label text color + //Password label text color { description: 'Validate Password label text color', action: async () => { @@ -207,7 +208,7 @@ const steps = [ } }, - //Forgot password text link color + //Forgot password text link color { description: 'Validate Forgot Password link text color', action: async () => { @@ -219,7 +220,7 @@ const steps = [ } }, - //Login button text + //Login button text { description: 'Validate Login button text', action: async () => { @@ -292,11 +293,10 @@ const steps = [ }, //Validation - - { description: 'Click Login button', action: async () => await driver.findElement(By.css('.login')).click() }, + { description: 'Click Login button without username or password', action: async () => await driver.findElement(By.css('.login')).click() }, + { description: 'Driver sleep', action: async () => await driver.sleep(2000) }, /*Username validation - { description: 'Validate username validadtion text', action: async () => { const elementText = await driver.findElement(By.css('?')).getText(); if (elementText === expectedUsernameValidationText) @@ -306,16 +306,16 @@ const steps = [ } },*/ - { description: 'Enter username', action: async () => await driver.findElement(By.css('.form-control:nth-child(2)')).sendKeys('exact_juan') }, { description: 'Click Login button after entering username', action: async () => await driver.findElement(By.css('.login')).click() }, + { description: 'Driver sleep', action: async () => await driver.sleep(2000) }, { description: 'Enter incorrect password', action: async () => await driver.findElement(By.css('.passfield')).sendKeys('Edgate1') }, { description: 'Click Login button after entering wrong password', action: async () => await driver.findElement(By.css('.login')).click() }, + { description: 'Driver sleep', action: async () => await driver.sleep(2000) }, //Confirm validation message - { - description: 'Validate authentication failed validation text', + description: 'Verify authentication failed validation text', action: async () => { const elementText = await driver.findElement(By.css('.alert')).getText(); if (elementText !== expectedAuthenticationText) { @@ -340,7 +340,23 @@ const steps = [ { description: 'Enter username', action: async () => await driver.findElement(By.css('.form-control:nth-child(2)')).sendKeys('exact_juan') }, { description: 'Enter correct password', action: async () => await driver.findElement(By.css('.passfield')).sendKeys('Edgate1!') }, { description: 'Click Login button after entering correct password', action: async () => await driver.findElement(By.css('.login')).click() }, - { description: 'Wait for login process to complete', action: async () => await driver.sleep(10000) }, + { description: 'Driver sleep', action: async () => await driver.sleep(10000) }, + + //Check if log out was successful - username + { + description: 'Verify username', + action: async () => { + const elementText = await driver.findElement(By.css('#navbarDropdown > span')).getText(); + if (elementText !== expectedUsername) { + throw new Error(`Expected: "${expectedUsername}"; Actual: "${elementText}"`); + } + console.log('Passed: Username matched as expected'); + } + }, + + //Log Out + { description: 'Click the profile label', action: async () => await driver.findElement(By.css('#navbarDropdown > span')).click() }, + { description: 'Click Log out link', action: async () => await driver.findElement(By.linkText('Log Out')).click() }, ]; const logStep = (worksheet, stepDescription, status, stepIndex, timestamp, screenshotPath) => { @@ -352,7 +368,7 @@ const logStep = (worksheet, stepDescription, status, stepIndex, timestamp, scree const takeScreenshot = async (driver, stepIndex, stepDescription) => { const screenshot = await driver.takeScreenshot(); - const dir = path.join('screenshots', 'loginScript'); + const dir = path.join('screenshots', 'login'); const screenshotFileName = `step_${stepIndex}_${stepDescription.replace(/\s+/g, '_')}.png`; const screenshotPath = path.join(dir, screenshotFileName); fs.writeFileSync(screenshotPath, screenshot, 'base64'); @@ -361,7 +377,7 @@ const takeScreenshot = async (driver, stepIndex, stepDescription) => { const clearOldResults = () => { // Remove old screenshots - const screenshotDir = path.join('screenshots', 'loginScript'); + const screenshotDir = path.join('screenshots', 'login'); if (fs.existsSync(screenshotDir)) { fs.rmSync(screenshotDir, { recursive: true, force: true }); } @@ -402,15 +418,15 @@ try { testStatus = 'Failed'; } } - - //Check if login was successful - const usernameValidation = await driver.wait(until.elementLocated(By.css('#navbarDropdown > span')), 5000).catch(() => false); - if (usernameValidation) { - console.log('PASSED: System logged in as expected'); + //Script completed + const loginButton = await driver.wait(until.elementLocated(By.css('.login')), 5000).catch(() => false); + + if (loginButton) { + console.log('PASSED: Script completed'); testStatus = 'Passed'; } else { - console.log('FAILED: Unable to log in'); + console.log('FAILED: Script completed'); testStatus = 'Failed'; }