fixed excel status update issue

This commit is contained in:
AShahzad
2024-10-10 21:20:17 +05:00
parent ea42898c2a
commit 14d6e74fb1
2 changed files with 184 additions and 174 deletions

Binary file not shown.

View File

@@ -15,10 +15,10 @@ const ExACT_login = (req, res) => {
//Right Panel: //Right Panel:
//Welcome back //Welcome back
const expectedWelcomeBackText = 'WELCOME BACK!'; const expectedWelcomeBackText = 'WELCOME BAC';
const expectedWelcomeBackColor = 'rgba(117, 117, 117, 1)' //gray const expectedWelcomeBackColor = 'rgba(117, 117, 117, 1)' //gray
//Login //Login
const expectedLoginTitleText = 'Login to your account'; const expectedLoginTitleText = 'Login to 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 AN ACCOUNT?`; const expectedDontHaveAccountText = `DON'T HAVE 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
@@ -45,245 +45,254 @@ const expectedAuthenticationText = 'Authentication Failed. Please check the user
const expectedAuthenticationColor = 'rgba(231, 76, 60, 0.88)'; //orange const expectedAuthenticationColor = 'rgba(231, 76, 60, 0.88)'; //orange
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') },
{ description: 'Expand browser', action: async () => await driver.manage().window().maximize() }, { description: 'Expand browser', action: async () => await driver.manage().window().maximize() },
//RIGHT PANEL {
//ExACT logo description: 'Verify ExACT logo is present',
{ description: 'Verify ExACT logo is present', action: async () => action: async () => {
{ const expectedExactLogo = await driver.wait(until.elementLocated(By.css('.logo')), 5000).catch(() => false); const expectedExactLogo = await driver.wait(until.elementLocated(By.css('.logo')), 5000).catch(() => false);
if (expectedExactLogo) if (!expectedExactLogo) {
{console.log('Passed: ExACT logo present');} throw new Error('ExACT logo not found');
else }
{console.log('FAILED: ExACT logo not found');} console.log('Passed: ExACT logo present');
} }
}, },
//Welcome back text {
{ description: 'Validate Welcome back text', action: async () => description: 'Validate Welcome back text',
{ const elementText = await driver.findElement(By.css('#formLogin > p')).getText(); action: async () => {
if (elementText === expectedWelcomeBackText) const elementText = await driver.findElement(By.css('#formLogin > p')).getText();
{console.log('Passed: Welcome Back! text matched as expected');} if (elementText !== expectedWelcomeBackText) {
else throw new Error(`Expected: "${expectedWelcomeBackText}"; Actual: "${elementText}"`);
{console.log(`FAILED: Expected: "${expectedWelcomeBackText}"; Actual: "${elementText}"`);} }
console.log('Passed: Welcome Back! text matched as expected');
} }
}, },
//Welcome back text color {
{ description: 'Validate Welcome back text color', action: async () => description: 'Validate Welcome back text color',
{ const elementStyle = await driver.findElement(By.css('#formLogin > p')).getCssValue('color'); action: async () => {
if (elementStyle === expectedWelcomeBackColor) const elementStyle = await driver.findElement(By.css('#formLogin > p')).getCssValue('color');
{console.log('Passed: Welcome back text color matched as expected');} if (elementStyle !== expectedWelcomeBackColor) {
else throw new Error(`Welcome back text color Expected: "${expectedWelcomeBackColor}"; Actual: "${elementStyle}"`);
{console.log(`FAILED: Welcome back text color Expected: "${expectedWelcomeBackColor}"; Actual: "${elementStyle}"`);} }
console.log('Passed: Welcome back text color matched as expected');
} }
}, },
//Welcome back icon {
{ description: 'Verify Welcome back icon is present', action: async () => description: 'Verify Welcome back icon is present',
{ const expectedWelcomeBackIcon = await driver.wait(until.elementLocated(By.css('p > img')), 5000).catch(() => false); action: async () => {
if (expectedWelcomeBackIcon) const expectedWelcomeBackIcon = await driver.wait(until.elementLocated(By.css('p > img')), 5000).catch(() => false);
{console.log('Passed: Welcome back icon present');} if (!expectedWelcomeBackIcon) {
else throw new Error('Welcome back icon not found');
{console.log('FAILED: Welcome back icon not found');} }
console.log('Passed: Welcome back icon present');
} }
}, },
//Login title text {
{ description: 'Validate Login title text', action: async () => description: 'Validate Login title text',
{ const elementText = await driver.findElement(By.css('h2:nth-child(3)')).getText(); action: async () => {
if (elementText === expectedLoginTitleText) const elementText = await driver.findElement(By.css('h2:nth-child(3)')).getText();
{console.log('Passed: Login title text matched as expected');} if (elementText !== expectedLoginTitleText) {
else throw new Error(`Expected: "${expectedLoginTitleText}"; Actual: "${elementText}"`);
{console.log(`FAILED: Expected: "${expectedLoginTitleText}"; Actual: "${elementText}"`);} }
console.log('Passed: Login title text matched as expected');
} }
}, },
//Login title text color {
{ description: 'Validate Login title text color', action: async () => description: 'Validate Login title text color',
{ const elementStyle = await driver.findElement(By.css('h2:nth-child(3)')).getCssValue('color'); action: async () => {
if (elementStyle === expectedLoginTitleColor) const elementStyle = await driver.findElement(By.css('h2:nth-child(3)')).getCssValue('color');
{console.log('Passed: Login title text color matched as expected');} if (elementStyle !== expectedLoginTitleColor) {
else throw new Error(`Login title text color Expected: "${expectedLoginTitleColor}"; Actual: "${elementStyle}"`);
{console.log(`FAILED: Login title text color Expected: "${expectedLoginTitleColor}"; Actual: "${elementStyle}"`);} }
console.log('Passed: Login title text color matched as expected');
} }
}, },
//Login title text font {
{ description: 'Validate Login title text font size', action: async () => description: 'Validate Login title text font size',
{ const elementStyle = await driver.findElement(By.css('h2:nth-child(3)')).getCssValue('font-size'); action: async () => {
if (elementStyle === expectedLoginTitleFont) const elementStyle = await driver.findElement(By.css('h2:nth-child(3)')).getCssValue('font-size');
{console.log('Passed: Login title text font-size matched as expected');} if (elementStyle !== expectedLoginTitleFont) {
else throw new Error(`Login title text font-size Expected: "${expectedLoginTitleFont}"; Actual: "${elementStyle}"`);
{console.log(`FAILED: Login title text font-size Expected: "${expectedLoginTitleFont}"; Actual: "${elementStyle}"`);} }
console.log('Passed: Login title text font-size matched as expected');
} }
}, },
//Username label text {
{ description: 'Validate Username label text', action: async () => description: 'Validate Username label text',
{ const elementText = await driver.findElement(By.css('.form-group:nth-child(4) > label')).getText(); action: async () => {
if (elementText === expectedUsernameLabel) const elementText = await driver.findElement(By.css('.form-group:nth-child(4) > label')).getText();
{console.log('Passed: Username label text matched as expected');} if (elementText !== expectedUsernameLabel) {
else throw new Error(`Expected: "${expectedUsernameLabel}"; Actual: "${elementText}"`);
{console.log(`FAILED: Expected: "${expectedUsernameLabel}"; Actual: "${elementText}"`);} }
console.log('Passed: Username label text matched as expected');
} }
}, },
//Username label text color {
{ description: 'Validate Username label text color', action: async () => description: 'Validate Username label text color',
{ const elementStyle = await driver.findElement(By.css('.form-group:nth-child(4) > label')).getCssValue('color'); action: async () => {
if (elementStyle === expectedUsernameColor) const elementStyle = await driver.findElement(By.css('.form-group:nth-child(4) > label')).getCssValue('color');
{console.log('Passed: Username label text color matched as expected');} if (elementStyle !== expectedUsernameColor) {
else throw new Error(`Username label text color Expected: "${expectedUsernameColor}"; Actual: "${elementStyle}"`);
{console.log(`FAILED: Username label text color Expected: "${expectedUsernameColor}"; Actual: "${elementStyle}"`);} }
console.log('Passed: Username label text color matched as expected');
} }
}, },
//Username textbox placeholder {
{ description: 'Validate Username placeholder text', action: async () => description: 'Validate Username placeholder text',
{ const elementValue = await driver.findElement(By.css('.form-control:nth-child(2)')).getAttribute('placeholder'); action: async () => {
if (elementValue === expectedUsernamePlaceholder) const elementValue = await driver.findElement(By.css('.form-control:nth-child(2)')).getAttribute('placeholder');
{console.log('Passed: Username placeholder text matched as expected');} if (elementValue !== expectedUsernamePlaceholder) {
else throw new Error(`Username placeholder text Expected: "${expectedUsernamePlaceholder}"; Actual: "${elementValue}"`);
{console.log(`FAILED: Username placeholder text Expected: "${expectedUsernamePlaceholder}"; Actual: "${elementValue}"`);} }
console.log('Passed: Username placeholder text matched as expected');
} }
}, },
//Password label text {
{ description: 'Validate Password label text', action: async () => description: 'Validate Password label text',
{ const elementText = await driver.findElement(By.css('.form-group:nth-child(5) > label')).getText(); action: async () => {
if (elementText === expectedPasswordLabel) const elementText = await driver.findElement(By.css('.form-group:nth-child(5) > label')).getText();
{console.log('Passed: Password label text matched as expected');} if (elementText !== expectedPasswordLabel) {
else throw new Error(`Expected: "${expectedPasswordLabel}"; Actual: "${elementText}"`);
{console.log(`FAILED: Expected: "${expectedPasswordLabel}"; Actual: "${elementText}"`);} }
console.log('Passed: Password label text matched as expected');
} }
}, },
//Password label text color {
{ description: 'Validate Password label text color', action: async () => description: 'Validate Password label text color',
{ const elementStyle = await driver.findElement(By.css('.form-group:nth-child(5) > label')).getCssValue('color'); action: async () => {
if (elementStyle === expectedPasswordColor) const elementStyle = await driver.findElement(By.css('.form-group:nth-child(5) > label')).getCssValue('color');
{console.log('Passed: Password label text color matched as expected');} if (elementStyle !== expectedPasswordColor) {
else throw new Error(`Password label text color Expected: "${expectedPasswordColor}"; Actual: "${elementStyle}"`);
{console.log(`FAILED: Password label text color Expected: "${expectedPasswordColor}"; Actual: "${elementStyle}"`);} }
console.log('Passed: Password label text color matched as expected');
} }
}, },
//Password textbox placeholder {
{ description: 'Validate Password placeholder text', action: async () => description: 'Validate Password placeholder text',
{ const elementValue = await driver.findElement(By.css('.passfield')).getAttribute('placeholder'); action: async () => {
if (elementValue === expectedPasswordPlaceholder) const elementValue = await driver.findElement(By.css('.passfield')).getAttribute('placeholder');
{console.log('Passed: Password placeholder text matched as expected');} if (elementValue !== expectedPasswordPlaceholder) {
else throw new Error(`Password placeholder text Expected: "${expectedPasswordPlaceholder}"; Actual: "${elementValue}"`);
{console.log(`FAILED: Password placeholder text Expected: "${expectedPasswordPlaceholder}"; Actual: "${elementValue}"`);} }
console.log('Passed: Password placeholder text matched as expected');
} }
}, },
//Forgot password text link color {
{ description: 'Validate Forgot Password link text color', action: async () => description: 'Validate Forgot Password link text color',
{ const elementStyle = await driver.findElement(By.linkText('Forgot Password?')).getCssValue('color'); action: async () => {
if (elementStyle === expectedForgotPasswordLinkColor) const elementStyle = await driver.findElement(By.linkText('Forgot Password?')).getCssValue('color');
{console.log('Passed: Forgot password link text color matched as expected');} if (elementStyle !== expectedForgotPasswordLinkColor) {
else throw new Error(`Forgot password link text color Expected: "${expectedForgotPasswordLinkColor}"; Actual: "${elementStyle}"`);
{console.log(`FAILED: Forgot password link text color Expected: "${expectedForgotPasswordLinkColor}"; Actual: "${elementStyle}"`);} }
console.log('Passed: Forgot password link text color matched as expected');
} }
}, },
//Login button text {
{ description: 'Validate Login button text', action: async () => description: 'Validate Login button text',
{ const elementText = await driver.findElement(By.css('.login')).getAttribute('value'); action: async () => {
if (elementText === expectedLoginButtonText) const elementText = await driver.findElement(By.css('.login')).getAttribute('value');
{console.log('Passed: Login button text matched as expected');} if (elementText !== expectedLoginButtonText) {
else throw new Error(`Expected: "${expectedLoginButtonText}"; Actual: "${elementText}"`);
{console.log(`FAILED: Expected: "${expectedLoginButtonText}"; Actual: "${elementText}"`);} }
console.log('Passed: Login button text matched as expected');
} }
}, },
//Login button background color {
{ description: 'Validate Login button background color', action: async () => description: 'Validate Login button background color',
{ const elementStyle = await driver.findElement(By.css('.login')).getCssValue('background-color'); action: async () => {
if (elementStyle === expectedLoginButtonColor) const elementStyle = await driver.findElement(By.css('.login')).getCssValue('background-color');
{console.log('Passed: Login button background color matched as expected');} if (elementStyle !== expectedLoginButtonColor) {
else throw new Error(`Login button background color Expected: "${expectedLoginButtonColor}"; Actual: "${elementStyle}"`);
{console.log(`FAILED: Login button background color Expected: "${expectedLoginButtonColor}"; Actual: "${elementStyle}"`);} }
console.log('Passed: Login button background color matched as expected');
} }
}, },
//Don't have an account? text {
{ description: 'Validate Dont have account text', action: async () => description: 'Validate Dont have account text',
{ const elementText = await driver.findElement(By.css('p:nth-child(1)')).getText(); action: async () => {
if (elementText === expectedDontHaveAccountText) const elementText = await driver.findElement(By.css('p:nth-child(1)')).getText();
{console.log('Passed: Dont have an account text matched as expected');} if (elementText !== expectedDontHaveAccountText) {
else throw new Error(`Expected: "${expectedDontHaveAccountText}"; Actual: "${elementText}"`);
{console.log(`FAILED: Expected: "${expectedDontHaveAccountText}"; Actual: "${elementText}"`);} }
console.log('Passed: Dont have an account text matched as expected');
} }
}, },
//Free trial button text {
{ description: 'Validate Free trial button text', action: async () => description: 'Validate Free trial button text',
{ const elementText = await driver.findElement(By.css('.btn > span')).getText(); action: async () => {
if (elementText === expectedFreeTrialButtonText) const elementText = await driver.findElement(By.css('.btn > span')).getText();
{console.log('Passed: Free trial button text matched as expected');} if (elementText !== expectedFreeTrialButtonText) {
else throw new Error(`Expected: "${expectedFreeTrialButtonText}"; Actual: "${elementText}"`);
{console.log(`FAILED: Expected: "${expectedFreeTrialButtonText}"; Actual: "${elementText}"`);} }
console.log('Passed: Free trial button text matched as expected');
} }
}, },
//Free trial button background color {
{ description: 'Validate Free trial button background color', action: async () => description: 'Validate Free trial button background color',
{ const elementStyle = await driver.findElement(By.css('.btn > span')).getCssValue('background-color'); action: async () => {
if (elementStyle === expectedFreeTrialButtonColor) const elementStyle = await driver.findElement(By.css('.btn > span')).getCssValue('background-color');
{console.log('Passed: Free trial button background color matched as expected');} if (elementStyle !== expectedFreeTrialButtonColor) {
else throw new Error(`Free trial button background color Expected: "${expectedFreeTrialButtonColor}"; Actual: "${elementStyle}"`);
{console.log(`FAILED: Free trial button background color Expected: "${expectedFreeTrialButtonColor}"; Actual: "${elementStyle}"`);} }
console.log('Passed: Free trial button background color matched as expected');
} }
}, },
//EdGate copyright image {
{ description: 'Verify EdGate copyright image is present', action: async () => description: 'Verify EdGate copyright image is present',
{ const expectedEdGateCopyright = await driver.wait(until.elementLocated(By.css('.logincopyright > img')), 5000).catch(() => false); action: async () => {
if (expectedEdGateCopyright) const expectedEdGateCopyright = await driver.wait(until.elementLocated(By.css('.logincopyright > img')), 5000).catch(() => false);
{console.log('Passed: EdGate copyright image present');} if (!expectedEdGateCopyright) {
else throw new Error('EdGate copyright not found');
{console.log('FAILED: EdGate copyright not found');} }
console.log('Passed: EdGate copyright image present');
} }
}, },
//Validation
{ description: 'Click Login button', action: async () => await driver.findElement(By.css('.login')).click() }, { description: 'Click Login button', action: async () => await driver.findElement(By.css('.login')).click() },
/*Username validation
{ description: 'Validate username validadtion text', action: async () =>
{ const elementText = await driver.findElement(By.css('?')).getText();
if (elementText === expectedUsernameValidationText)
{console.log('Passed: Username validation text matched as expected');}
else
{console.log(`FAILED: Expected: "${expectedUsernameValidationText}"; Actual: "${elementText}"`);}
}
},*/
{ 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: '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() },
//Confirm validation message {
{ description: 'Validate authentication failed validation text', action: async () => description: 'Validate authentication failed validation text',
{ const elementText = await driver.findElement(By.css('.alert')).getText(); action: async () => {
if (elementText === expectedAuthenticationText) const elementText = await driver.findElement(By.css('.alert')).getText();
{console.log('Passed: Authentication text matched as expected');} if (elementText !== expectedAuthenticationText) {
else throw new Error(`Expected: "${expectedAuthenticationText}"; Actual: "${elementText}"`);
{console.log(`FAILED: Expected: "${expectedAuthenticationText}"; Actual: "${elementText}"`);} }
console.log('Passed: Authentication text matched as expected');
} }
}, },
//Authentication validation text background color {
{ description: 'Validate authentication alert background color', action: async () => description: 'Validate authentication alert background color',
{ const elementStyle = await driver.findElement(By.css('.alert')).getCssValue('background-color'); action: async () => {
if (elementStyle === expectedAuthenticationColor) const elementStyle = await driver.findElement(By.css('.alert')).getCssValue('background-color');
{console.log('Passed: Authentication alert background color matched as expected');} if (elementStyle !== expectedAuthenticationColor) {
else throw new Error(`Authentication alert background color Expected: "${expectedAuthenticationColor}"; Actual: "${elementStyle}"`);
{console.log(`FAILED: Authentication alert background color Expected: "${expectedAuthenticationColor}"; Actual: "${elementStyle}"`);} }
console.log('Passed: Authentication alert background color matched as expected');
} }
}, },
@@ -342,10 +351,10 @@ try {
} catch (error) { } catch (error) {
const screenshotPath = await takeScreenshot(driver, stepIndex, `${step.description}_Failed`); const screenshotPath = await takeScreenshot(driver, stepIndex, `${step.description}_Failed`);
worksheet = logStep(worksheet, step.description, 'Failed', stepIndex, timestamp, screenshotPath); worksheet = logStep(worksheet, step.description, 'Failed', stepIndex, timestamp, screenshotPath);
throw error; // Re-throw the error to stop further execution if necessary console.error(`Step ${stepIndex} failed: ${error.message}`);
testStatus = 'Failed';
} }
} }
//Check if login was successful //Check if login was successful
const usernameValidation = await driver.wait(until.elementLocated(By.css('#navbarDropdown > span')), 5000).catch(() => false); const usernameValidation = await driver.wait(until.elementLocated(By.css('#navbarDropdown > span')), 5000).catch(() => false);
@@ -354,11 +363,12 @@ try {
testStatus = 'Passed'; testStatus = 'Passed';
} else { } else {
console.log('FAILED: Unable to log in'); console.log('FAILED: Unable to log in');
testStatus = 'Failed';
} }
// Log test end time // Log test end time
const endTime = new Date().toISOString(); const endTime = new Date().toISOString();
worksheet = logStep(worksheet, 'Test End', 'Ended', '', endTime, ''); worksheet = logStep(worksheet, 'Test End', testStatus, '', endTime, '');
// Write the updated worksheet back to the workbook and save it // Write the updated worksheet back to the workbook and save it
workbook.Sheets['Sheet1'] = worksheet; workbook.Sheets['Sheet1'] = worksheet;