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_contentPage = (req, res) => {
res.send('<h2>ExACT Automated Test Script - Content Page: Initiated</h2>');
res.send('<h2>ExACT Automated Test Script - Content Page(ExACT_contentPage): Initiated</h2>');
(async function example() {
let driver = await new Builder().forBrowser('chrome').build();
let testStatus = 'Failed';
@@ -586,11 +586,59 @@ const steps = [
}
},
//Social and Emotional Learning checkbox
//Language Arts checkbox (added?)
{
description: 'Verify Language Arts checkbox icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('#metasubjectsLanguage\\ Arts')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('Expected: Language Arts checkbox icon not found');
}
console.log('Passed: Language Arts checkbox icon present');
}
},
//Language Arts label (added?)
{
description: 'Validate Language Arts label',
action: async () => {
const elementText = await driver.findElement(By.css('.form-group:nth-child(6) > label:nth-child(10)')).getText();
if (elementText !== 'Language Arts') {
throw new Error(`Expected: "Language Arts"; Actual: "${elementText}"`);
}
console.log('Passed: Language Arts label matched as expected');
}
},
//Social Studies checkbox (added?)
{
description: 'Verify Social Studies checkbox icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('#metasubjectsSocial\\ Studies')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('Expected: Social Studies checkbox icon not found');
}
console.log('Passed: Social Studies checkbox icon present');
}
},
//Social Studies label (added?)
{
description: 'Validate Social Studies label',
action: async () => {
const elementText = await driver.findElement(By.css('.form-group:nth-child(6) > label:nth-child(13)')).getText();
if (elementText !== 'Social Studies') {
throw new Error(`Expected: "Social Studies"; Actual: "${elementText}"`);
}
console.log('Passed: Social Studies label matched as expected');
}
},
//Social and Emotional Learning checkbox (pushed down)
{
description: 'Verify Social and Emotional Learning checkbox icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.id('metasubjectsSocial and Emotional Learning')), 5000).catch(() => false);
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('#metasubjectsSocial\\ and\\ Emotional\\ Learning')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('Expected: Social and Emotional Learning checkbox icon not found');
}
@@ -598,11 +646,11 @@ const steps = [
}
},
//Social and Emotional Learning label
//Social and Emotional Learning label (pushed down)
{
description: 'Validate Social and Emotional Learning label',
action: async () => {
const elementText = await driver.findElement(By.css('.form-group:nth-child(6) > label:nth-child(10)')).getText();
const elementText = await driver.findElement(By.css('.form-group:nth-child(6) > label:nth-child(16)')).getText();
if (elementText !== 'Social and Emotional Learning') {
throw new Error(`Expected: "Social and Emotional Learning"; Actual: "${elementText}"`);
}
@@ -2048,15 +2096,15 @@ const steps = [
}
},
//Filtered Content 2 alignment label
//Filtered Content 2 ECS Alignment (reset) label (previously Not Aligned)
{
description: 'Validate Filtered Content 2 Not Aligned label',
description: 'Validate Filtered Content 2 ECS Alignment (reset) label',
action: async () => {
const elementText = await driver.findElement(By.css('#alignstatuslink873578655 > .display-alignment')).getText();
if (elementText !== 'Not Aligned') {
throw new Error(`Expected: Filtered Content 2 Not Aligned label did not match; Actual: "${elementText}"`);
if (elementText !== 'ECS Alignment (reset)') {
throw new Error(`Expected: Filtered Content 2 "ECS Alignment (reset)" label did not match; Actual: "${elementText}"`);
}
console.log('Passed: Filtered Content 2 Not Aligned label matched as expected');
console.log('Passed: Filtered Content 2 ECS Alignment (reset) label matched as expected');
}
},
@@ -2099,7 +2147,7 @@ const steps = [
//NEXT ACTION - VIEW EDIT MODE
{ description: 'Click Edit View button', action: async () => await driver.findElement(By.linkText('Edit View')).click() },
//Wait for dashboard to load - Correlation Coverages View Details button
//Wait for page to load - Correlation Coverages View Details button
{
description: 'Wait for Actions button to load',
action: async () => {
@@ -2323,15 +2371,15 @@ const steps = [
}
},
//Second content item alignment pending text
//Second content item ECS Alignment (reset) text (previously Not Aligned)
{
description: 'Validate Altered Elephant Behavior alignment pending text',
description: 'Validate Altered Elephant Behavior ECS Alignment (reset) text',
action: async () => {
const elementText = await driver.findElement(By.css('#alignstatuslink873578655 > .display-alignment')).getText();
if (elementText !== 'Not Aligned') {
throw new Error(`Expected: Altered Elephant Behavior "Not Aligned" text; Actual: "${elementText}"`);
if (elementText !== 'ECS Alignment (reset)') {
throw new Error(`Expected: Altered Elephant Behavior "ECS Alignment (reset)" text; Actual: "${elementText}"`);
}
console.log('Passed: Altered Elephant Behavior "Not Aligned" text matched as expected');
console.log('Passed: Altered Elephant Behavior ECS Alignment (reset) text matched as expected');
}
},
@@ -2417,12 +2465,40 @@ const steps = [
action: async () => {
const elementStyle = await driver.findElement(By.linkText('Delete')).getCssValue('color');
if (elementStyle !== 'rgba(220, 53, 69, 1)') {
throw new Error(`Expected: Actions Delete text color did not match; Actual: "${elementStyle}"`);
throw new Error(`Expected: ECS-2920 | Actions Delete text color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Delete text color matched as expected');
console.log('Passed: ECS-2920 | Delete text color matched as expected');
}
},
//NEXT ACTION - Reset | ECS-2920
{ description: 'Click Actions button', action: async () => await driver.findElement(By.linkText('Actions')).click() },
{ description: 'Wait for action to complete', action: async () => await driver.sleep(2000) },
{ description: 'Click Detail View button', action: async () => await driver.findElement(By.linkText('Detail View')).click() },
{ description: 'Wait for action to complete', action: async () => await driver.sleep(2000) },
//Wait for page to load - Content 1 edit button
{
description: 'Wait for Content 1 edit button to load',
action: async () => {
return await driver.wait(until.elementLocated(By.css('.card:nth-child(8) .lo-title .fa')), 10000).catch(() => false);
}
},
//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) => {
@@ -2470,6 +2546,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();
@@ -2483,17 +2561,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: Content Page(ExACT_contentPage); All test steps completed successfully');
testStatus = 'Passed';
} else {
console.log('FAILED: Unable to log in');
console.log('FAILED: Content Page(ExACT_contentPage); One or more test steps failed');
testStatus = 'Failed';
}