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();
|
const startTime = new Date().toISOString();
|
||||||
|
|
||||||
//Right Panel:
|
//Right Panel:
|
||||||
//Welcome back
|
//Welcome back
|
||||||
const expectedWelcomeBackText = 'WELCOME BAC';
|
const expectedWelcomeBackText = 'WELCOME BACK!';
|
||||||
const expectedWelcomeBackColor = 'rgba(117, 117, 117, 1)' //gray
|
const expectedWelcomeBackColor = 'rgba(117, 117, 117, 1)' //gray
|
||||||
//Login
|
//Login
|
||||||
const expectedLoginTitleText = 'Login to account';
|
const expectedLoginTitleText = 'Login to your account';
|
||||||
const expectedLoginTitleColor = 'rgba(40, 39, 90, 1)'; //navy blue
|
const expectedLoginTitleColor = 'rgba(40, 39, 90, 1)'; //navy blue
|
||||||
const expectedLoginTitleFont = '32px';
|
const expectedLoginTitleFont = '32px';
|
||||||
//Username
|
//Username
|
||||||
@@ -35,7 +35,7 @@ const expectedForgotPasswordLinkColor = 'rgba(40, 39, 90, 1)'; //navy blue
|
|||||||
const expectedLoginButtonText = 'Login';
|
const expectedLoginButtonText = 'Login';
|
||||||
const expectedLoginButtonColor = 'rgba(48, 200, 172, 1)'; //teal
|
const expectedLoginButtonColor = 'rgba(48, 200, 172, 1)'; //teal
|
||||||
//Don't have account text
|
//Don't have account text
|
||||||
const expectedDontHaveAccountText = `DON'T HAVE ACCOUNT?`;
|
const expectedDontHaveAccountText = `DON'T HAVE AN ACCOUNT?`;
|
||||||
//Free trial button
|
//Free trial button
|
||||||
const expectedFreeTrialButtonText = '30 Day';
|
const expectedFreeTrialButtonText = '30 Day';
|
||||||
const expectedFreeTrialButtonColor = 'rgba(0, 0, 0, 0)'; //white
|
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 expectedAuthenticationText = 'Authentication Failed. Please check the username and password you entered and try again.';
|
||||||
const expectedAuthenticationColor = 'rgba(231, 76, 60, 0.88)'; //orange
|
const expectedAuthenticationColor = 'rgba(231, 76, 60, 0.88)'; //orange
|
||||||
|
|
||||||
|
//Signed in Username
|
||||||
|
const expectedUsername = 'JuanIsThe BestAdmin';
|
||||||
|
|
||||||
const steps = [
|
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: '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() },
|
{ description: 'Expand browser', action: async () => await driver.manage().window().maximize() },
|
||||||
|
|
||||||
//RIGHT PANEL
|
//RIGHT PANEL
|
||||||
|
|
||||||
//ExACT logo
|
//ExACT logo
|
||||||
{
|
{
|
||||||
description: 'Verify ExACT logo is present',
|
description: 'Verify ExACT logo is present',
|
||||||
@@ -170,7 +172,6 @@ const steps = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
//Password label text
|
//Password label text
|
||||||
{
|
{
|
||||||
description: 'Validate Password label text',
|
description: 'Validate Password label text',
|
||||||
@@ -292,11 +293,10 @@ const steps = [
|
|||||||
},
|
},
|
||||||
|
|
||||||
//Validation
|
//Validation
|
||||||
|
{ description: 'Click Login button without username or password', action: async () => await driver.findElement(By.css('.login')).click() },
|
||||||
{ description: 'Click Login button', action: async () => await driver.findElement(By.css('.login')).click() },
|
{ description: 'Driver sleep', action: async () => await driver.sleep(2000) },
|
||||||
|
|
||||||
/*Username validation
|
/*Username validation
|
||||||
|
|
||||||
{ description: 'Validate username validadtion text', action: async () =>
|
{ description: 'Validate username validadtion text', action: async () =>
|
||||||
{ const elementText = await driver.findElement(By.css('?')).getText();
|
{ const elementText = await driver.findElement(By.css('?')).getText();
|
||||||
if (elementText === expectedUsernameValidationText)
|
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: '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: '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: '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: '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
|
//Confirm validation message
|
||||||
|
|
||||||
{
|
{
|
||||||
description: 'Validate authentication failed validation text',
|
description: 'Verify authentication failed validation text',
|
||||||
action: async () => {
|
action: async () => {
|
||||||
const elementText = await driver.findElement(By.css('.alert')).getText();
|
const elementText = await driver.findElement(By.css('.alert')).getText();
|
||||||
if (elementText !== expectedAuthenticationText) {
|
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 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: '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: '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) => {
|
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 takeScreenshot = async (driver, stepIndex, stepDescription) => {
|
||||||
const screenshot = await driver.takeScreenshot();
|
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 screenshotFileName = `step_${stepIndex}_${stepDescription.replace(/\s+/g, '_')}.png`;
|
||||||
const screenshotPath = path.join(dir, screenshotFileName);
|
const screenshotPath = path.join(dir, screenshotFileName);
|
||||||
fs.writeFileSync(screenshotPath, screenshot, 'base64');
|
fs.writeFileSync(screenshotPath, screenshot, 'base64');
|
||||||
@@ -361,7 +377,7 @@ const takeScreenshot = async (driver, stepIndex, stepDescription) => {
|
|||||||
|
|
||||||
const clearOldResults = () => {
|
const clearOldResults = () => {
|
||||||
// Remove old screenshots
|
// Remove old screenshots
|
||||||
const screenshotDir = path.join('screenshots', 'loginScript');
|
const screenshotDir = path.join('screenshots', 'login');
|
||||||
if (fs.existsSync(screenshotDir)) {
|
if (fs.existsSync(screenshotDir)) {
|
||||||
fs.rmSync(screenshotDir, { recursive: true, force: true });
|
fs.rmSync(screenshotDir, { recursive: true, force: true });
|
||||||
}
|
}
|
||||||
@@ -403,14 +419,14 @@ try {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check if login was successful
|
//Script completed
|
||||||
const usernameValidation = await driver.wait(until.elementLocated(By.css('#navbarDropdown > span')), 5000).catch(() => false);
|
const loginButton = await driver.wait(until.elementLocated(By.css('.login')), 5000).catch(() => false);
|
||||||
|
|
||||||
if (usernameValidation) {
|
if (loginButton) {
|
||||||
console.log('PASSED: System logged in as expected');
|
console.log('PASSED: Script completed');
|
||||||
testStatus = 'Passed';
|
testStatus = 'Passed';
|
||||||
} else {
|
} else {
|
||||||
console.log('FAILED: Unable to log in');
|
console.log('FAILED: Script completed');
|
||||||
testStatus = 'Failed';
|
testStatus = 'Failed';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user