Added LogOut and updated test results

This commit is contained in:
2025-05-07 15:14:53 -07:00
parent fee67f7164
commit 7c399ee06d
9 changed files with 386 additions and 158 deletions

View File

@@ -4,7 +4,7 @@ import XLSX from 'xlsx';
import path from 'path';
const ExACT_editItem = (req, res) => {
res.send('<h2>ExACT Automated Test Script - Edit Item: Initiated</h2>');
res.send('<h2>ExACT Automated Test Script - Edit Item(ExACT_editItem): Initiated</h2>');
(async function example() {
let driver = await new Builder().forBrowser('chrome').build();
let testStatus = 'Failed';
@@ -2447,6 +2447,20 @@ const steps = [
}
},
//LOG OUT
//NEXT ACTION - Log out
{ description: 'Click Username dropdown', action: async () => await driver.findElement(By.css('#navbarDropdown > span')).click() },
{ description: 'Wait for action to complete', action: async () => await driver.sleep(2000) },
{ description: 'Click Log Out link', action: async () => await driver.findElement(By.linkText('Log Out')).click() },
{ description: 'Wait for action to complete', action: async () => await driver.sleep(2000) },
//Wait for login screen to load
{
description: 'Wait for log out process to complete',
action: async () => {
return await driver.wait(until.elementLocated(By.css('.login')), 10000).catch(() => false);
}
},
];
const logStep = (worksheet, stepDescription, status, stepIndex, timestamp, screenshotPath) => {
@@ -2494,6 +2508,8 @@ try {
// Log test start time
worksheet = logStep(worksheet, 'Test Start', 'Started', '', startTime, '');
let allStepsPassed = true;
for (const step of steps) {
const stepIndex = steps.indexOf(step) + 1;
const timestamp = new Date().toISOString();
@@ -2507,17 +2523,18 @@ try {
worksheet = logStep(worksheet, step.description, 'Failed', stepIndex, timestamp, screenshotPath);
console.error(`Step ${stepIndex} FAILED: ${error.message}`);
testStatus = 'Failed';
allStepsPassed = false;
}
}
//Check if login was successful
const usernameValidation = await driver.wait(until.elementLocated(By.css('#navbarDropdown > span')), 5000).catch(() => false);
//Check if log out was successful
const loginButton = await driver.wait(until.elementLocated(By.css('.login')), 5000).catch(() => false);
if (usernameValidation) {
console.log('PASSED: System logged in as expected');
if (loginButton && allStepsPassed) {
console.log('PASSED: Edit Item(ExACT_editItem); All test steps completed successfully');
testStatus = 'Passed';
} else {
console.log('FAILED: Unable to log in');
console.log('FAILED: Edit Item(ExACT_editItem); One or more test steps failed');
testStatus = 'Failed';
}