Added LogOut check
This commit is contained in:
Binary file not shown.
@@ -14,11 +14,11 @@ const ExACT_login = (req, res) => {
|
||||
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';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user