From 8a64b6ddfe06250af9e6b37d068c304a2e421379 Mon Sep 17 00:00:00 2001 From: jhuerta Date: Thu, 5 Nov 2026 15:21:53 -0800 Subject: [PATCH] Added and Completed Specialty Reports Page script --- index.js | 5 +- .../reportSpecialtyReportsPageResults.xlsx | Bin 0 -> 21343 bytes tests/Report/reportSpecialtyReportsPage.js | 1308 +++++++++++++++++ 3 files changed, 1312 insertions(+), 1 deletion(-) create mode 100644 results/reportSpecialtyReportsPageResults.xlsx create mode 100644 tests/Report/reportSpecialtyReportsPage.js diff --git a/index.js b/index.js index 2f36e22..a1972a6 100644 --- a/index.js +++ b/index.js @@ -36,6 +36,7 @@ import activityReportPage from './tests/ActivityReport/ActivityReportPage.js'; //REPORT import reportBuildYourReportPage from './tests/Report/reportBuildYourReportPage.js'; import reportViewQueuedReportsPage from './tests/Report/reportViewQueuedReportsPage.js'; +import reportSpecialtyReportsPage from './tests/Report/reportSpecialtyReportsPage.js'; //APPROVE import approvePage from './tests/Approve/approvePage.js'; @@ -92,7 +93,8 @@ app.get('/', (req, res) => {

REPORT

Build Your Report Page
View Queued Reports Page
- +
Specialty Reports Page
+

APPROVE

Approve Page
@@ -147,6 +149,7 @@ app.get('/activityReportPage', activityReportPage); //ACTIVITY REPORT app.get('/reportBuildYourReportPage', reportBuildYourReportPage); app.get('/reportViewQueuedReportsPage', reportViewQueuedReportsPage); +app.get('/reportSpecialtyReportsPage', reportSpecialtyReportsPage); //APPROVE app.get('/approvePage', approvePage); diff --git a/results/reportSpecialtyReportsPageResults.xlsx b/results/reportSpecialtyReportsPageResults.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..619263009afd8ed6cc68db73aa3c2991bb294590 GIT binary patch literal 21343 zcmeHP+m9^ASzi+qA)_c*0TCe~wMK#m;@z2^nZ2?*VRv@d$M(6b&aRIgBNS@7Yi9av zPj|b!XLdIM$#D=m!UBn45Ii9AfD|MISV|BUn16v6r0~XzFA)Uf7haH%;P+Mat!k?G z4k+Mbt*5&ByVqA=e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y?FmAeouGe#9O4{r_4=}#h#-hvz_2{keYHkD-|XV3_<5X*WHnDFuEsrg zF>SJODUR@7kze1$vWCp|Jl=5dJWshXYlDO5iz>MYO);n=i+BoCgZldnkxEql)!%NY z)6uVrD~bFo_<@e@#5w`}6ALEek8a={o2n6)S{zRFCx^b=xdrKl}~R8 zD%IA~k@dBe68Ud_p%5Xz9#TivR|-nxpW9K^4Rl0(wpSwl(eC`*Psi4C`4am-_bb?W iXVlU4475ala>tmD9=!C!pC+JZ@ZVSA6n}R>PyYoGkF=!# literal 0 HcmV?d00001 diff --git a/tests/Report/reportSpecialtyReportsPage.js b/tests/Report/reportSpecialtyReportsPage.js new file mode 100644 index 0000000..530eace --- /dev/null +++ b/tests/Report/reportSpecialtyReportsPage.js @@ -0,0 +1,1308 @@ +import { Builder, By, Key, until, Select, Browser } from 'selenium-webdriver'; +import { Options as ChromeOptions } from 'selenium-webdriver/chrome.js'; +import fs, { link } from 'fs'; +import XLSX from 'xlsx'; +import path from 'path'; + +const reportSpecialtyReportsPage = (req, res) => { + res.send('

ExACT Automated Test Script: Report - Specialty Reports Page(reportSpecialtyReportsPage); Initiated

'); + (async function example() { + let driver = await new Builder() + .forBrowser('chrome') + .setChromeOptions( + new ChromeOptions() + .addArguments('--disable-features=MediaRouter') + .addArguments('--disable-extensions') + .addArguments('--disable-background-networking') + .addArguments('--log-level=3') + ) + .build(); + let testStatus = 'Failed'; + let workbook; + let worksheet; + const startTime = new Date().toISOString(); + +//CONSTANTS - SPECIALTY REPORTS DROPDOWN LIST +//Expected reports under each category, top to bottom. Update this list when the reports change. +const expectedSpecialtyReports = [ + { category: 'STANDARDS', name: 'State Alignment Intelligence Matrix', description: 'View correlation coverage percentages across standard sets.' }, + { category: 'STANDARDS', name: 'Learning Progression', description: 'View concept progressions across standards and grade levels' }, +]; + +//Compare an element's text, font-family, font-size, and color; push any mismatch to errors +//actualText overrides getText() (e.g. for an input placeholder); color can be read from a pseudo-element (e.g. '::placeholder') +const checkTextStyle = async (errors, name, element, expected, { actualText, pseudo } = {}) => { + const text = actualText !== undefined ? actualText : (await element.getText()).trim(); + const font = await element.getCssValue('font-family'); + const size = await element.getCssValue('font-size'); + const color = pseudo + ? await driver.executeScript(`return getComputedStyle(arguments[0], '${pseudo}').color.replace(/^rgb\\((.*)\\)$/, 'rgba($1, 1)');`, element) + : await element.getCssValue('color'); + + //text + if (text === expected.text) { + console.log(`Passed: ${name} text matched as expected`); + } else { + errors.push(`Expected: ${name} text "${expected.text}"; Actual: "${text}"`); + } + + //font + if (font === expected.font) { + console.log(`Passed: ${name} font-family matched as expected`); + } else { + errors.push(`Expected: ${name} font-family "${expected.font}"; Actual: ${font}`); + } + + //size + if (size === expected.size) { + console.log(`Passed: ${name} text font-size matched as expected`); + } else { + errors.push(`Expected: ${name} text font-size "${expected.size}"; Actual: "${size}"`); + } + + //color + if (color === expected.color) { + console.log(`Passed: ${name} text color matched as expected`); + } else { + errors.push(`Expected: ${name} text color: "${expected.color}"; Actual: "${color}"`); + } +}; + +//Push an error when an element is missing or not displayed +const checkDisplayed = async (errors, name, elements) => { + if (elements.length > 0 && await elements[0].isDisplayed()) { + console.log(`Passed: ${name} was displayed as expected`); + } else { + errors.push(`Expected: ${name} was not displayed`); + } +}; + +//Throw collected messages — catch() will prefix with "FAILED:" +const throwIfErrors = (errors, multipleChecks) => { + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + throw new Error(errors.join('\n')); + } +}; + +const steps = [ + { description: 'Navigate to ExACT Landing Page', action: async () => await driver.navigate().to('https://correlation.edgate.com/exact/login.php') }, + { description: 'Expand browser', action: async () => await driver.manage().window().maximize() }, + + //Login + { + description: 'Login', + action: async () => { + const multipleChecks = 'Log In'; + + console.log('------------->| REPORT - SPECIALTY REPORTS PAGE |<-------------'); + const errors = []; + + await driver.findElement(By.css('.form-control:nth-child(2)')).sendKeys('exact_juan'); + await driver.findElement(By.css('.passfield')).sendKeys('Edgate1!'); + await driver.findElement(By.css('.login')).click(); + console.log('----->| NEXT ACTION: Entered credentials and logged in'); + + //Wait for page readyState + await driver.wait(async () => { + const readyState = await driver.executeScript('return document.readyState'); + return readyState === 'complete'; + }, 30000, 'ExACT Dashboard did not fully load within 30 seconds'); + + //Wait for the dashboard container to exist in DOM + await driver.wait( + until.elementLocated(By.css('.gap-idle-wrap > img')), + 30000, + 'Dashboard image did not appear within 30 seconds' + ); + + //Wait for it to be: visible + await driver.wait(async () => { + try { + const img = await driver.findElement(By.css('.gap-idle-wrap > img')); + return await img.isDisplayed(); + } catch (e) { + return false; + } + }, 30000, 'Dashboard image did not become visible within 30 seconds'); + + //Wait for any loading spinners to disappear + await driver.wait(async () => { + try { + const spinners = await driver.findElements(By.css('.spinner-border')); + for (const spinner of spinners) { + if (await spinner.isDisplayed()) return false; + } + return true; + } catch (e) { + return true; + } + }, 30000, 'Loading spinners did not disappear within 30 seconds'); + + //Wait for the slowest resource to complete + await driver.wait(async () => { + const completed = await driver.executeScript(` + const entries = performance.getEntriesByType('resource'); + return entries.some(entry => + entry.name.includes('content_sets.php') && + entry.responseEnd > 0 + ); + `); + return completed; + }, 30000, 'My Content widget (content_sets.php) did not complete loading within 30 seconds'); + console.log('Passed: My Content widget (content_sets.php) loaded successfully - Dashboard fully loaded'); + + //Final sleep to allow any remaining dynamic content to settle + await driver.sleep(2000); + + console.log('Passed: ExACT Dashboard loaded successfully'); + + if (errors.length > 0) { + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + throw new Error(errors.join('\n')); + } + } + }, + + //Dashboard title + { + description: 'Dashboard title text, size, and color', + action: async () => { + const multipleChecks = 'Dashboard title'; + + const element = await driver.findElement(By.css('.e-heading')); + + //Get text, font, size, and color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //text + if (elementText === 'Correlation Dashboard') { + console.log('Passed: Dashboard title text matched as expected'); + } else { + errors.push(`Expected: "Correlation Dashboard"; Actual: "${elementText}"`); + } + + //font + if (elementFont === `"DM Serif Display", serif`) { + console.log('Passed: Dashboard title font-family matched as expected'); + } else { + errors.push(`Expected: Dashboard title font-family "DM Serif Display, serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '32px') { + console.log('Passed: Dashboard title text font-size matched as expected'); + } else { + errors.push(`Expected: Dashboard title text font-size "32px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Dashboard title text color matched as expected'); + } else { + errors.push(`Expected: Dashboard title text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //NEXT ACTION + { + description: 'Click Report navigation link', + action: async () => { + await driver.findElement(By.linkText('Report')).click(); + console.log('----->| NEXT ACTION: Clicked Report navigation link'); + + //Wait for page readyState + await driver.wait(async () => { + const readyState = await driver.executeScript('return document.readyState'); + return readyState === 'complete'; + }, 30000, 'Report page did not fully load within 30 seconds'); + + //Wait until the element exists in the DOM + const reportPageTitle = await driver.wait( + until.elementLocated(By.css('h2')), + 30000 + ); + + //Wait until it becomes visible + await driver.wait( + until.elementIsVisible(reportPageTitle), + 30000 + ); + } + }, + + //Report page title + { + description: 'Report page title text, size, and color', + action: async () => { + const multipleChecks = 'Report page title'; + + const element = await driver.findElement(By.css('h2')); + + //Get text, font, size, and color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //text + if (elementText === 'Report') { + console.log('Passed: Report page title text matched as expected'); + } else { + errors.push(`Expected: "Report"; Actual: "${elementText}"`); + } + + //font + if (elementFont === `"DM Serif Display", serif`) { + console.log('Passed: Report page title font-family matched as expected'); + } else { + errors.push(`Expected: Report page title font-family "DM Serif Display, serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '32px') { + console.log('Passed: Report page title text font-size matched as expected'); + } else { + errors.push(`Expected: Report page title text font-size "32px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Report page title text color matched as expected'); + } else { + errors.push(`Expected: Report page title text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //Build your report tab + { + description: 'Build your report tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Build your report tab title'; + + const element = await driver.findElement(By.linkText('Build your report')); + + //Get text, font, size, color, and background color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + const elementBgColor = await element.getCssValue('background-color'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Build your report') { + console.log('Passed: Build your report tab title text matched as expected'); + } else { + errors.push(`Expected: "Build your report"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Build your report tab title font-family matched as expected'); + } else { + errors.push(`Expected: Build your report tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Build your report tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Build your report tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(255, 255, 255, 1)') { + console.log('Passed: Build your report tab title text color matched as expected'); + } else { + errors.push(`Expected: Build your report tab title text color: "rgba(255, 255, 255, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Build your report tab title background color matched as expected'); + } else { + errors.push(`Expected: Build your report tab title background color: "rgba(40, 39, 90, 1)"; Actual: "${elementBgColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //View queued reports tab + { + description: 'View queued reports tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'View queued reports tab title'; + + const element = await driver.findElement(By.linkText('View queued reports')); + + //Get text, font, size, color, and background color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + const elementBgColor = await element.getCssValue('background-color'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'View queued reports') { + console.log('Passed: View queued reports tab title text matched as expected'); + } else { + errors.push(`Expected: "View queued reports"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: View queued reports tab title font-family matched as expected'); + } else { + errors.push(`Expected: View queued reports tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: View queued reports tab title text font-size matched as expected'); + } else { + errors.push(`Expected: View queued reports tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: View queued reports tab title text color matched as expected'); + } else { + errors.push(`Expected: View queued reports tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: View queued reports tab title background color matched as expected'); + } else { + errors.push(`Expected: View queued reports tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //Specialty Reports tab + { + description: 'Specialty Reports tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Specialty Reports tab title'; + + const element = await driver.findElement(By.linkText('Specialty Reports')); + + //Get text, font, size, color, and background color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + const elementBgColor = await element.getCssValue('background-color'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Specialty Reports') { + console.log('Passed: Specialty Reports tab title text matched as expected'); + } else { + errors.push(`Expected: "Specialty Reports"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Specialty Reports tab title font-family matched as expected'); + } else { + errors.push(`Expected: Specialty Reports tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Specialty Reports tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Specialty Reports tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Specialty Reports tab title text color matched as expected'); + } else { + errors.push(`Expected: Specialty Reports tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Specialty Reports tab title background color matched as expected'); + } else { + errors.push(`Expected: Specialty Reports tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //NEXT ACTION + { + description: 'Click Specialty Reports tab', + action: async () => { + await driver.findElement(By.linkText('Specialty Reports')).click(); + console.log('----->| NEXT ACTION: Clicked Specialty Reports tab'); + + //Wait for page readyState + await driver.wait(async () => { + const readyState = await driver.executeScript('return document.readyState'); + return readyState === 'complete'; + }, 30000, 'Specialty Reports page did not fully load within 30 seconds'); + + //Wait until the element exists in the DOM + const specialtyReportsPageTitle = await driver.wait( + until.elementLocated(By.css('h2')), + 30000 + ); + + //Wait until it becomes visible + await driver.wait( + until.elementIsVisible(specialtyReportsPageTitle), + 30000 + ); + } + }, + + //Report page title + { + description: 'Report page title text, size, and color', + action: async () => { + const multipleChecks = 'Report page title'; + + const element = await driver.findElement(By.css('h2')); + + //Get text, font, size, and color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //text + if (elementText === 'Report') { + console.log('Passed: Report page title text matched as expected'); + } else { + errors.push(`Expected: "Report"; Actual: "${elementText}"`); + } + + //font + if (elementFont === `"DM Serif Display", serif`) { + console.log('Passed: Report page title font-family matched as expected'); + } else { + errors.push(`Expected: Report page title font-family "DM Serif Display, serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '32px') { + console.log('Passed: Report page title text font-size matched as expected'); + } else { + errors.push(`Expected: Report page title text font-size "32px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Report page title text color matched as expected'); + } else { + errors.push(`Expected: Report page title text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //Build your report tab + { + description: 'Build your report tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Build your report tab title'; + + const element = await driver.findElement(By.linkText('Build your report')); + + //Get text, font, size, color, and background color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + const elementBgColor = await element.getCssValue('background-color'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Build your report') { + console.log('Passed: Build your report tab title text matched as expected'); + } else { + errors.push(`Expected: "Build your report"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Build your report tab title font-family matched as expected'); + } else { + errors.push(`Expected: Build your report tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Build your report tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Build your report tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Build your report tab title text color matched as expected'); + } else { + errors.push(`Expected: Build your report tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Build your report tab title background color matched as expected'); + } else { + errors.push(`Expected: Build your report tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //View queued reports tab + { + description: 'View queued reports tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'View queued reports tab title'; + + const element = await driver.findElement(By.linkText('View queued reports')); + + //Get text, font, size, color, and background color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + const elementBgColor = await element.getCssValue('background-color'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'View queued reports') { + console.log('Passed: View queued reports tab title text matched as expected'); + } else { + errors.push(`Expected: "View queued reports"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: View queued reports tab title font-family matched as expected'); + } else { + errors.push(`Expected: View queued reports tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: View queued reports tab title text font-size matched as expected'); + } else { + errors.push(`Expected: View queued reports tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: View queued reports tab title text color matched as expected'); + } else { + errors.push(`Expected: View queued reports tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: View queued reports tab title background color matched as expected'); + } else { + errors.push(`Expected: View queued reports tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //Specialty Reports tab + { + description: 'Specialty Reports tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Specialty Reports tab title'; + + const element = await driver.findElement(By.linkText('Specialty Reports')); + + //Get text, font, size, color, and background color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + const elementBgColor = await element.getCssValue('background-color'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Specialty Reports') { + console.log('Passed: Specialty Reports tab title text matched as expected'); + } else { + errors.push(`Expected: "Specialty Reports"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Specialty Reports tab title font-family matched as expected'); + } else { + errors.push(`Expected: Specialty Reports tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Specialty Reports tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Specialty Reports tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(255, 255, 255, 1)') { + console.log('Passed: Specialty Reports tab title text color matched as expected'); + } else { + errors.push(`Expected: Specialty Reports tab title text color: "rgba(255, 255, 255, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Specialty Reports tab title background color matched as expected'); + } else { + errors.push(`Expected: Specialty Reports tab title background color: "rgba(40, 39, 90, 1)"; Actual: "${elementBgColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //Select Specialty Report widget title + { + description: 'Select Specialty Report widget title text, size, and color', + action: async () => { + const multipleChecks = 'Select Specialty Report widget title'; + + const element = await driver.findElement(By.css('.font-weight-bold')); + + //Get text, font, size, and color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //text + if (elementText === 'Select Specialty Report') { + console.log('Passed: Select Specialty Report widget title text matched as expected'); + } else { + errors.push(`Expected: "Select Specialty Report"; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Select Specialty Report widget title font-family matched as expected'); + } else { + errors.push(`Expected: Select Specialty Report widget title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '13px') { + console.log('Passed: Select Specialty Report widget title text font-size matched as expected'); + } else { + errors.push(`Expected: Select Specialty Report widget title text font-size "13px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Select Specialty Report widget title text color matched as expected'); + } else { + errors.push(`Expected: Select Specialty Report widget title text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //Select Specialty Report dropdown (closed) - file icon, default text, and dropdown icon + { + description: 'Select Specialty Report dropdown icons, default text, size, and color', + action: async () => { + const multipleChecks = 'Select Specialty Report dropdown'; + + //Track all errors + const errors = []; + + await checkDisplayed(errors, 'Select Specialty Report dropdown file icon', await driver.findElements(By.css('#sp-trigger .sp-trigger-icon'))); + await checkDisplayed(errors, 'Select Specialty Report dropdown icon', await driver.findElements(By.css('#sp-trigger .sp-chevron'))); + + await checkTextStyle(errors, 'Select Specialty Report dropdown default', await driver.findElement(By.css('#sp-trigger-text')), + { text: 'Search and select a report...', font: 'Poppins, sans-serif', size: '14px', color: 'rgba(170, 170, 170, 1)' }); + + throwIfErrors(errors, multipleChecks); + } + }, + + //NEXT ACTION + { + description: 'Open Select Specialty Report dropdown', + action: async () => { + await driver.findElement(By.css('#sp-trigger')).click(); + await driver.wait(until.elementLocated(By.css('#sp-panel.sp-open')), 5000, 'Select Specialty Report dropdown did not open within 5 seconds'); + await driver.wait(until.elementIsVisible(await driver.findElement(By.css('#sp-panel'))), 5000, 'Select Specialty Report dropdown panel was not visible within 5 seconds'); + console.log('----->| NEXT ACTION: Opened Select Specialty Report dropdown'); + } + }, + + //Search reports textbox - search icon, placeholder text, and "x" clear icon + { + description: 'Search reports textbox icons, placeholder text, size, and color', + action: async () => { + const multipleChecks = 'Search reports textbox'; + + //Track all errors + const errors = []; + + await checkDisplayed(errors, 'Search reports search icon', await driver.findElements(By.css('#sp-panel .sp-search-icon'))); + await checkDisplayed(errors, 'Search reports "x" clear icon', await driver.findElements(By.css('#sp-search-clear'))); + + //Placeholder text is an attribute, and its color comes from the ::placeholder pseudo-element + const searchBox = await driver.findElement(By.css('#sp-search')); + await checkTextStyle(errors, 'Search reports placeholder', searchBox, + { text: 'Search reports...', font: 'Poppins, sans-serif', size: '14px', color: 'rgba(170, 170, 170, 1)' }, + { actualText: await searchBox.getAttribute('placeholder'), pseudo: '::placeholder' }); + + throwIfErrors(errors, multipleChecks); + } + }, + + //Specialty reports list - category headers, then each report's file icon, name, and description + { + description: 'Specialty reports list categories, icons, names, descriptions, size, and color', + action: async () => { + const multipleChecks = 'Specialty reports list'; + + //Track all errors + const errors = []; + + //Category headers - CSS shows them in capitals, and getText() returns the displayed text + const expectedCategories = [...new Set(expectedSpecialtyReports.map(report => report.category))]; + const categoryHeaders = await driver.findElements(By.css('#sp-list .sp-category-header')); + if (categoryHeaders.length !== expectedCategories.length) { + errors.push(`Expected: ${expectedCategories.length} category headers; Actual: ${categoryHeaders.length}`); + } + for (const [index, category] of expectedCategories.entries()) { + if (categoryHeaders[index]) { + await checkTextStyle(errors, `${category} category header`, categoryHeaders[index], + { text: category, font: 'Poppins, sans-serif', size: '11px', color: 'rgba(170, 170, 170, 1)' }); + } + } + + //Reports + const items = await driver.findElements(By.css('#sp-list .sp-item')); + if (items.length !== expectedSpecialtyReports.length) { + errors.push(`Expected: ${expectedSpecialtyReports.length} reports in the list; Actual: ${items.length}`); + } + for (const [index, expected] of expectedSpecialtyReports.entries()) { + const item = items[index]; + if (!item) { + errors.push(`Expected: "${expected.name}" report was not in the list`); + continue; + } + + //Category the report is listed under + const itemCategory = (await item.getAttribute('data-category')).toUpperCase(); + if (itemCategory === expected.category) { + console.log(`Passed: ${expected.name} category matched as expected`); + } else { + errors.push(`Expected: ${expected.name} category "${expected.category}"; Actual: "${itemCategory}"`); + } + + await checkDisplayed(errors, `${expected.name} file icon`, await item.findElements(By.css('.sp-item-icon'))); + + await checkTextStyle(errors, `${expected.name} report name`, await item.findElement(By.css('.sp-item-name')), + { text: expected.name, font: 'Poppins, sans-serif', size: '14px', color: 'rgba(40, 39, 90, 1)' }); + + await checkTextStyle(errors, `${expected.name} report description`, await item.findElement(By.css('.sp-item-desc')), + { text: expected.description, font: 'Poppins, sans-serif', size: '12px', color: 'rgba(170, 170, 170, 1)' }); + } + + //Footer - report count + await checkTextStyle(errors, 'Specialty reports list footer', await driver.findElement(By.css('#sp-panel .sp-footer')), + { text: `${expectedSpecialtyReports.length} reports available`, font: 'Poppins, sans-serif', size: '12px', color: 'rgba(170, 170, 170, 1)' }); + + throwIfErrors(errors, multipleChecks); + } + }, + + //NEXT ACTION + { + description: 'Close Select Specialty Report dropdown', + action: async () => { + await driver.findElement(By.css('#sp-trigger')).click(); + await driver.wait(async () => (await driver.findElements(By.css('#sp-panel.sp-open'))).length === 0, 5000, 'Select Specialty Report dropdown did not close within 5 seconds'); + console.log('----->| NEXT ACTION: Closed Select Specialty Report dropdown'); + } + }, + + //Widget instructions + { + description: 'Widget instructions text, size, color, and icon', + action: async () => { + const multipleChecks = 'Widget instructions'; + + const elementIcon = await driver.findElement(By.css('.sp-doc-icon')); + const element = await driver.findElement(By.css('.sp-empty-title')); + + //Get text, font, size, and color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //icon present + if (await elementIcon.isDisplayed()) { + console.log('Passed: Widget instructions icon was displayed as expected'); + } else { + errors.push('Expected: Widget instructions icon was not displayed'); + } + + //text + if (elementText === 'Please select a report from the list to begin.') { + console.log('Passed: Widget instructions text matched as expected'); + } else { + errors.push(`Expected: "Please select a report from the list to begin."; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Widget instructions font-family matched as expected'); + } else { + errors.push(`Expected: Widget instructions font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '18px') { + console.log('Passed: Widget instructions text font-size matched as expected'); + } else { + errors.push(`Expected: Widget instructions text font-size "18px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Widget instructions text color matched as expected'); + } else { + errors.push(`Expected: Widget instructions text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //Widget sub instructions + { + description: 'Widget sub instructions text, size, and color', + action: async () => { + const multipleChecks = 'Widget sub instructions'; + + const element = await driver.findElement(By.css('.sp-empty-sub')); + + //Get text, font, size, and color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //text |
splits the text into two lines, so getText() returns them joined by "\n" + const expectedText = 'Report parameters and generation\noptions will appear after selecting a report.'; + if (elementText === expectedText) { + console.log('Passed: Widget sub instructions text matched as expected'); + } else { + errors.push(`Expected: Line 1: "Report parameters and generation" | Line 2: "options will appear after selecting a report."; Actual: ${JSON.stringify(elementText)}`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Widget sub instructions font-family matched as expected'); + } else { + errors.push(`Expected: Widget sub instructions font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '14px') { + console.log('Passed: Widget sub instructions text font-size matched as expected'); + } else { + errors.push(`Expected: Widget sub instructions text font-size "14px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(170, 170, 170, 1)') { + console.log('Passed: Widget sub instructions text color matched as expected'); + } else { + errors.push(`Expected: Widget sub instructions text color: "rgba(170, 170, 170, 1)"; Actual: "${elementColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //FOOTER + //EdGate Copyright Logo + { + description: 'EdGate Copyright Logo', + action: async () => { + const multipleChecks = 'EdGate Copyright Logo'; + + const element = await driver.findElement(By.css('footer .pull-right > a')); + const elementLogo = await element.findElement(By.css('img')); + const expectedHref = 'https://www.edgate.com/'; + + //Track all errors + const errors = []; + + //icon present + if (await elementLogo.isDisplayed()) { + console.log('Passed: EdGate Copyright Logo was displayed as expected'); + } else { + errors.push('Expected: EdGate Copyright Logo was not displayed'); + } + + //href - browser resolves the link with a trailing slash, so remove it before comparing + const actualHref = await element.getAttribute('href'); + if (actualHref && actualHref === expectedHref) { + console.log('Passed: EdGate Copyright Logo href matched as expected'); + } else { + errors.push(`Expected: EdGate Copyright Logo href to be: "https://www.edgate.com/"; actual: "${actualHref}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //NEXT ACTION + { + description: 'Log Out', + action: async () => { + const multipleChecks = 'Log Out'; + + //Track all errors + const errors = []; + + await driver.findElement(By.css('#navbarDropdown > span')).click(); + await driver.sleep(2000); + await driver.findElement(By.linkText('Log Out')).click(); + console.log('----->| NEXT ACTION: Clicked User Profile and Logged Out'); + + //Wait until the element exists in the DOM + const exactLogo = await driver.wait( + until.elementLocated(By.css('.logo')), + 30000 + ); + + //Wait until it becomes visible + await driver.wait( + until.elementIsVisible(exactLogo), + 30000 + ); + + //Wait for page to load completely + await driver.wait(async () => { + const readyState = await driver.executeScript('return document.readyState'); + return readyState === 'complete'; + }, 30000, 'ExACT Langing page did not fully load within 30 seconds'); + console.log('Passed: ExACT Landing Page loaded successfully'); + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, +]; + +const logStep = (worksheet, stepDescription, status, stepIndex, timestamp, screenshotPath) => { + const json_data = XLSX.utils.sheet_to_json(worksheet, { header: 1 }); + json_data.push([stepIndex, stepDescription, status, timestamp, screenshotPath]); + return XLSX.utils.aoa_to_sheet(json_data); +}; + +const takeScreenshot = async (driver, stepIndex, stepDescription) => { + const screenshot = await driver.takeScreenshot(); + + const dir = path.join('screenshots', 'reportSpecialtyReportsPage'); + + const screenshotFileName = `step_${stepIndex}_${stepDescription.replace(/\s+/g, '_')}.png`; + const screenshotPath = path.join(dir, screenshotFileName); + fs.writeFileSync(screenshotPath, screenshot, 'base64'); + return screenshotPath; +}; + +const resultsFile = path.join('results', 'reportSpecialtyReportsPageResults.xlsx'); + +const clearOldResults = () => { + //Remove old screenshots + const screenshotDir = path.join('screenshots', 'reportSpecialtyReportsPage'); + if (fs.existsSync(screenshotDir)) { + fs.rmSync(screenshotDir, { recursive: true, force: true }); + } + fs.mkdirSync(screenshotDir, { recursive: true }); + + //Remove old Excel file + if (fs.existsSync(resultsFile)) { + fs.unlinkSync(resultsFile); + } + fs.mkdirSync('results', { recursive: true }); +}; + +try { + //Initialize workbook and worksheet + clearOldResults(); + + //Initialize workbook and worksheet + workbook = XLSX.utils.book_new(); + worksheet = XLSX.utils.aoa_to_sheet([ + ['Step Number', 'Step Description', 'Status', 'Timestamp', 'Screenshot'] + ]); + XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1'); + + //Log test start time + worksheet = logStep(worksheet, 'Test Start', 'Started', '', startTime, ''); + + let allStepsPassed = true; + + const failedSteps = []; //Track failed steps + + for (const step of steps) { + const stepIndex = steps.indexOf(step) + 1; + const timestamp = new Date().toISOString(); + + try { + //Screenshot of failed step + await step.action(); + + //Log a successful step with no screenshot + worksheet = logStep( + worksheet, + step.description, + 'Passed', + stepIndex, + timestamp, + null //No screenshot for passed steps + ); + + } catch (error) { + //Only take screenshot if the step fails + const screenshotPath = await takeScreenshot( + driver, + stepIndex, + `${step.description}_Failed` + ); + + worksheet = logStep( + worksheet, + step.description, + 'Failed', + stepIndex, + timestamp, + screenshotPath + ); + + console.error(`Step ${stepIndex} FAILED: ${error.message}`); + failedSteps.push(`Step ${stepIndex}: ${step.description} - ${error.message}`); //Track failed step + testStatus = 'Failed'; + allStepsPassed = false; + } + } + + if (allStepsPassed) { + console.log('------------->| THE END |<-------------'); + console.log('PASSED: Report - Specialty Reports Page(reportSpecialtyReportsPage); All test steps completed successfully'); + testStatus = 'Passed'; + } else { + console.log('------------->| THE END |<-------------'); + console.log('FAILED: Report - Specialty Reports Page(reportSpecialtyReportsPage); One or more test steps failed'); + console.log('FAILED STEPS:'); + failedSteps.forEach(step => console.error(` ✗ ${step}`)); + testStatus = 'Failed'; + } + + //Log test end time + const endTime = new Date().toISOString(); + worksheet = logStep(worksheet, 'Test End', testStatus, '', endTime, ''); + + //Write the updated worksheet back to the workbook and save it + workbook.Sheets['Sheet1'] = worksheet; + XLSX.writeFile(workbook, resultsFile); +} finally { + await driver.quit(); +} + })(); +} + +export default reportSpecialtyReportsPage;