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_dashboardMyContent = (req, res) => {
res.send('<h2>ExACT Automated Test Script - Dashboard - My Content widget: Initiated</h2>');
res.send('<h2>ExACT Automated Test Script - Dashboard - My Content Widget(ExACT_dashboardMyContent): Initiated</h2>');
(async function example() {
let driver = await new Builder().forBrowser('chrome').build();
let testStatus = 'Failed';
@@ -2596,62 +2596,76 @@ const steps = [
await alert.accept();
await driver.sleep(2000);
}
},
},
//Validate confirmation message
{
description: 'Validate confirmation message',
action: async () => {
const elementText = await driver.findElement(By.css('strong')).getText();
if (elementText !== 'The content set was successfuly deleted') {
throw new Error(`Expected: Alert banner deleted confirmation message did not match; Actual: "${elementText}"`);
//Validate confirmation message
{
description: 'Validate confirmation message',
action: async () => {
const elementText = await driver.findElement(By.css('strong')).getText();
if (elementText !== 'The content set was successfuly deleted') {
throw new Error(`Expected: Alert banner deleted confirmation message did not match; Actual: "${elementText}"`);
}
console.log('Passed: Alert banner deleted confirmation message displayed as expected');
}
console.log('Passed: Alert banner deleted confirmation message displayed as expected');
}
},
},
//Validate confirmation message background color -green
{
description: 'Validate confirmation message background color',
action: async () => {
const elementStyle = await driver.findElement(By.css('#statalert')).getCssValue('background-color');
if (elementStyle !== 'rgba(40, 167, 69, 1)') {
throw new Error(`Expected: Alert banner background color did not match; Actual: "${elementStyle}"`);
//Validate confirmation message background color -green
{
description: 'Validate confirmation message background color',
action: async () => {
const elementStyle = await driver.findElement(By.css('#statalert')).getCssValue('background-color');
if (elementStyle !== 'rgba(40, 167, 69, 1)') {
throw new Error(`Expected: Alert banner background color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Alert banner background color matched as expected');
}
console.log('Passed: Alert banner background color matched as expected');
}
},
},
//Wait for dashboard to load
{
description: 'Wait for dashboard load to completely',
action: async () => {
return await driver.wait(until.elementLocated(By.linkText('View Details')), 10000).catch(() => false);
}
},
//Wait for dashboard to load
{
description: 'Wait for dashboard load to completely',
action: async () => {
return await driver.wait(until.elementLocated(By.linkText('View Details')), 10000).catch(() => false);
}
},
//Verify content was deleted
{
description: 'Verify content set deletion',
action: async () => {
const filterSearch = await driver.wait(
until.elementLocated(By.css('#content-org-filter')),
5000
);
await filterSearch.clear();
await filterSearch.sendKeys('QA');
await driver.sleep(2000);
const createdContentSet = await driver.findElements(
By.linkText(createContentSetName)
);
if (createdContentSet.length > 0) {
throw new Error('Content set was not deleted successfully');
//Verify content was deleted
{
description: 'Verify content set deletion',
action: async () => {
const filterSearch = await driver.wait(
until.elementLocated(By.css('#content-org-filter')),
5000
);
await filterSearch.clear();
await filterSearch.sendKeys('QA');
await driver.sleep(2000);
const createdContentSet = await driver.findElements(
By.linkText(createContentSetName)
);
if (createdContentSet.length > 0) {
throw new Error('Content set was not deleted successfully');
}
}
}
}
},
//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) => {
@@ -2699,6 +2713,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();
@@ -2712,17 +2728,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: My Content widget(ExACT_dashboardMyContent); All test steps completed successfully');
testStatus = 'Passed';
} else {
console.log('FAILED: Unable to log in');
console.log('FAILED: My Content widget(ExACT_dashboardMyContent); One or more test steps failed');
testStatus = 'Failed';
}