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_alignContentPage = (req, res) => {
res.send('<h2>ExACT Automated Test Script - Align Content Page: Initiated</h2>');
res.send('<h2>ExACT Automated Test Script: Align Content Page(ExACT_alignContentPage); Initiated</h2>');
(async function example() {
let driver = await new Builder().forBrowser('chrome').build();
let testStatus = 'Failed';
@@ -639,15 +639,15 @@ const steps = [
}
},
//Subject: Mathematics (2011) label
//Subject: Mathematics (2012) label
{
description: 'Validate Subject Mathematics (2011) label',
description: 'Validate Subject Mathematics (2012) label',
action: async () => {
const elementText = await driver.findElement(By.css('.show > li:nth-child(3) .checkbox')).getText();
if (elementText !== 'Mathematics (2011)') {
throw new Error(`Expected: Subject: "Mathematics (2011)" checkbox label; Actual: "${elementText}"`);
if (elementText !== 'Mathematics (2012)') {
throw new Error(`Expected: Subject: "Mathematics (2012)" checkbox label; Actual: "${elementText}"`);
}
console.log('Passed: Subject Mathematics (2011) checkbox label matched as expected');
console.log('Passed: Subject Mathematics (2012) checkbox label matched as expected');
}
},
@@ -663,15 +663,15 @@ const steps = [
}
},
//Subject: Science (1064) label
//Subject: Science (1066) label
{
description: 'Validate Subject Science (1064) label',
description: 'Validate Subject Science (1066) label',
action: async () => {
const elementText = await driver.findElement(By.css('.show > li:nth-child(4) .checkbox')).getText();
if (elementText !== 'Science (1064)') {
throw new Error(`Expected: Subject: "Science (2384)" checkbox label; Actual: "${elementText}"`);
if (elementText !== 'Science (1066)') {
throw new Error(`Expected: Subject: "Science (1066)" checkbox label; Actual: "${elementText}"`);
}
console.log('Passed: Subject Science (1064) checkbox label matched as expected');
console.log('Passed: Subject Science (1066) checkbox label matched as expected');
}
},
@@ -687,15 +687,15 @@ const steps = [
}
},
//Subject: Language Arts (414) label
//Subject: Language Arts (416) label
{
description: 'Validate Subject Language Arts (414) label',
description: 'Validate Subject Language Arts (416) label',
action: async () => {
const elementText = await driver.findElement(By.css('.show > li:nth-child(5) .checkbox')).getText();
if (elementText !== 'Language Arts (414)') {
throw new Error(`Expected: Subject: "Language Arts (414)" checkbox label; Actual: "${elementText}"`);
if (elementText !== 'Language Arts (416)') {
throw new Error(`Expected: Subject: "Language Arts (416)" checkbox label; Actual: "${elementText}"`);
}
console.log('Passed: Subject Language Arts (414) checkbox label matched as expected');
console.log('Passed: Subject Language Arts (416) checkbox label matched as expected');
}
},
@@ -711,15 +711,15 @@ const steps = [
}
},
//Subject: Social Studies (75) label
//Subject: Social Studies (77) label
{
description: 'Validate Subject Social Studies (75) label',
description: 'Validate Subject Social Studies (77) label',
action: async () => {
const elementText = await driver.findElement(By.css('.show > li:nth-child(6) .checkbox')).getText();
if (elementText !== 'Social Studies (75)') {
throw new Error(`Expected: Subject: "Social Studies (75)" checkbox label; Actual: "${elementText}"`);
if (elementText !== 'Social Studies (77)') {
throw new Error(`Expected: Subject: "Social Studies (77)" checkbox label; Actual: "${elementText}"`);
}
console.log('Passed: Subject Social Studies (75) checkbox label matched as expected');
console.log('Passed: Subject Social Studies (77) checkbox label matched as expected');
}
},
@@ -803,15 +803,15 @@ const steps = [
}
},
//Alignment Status:Not Aligned (3260) label
//Alignment Status:Not Aligned (3261) label
{
description: 'Validate Alignment Status Not Aligned (3260) label',
description: 'Validate Alignment Status Not Aligned (3261) label',
action: async () => {
const elementText = await driver.findElement(By.css('.show > li:nth-child(3) .checkbox')).getText();
if (elementText !== 'Not Aligned (3260)') {
throw new Error(`Expected: Alignment Status: "Not Aligned (3260)" checkbox label; Actual: "${elementText}"`);
if (elementText !== 'Not Aligned (3261)') {
throw new Error(`Expected: Alignment Status: "Not Aligned (3261)" checkbox label; Actual: "${elementText}"`);
}
console.log('Passed: Alignment Status Not Aligned (3260) checkbox label matched as expected');
console.log('Passed: Alignment Status Not Aligned (3261) checkbox label matched as expected');
}
},
@@ -851,15 +851,15 @@ const steps = [
}
},
//Alignment Status: Pending (16) label
//Alignment Status: Pending (13) label
{
description: 'Validate Alignment Status Pending (16) label',
description: 'Validate Alignment Status Pending (13) label',
action: async () => {
const elementText = await driver.findElement(By.css('.show > li:nth-child(5) .checkbox')).getText();
if (elementText !== 'Pending (16)') {
throw new Error(`Expected: Alignment Status: "Pending (16)" checkbox label; Actual: "${elementText}"`);
if (elementText !== 'Pending (13)') {
throw new Error(`Expected: Alignment Status: "Pending (13)" checkbox label; Actual: "${elementText}"`);
}
console.log('Passed: Alignment Status Pending (16) checkbox label matched as expected');
console.log('Passed: Alignment Status Pending (13) checkbox label matched as expected');
}
},
@@ -875,15 +875,15 @@ const steps = [
}
},
//Alignment Status: Aligned (6) label
//Alignment Status: Aligned (8) label
{
description: 'Validate Alignment Status Aligned (6) label',
description: 'Validate Alignment Status Aligned (8) label',
action: async () => {
const elementText = await driver.findElement(By.css('.show > li:nth-child(6) .checkbox')).getText();
if (elementText !== 'Aligned (6)') {
throw new Error(`Expected: Alignment Status: "Aligned (6)" checkbox label; Actual: "${elementText}"`);
if (elementText !== 'Aligned (8)') {
throw new Error(`Expected: Alignment Status: "Aligned (8)" checkbox label; Actual: "${elementText}"`);
}
console.log('Passed: Alignment Status Aligned (6) checkbox label matched as expected');
console.log('Passed: Alignment Status Aligned (8) checkbox label matched as expected');
}
},
@@ -1966,6 +1966,27 @@ 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) => {
@@ -2013,6 +2034,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();
@@ -2026,17 +2049,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: Align - Edit Content and Align Concept(ExACT_alignContentPage); All test steps completed successfully');
testStatus = 'Passed';
} else {
console.log('FAILED: Unable to log in');
console.log('FAILED: Align - Edit Content and Align Concept(ExACT_alignContentPage); One or more test steps failed');
testStatus = 'Failed';
}