From 57e89b6b530fa839fccd8a0455d2e9e073eedfd4 Mon Sep 17 00:00:00 2001 From: jhuerta Date: Thu, 5 Nov 2026 18:33:20 -0800 Subject: [PATCH] Added and Completed Approve tabs --- index.js | 15 +- .../approveApprovalHistoryPageResults.xlsx | Bin 0 -> 21298 bytes .../approveContentSubmissionsPageResults.xlsx | Bin 0 -> 21304 bytes results/approvePageResults.xlsx | Bin 19984 -> 19984 bytes .../approvePendingAlignmentsPageResults.xlsx | Bin 0 -> 19984 bytes .../approveRejectionHistoryPageResults.xlsx | Bin 0 -> 21456 bytes tests/Approve/approveApprovalHistoryPage.js | 1541 +++++++++++++++++ .../Approve/approveContentSubmissionsPage.js | 1541 +++++++++++++++++ ...age.js => approvePendingAlignmentsPage.js} | 26 +- tests/Approve/approveRejectionHistoryPage.js | 1541 +++++++++++++++++ 10 files changed, 4648 insertions(+), 16 deletions(-) create mode 100644 results/approveApprovalHistoryPageResults.xlsx create mode 100644 results/approveContentSubmissionsPageResults.xlsx create mode 100644 results/approvePendingAlignmentsPageResults.xlsx create mode 100644 results/approveRejectionHistoryPageResults.xlsx create mode 100644 tests/Approve/approveApprovalHistoryPage.js create mode 100644 tests/Approve/approveContentSubmissionsPage.js rename tests/Approve/{approvePage.js => approvePendingAlignmentsPage.js} (97%) create mode 100644 tests/Approve/approveRejectionHistoryPage.js diff --git a/index.js b/index.js index a1972a6..bc60657 100644 --- a/index.js +++ b/index.js @@ -39,7 +39,10 @@ import reportViewQueuedReportsPage from './tests/Report/reportViewQueuedReportsP import reportSpecialtyReportsPage from './tests/Report/reportSpecialtyReportsPage.js'; //APPROVE -import approvePage from './tests/Approve/approvePage.js'; +import approvePendingAlignmentsPage from './tests/Approve/approvePendingAlignmentsPage.js'; +import approveContentSubmissionsPage from './tests/Approve/approveContentSubmissionsPage.js'; +import approveApprovalHistoryPage from './tests/Approve/approveApprovalHistoryPage.js'; +import approveRejectionHistoryPage from './tests/Approve/approveRejectionHistoryPage.js'; //Content import ExACT_contentPage from './tests/ExACT_contentPage.js'; @@ -96,7 +99,10 @@ app.get('/', (req, res) => {
Specialty Reports Page

APPROVE

-
Approve Page
+
Pending Alignments Page
+
Content Submissions Page
+
Approval History Page
+
Rejection History Page
| APPROVE - APPROVAL HISTORY 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 Approve navigation link', + action: async () => { + await driver.findElement(By.linkText('Approve')).click(); + console.log('----->| NEXT ACTION: Clicked Approve navigation link'); + + //Wait for page readyState + await driver.wait(async () => { + const readyState = await driver.executeScript('return document.readyState'); + return readyState === 'complete'; + }, 30000, 'Pending Alignments page did not fully load within 30 seconds'); + + //Wait until the element exists in the DOM + const tabDefaultText = await driver.wait( + until.elementLocated(By.css('#tabs-2 b')), + 30000 + ); + + //Wait until it becomes visible + await driver.wait( + until.elementIsVisible(tabDefaultText), + 30000 + ); + } + }, + + //Content Approval title + { + description: 'Content Approval title text, size, and color', + action: async () => { + const multipleChecks = 'Content Approval 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 === 'Content Approval') { + console.log('Passed: Content Approval title text matched as expected'); + } else { + errors.push(`Expected: "Content Approval"; Actual: "${elementText}"`); + } + + //font + if (elementFont === `"DM Serif Display", serif`) { + console.log('Passed: Content Approval title font-family matched as expected'); + } else { + errors.push(`Expected: Content Approval title font-family "DM Serif Display, serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '32px') { + console.log('Passed: Content Approval title text font-size matched as expected'); + } else { + errors.push(`Expected: Content Approval title text font-size "32px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Content Approval title text color matched as expected'); + } else { + errors.push(`Expected: Content Approval 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')); + } + } + }, + + //Data range label + { + description: 'Data range label text, size, and color', + action: async () => { + const multipleChecks = 'Data range label'; + + const element = await driver.findElement(By.css('#get_report')); + const elementStart = await driver.findElement(By.css('.form-group:nth-child(1) > .form-label')); + + //Get text, font, size, and color + const elementText = await driver.executeScript( + `return Array.from(arguments[0].childNodes) + .filter(node => node.nodeType === Node.TEXT_NODE) + .map(node => node.textContent) + .join('') + .trim();`, + element + ); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + + const elementStartText = await elementStart.getText(); + const elementStartFont = await elementStart.getCssValue('font-family'); + const elementStartSize = await elementStart.getCssValue('font-size'); + const elementStartColor = await elementStart.getCssValue('color'); + + //Track all errors + const errors = []; + + //text + if (elementText === 'Data range:') { + console.log('Passed: Data range: label text matched as expected'); + } else { + errors.push(`Expected: "Data range:"; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Data range: label font-family matched as expected'); + } else { + errors.push(`Expected: Data range: label font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '13px') { + console.log('Passed: Data range: label text font-size matched as expected'); + } else { + errors.push(`Expected: Data range: label text font-size "13px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Data range: label text color matched as expected'); + } else { + errors.push(`Expected: Data range: label text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`); + } + + //Start text + if (elementStartText === 'Start') { + console.log('Passed: Start label text matched as expected'); + } else { + errors.push(`Expected: "Start"; Actual: "${elementStartText}"`); + } + + //Start font + if (elementStartFont === 'Poppins, sans-serif') { + console.log('Passed: Start label font-family matched as expected'); + } else { + errors.push(`Expected: Start label font-family "Poppins, sans-serif"; Actual: ${elementStartFont}`); + } + + //Start size + if (elementStartSize === '13px') { + console.log('Passed: Start label text font-size matched as expected'); + } else { + errors.push(`Expected: Start label text font-size "13px"; Actual: "${elementStartSize}"`); + } + + //Start color + if (elementStartColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Start label text color matched as expected'); + } else { + errors.push(`Expected: Start label text color: "rgba(40, 39, 90, 1)"; Actual: "${elementStartColor}"`); + } + + //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')); + } + } + }, + + //Data range: Start date textbox value + { + description: 'Data range: Start date textbox value text, size, and color', + action: async () => { + const multipleChecks = 'Data range: Start date textbox value'; + + const element = await driver.findElement(By.css('#startdate')); + + //Get text, font, size, and color + const elementText = await element.getAttribute('value'); + 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 === startDate) { + console.log('Passed: Data range: Start date textbox value text matched as expected'); + } else { + errors.push(`Expected: Data range: Start date to be: "${startDate}"; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Data range: Start date textbox value font-family matched as expected'); + } else { + errors.push(`Expected: Data range: Start date textbox value font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '16px') { + console.log('Passed: Data range: Start date textbox text font-size matched as expected'); + } else { + errors.push(`Expected: Data range: Start date textbox text font-size "16px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(73, 80, 87, 1)') { + console.log('Passed: Data range: Start date textbox text color matched as expected'); + } else { + errors.push(`Expected: Data range: Start date textbox text color: "rgba(73, 80, 87, 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')); + } + } + }, + + //End label + { + description: 'End label text, size, and color', + action: async () => { + const multipleChecks = 'End label'; + + const element = await driver.findElement(By.css('.form-group:nth-child(2) > .form-label')); + + //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 === 'End') { + console.log('Passed: End label text matched as expected'); + } else { + errors.push(`Expected: "End"; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: End label font-family matched as expected'); + } else { + errors.push(`Expected: End label font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '13px') { + console.log('Passed: End label text font-size matched as expected'); + } else { + errors.push(`Expected: End label text font-size "13px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: End label text color matched as expected'); + } else { + errors.push(`Expected: End label 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')); + } + } + }, + + //Data range: End date textbox value + { + description: 'Data range: End date textbox value text, size, and color', + action: async () => { + const multipleChecks = 'Data range: End date textbox value'; + + const element = await driver.findElement(By.css('#enddate')); + + //Get text, font, size, and color + const elementText = await element.getAttribute('value'); + 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 === todaysDate) { + console.log('Passed: Data range: End date textbox value text matched as expected'); + } else { + errors.push(`Expected: Data range: End date to be: "${todaysDate}"; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Data range: End date textbox value font-family matched as expected'); + } else { + errors.push(`Expected: Data range: End date textbox value font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '16px') { + console.log('Passed: Data range: End date textbox text font-size matched as expected'); + } else { + errors.push(`Expected: Data range: End date textbox text font-size "16px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(73, 80, 87, 1)') { + console.log('Passed: Data range: End date textbox text color matched as expected'); + } else { + errors.push(`Expected: Data range: End date textbox text color: "rgba(73, 80, 87, 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')); + } + } + }, + + //Submit button + { + description: 'Submit button', + action: async () => { + const multipleChecks = 'Submit button'; + + const element = await driver.findElement(By.css('#submit')); + + //Get text, text font, text size, text color, and button color + const elementText = await element.getAttribute('value'); + const elementTextFont = await element.getCssValue('font-family'); + const elementTextSize = await element.getCssValue('font-size'); + const elementTextColor = await element.getCssValue('color'); + const elementButtonColor = await element.getCssValue('background-color'); + + //Track all errors + const errors = []; + + //text + if (elementText === 'Submit') { + console.log('Passed: Submit button text matched as expected'); + } else { + errors.push(`Expected: "Submit"; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Submit button text font matched as expected'); + } else { + errors.push(`Expected: Submit button text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '14px') { + console.log('Passed: Submit button text font-size matched as expected'); + } else { + errors.push(`Expected: Submit button text font-size "14px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(255, 255, 255, 1)') { + console.log('Passed: Submit button text color matched as expected'); + } else { + errors.push(`Expected: Submit button text color: "rgba(255, 255, 255, 1)"; Actual: "${elementTextColor}"`); + } + + //button color + if (elementButtonColor === 'rgba(48, 200, 172, 1)') { + console.log('Passed: Submit button background color matched as expected'); + } else { + errors.push(`Expected: Submit button background color: "rgba(48, 200, 172, 1)"; Actual: "${elementButtonColor}"`); + } + + //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')); + } + } + }, + + //Pending Alignments tab + { + description: 'Pending Alignments tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Pending Alignments tab title'; + + const element = await driver.findElement(By.linkText('Pending Alignments')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Pending Alignments') { + console.log('Passed: Pending Alignments tab title text matched as expected'); + } else { + errors.push(`Expected: "Pending Alignments"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Pending Alignments tab title font-family matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Pending Alignments tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Pending Alignments tab title text color matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(255, 255, 255, 1)') { + console.log('Passed: Pending Alignments tab title background color matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title background color: "rgba(255, 255, 255, 1"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Alignments Pending Approval Ordered By Title') { + console.log('Passed: Pending Alignments tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab tool-tip "View Alignments Pending Approval Ordered By Title"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Content Submissions tab + { + description: 'Content Submissions tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Content Submissions tab title'; + + const element = await driver.findElement(By.linkText('Content Submissions')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Content Submissions') { + console.log('Passed: Content Submissions tab title text matched as expected'); + } else { + errors.push(`Expected: "Content Submissions"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Content Submissions tab title font-family matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Content Submissions tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Content Submissions tab title text color matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Content Submissions tab title background color matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Content Submissions Ordered By Title') { + console.log('Passed: Content Submissions tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab tool-tip "View Content Submissions Ordered By Title"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Approval History tab + { + description: 'Approval History tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Approval History tab title'; + + const element = await driver.findElement(By.linkText('Approval History')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Approval History') { + console.log('Passed: Approval History tab title text matched as expected'); + } else { + errors.push(`Expected: "Approval History"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Approval History tab title font-family matched as expected'); + } else { + errors.push(`Expected: Approval History tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Approval History tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Approval History tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Approval History tab title text color matched as expected'); + } else { + errors.push(`Expected: Approval History tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Approval History tab title background color matched as expected'); + } else { + errors.push(`Expected: Approval History tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Previous Approvals Ordered By Date') { + console.log('Passed: Approval History tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Approval History tab tool-tip "View Previous Approvals Ordered By Date"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Rejection History tab + { + description: 'Rejection History tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Rejection History tab title'; + + const element = await driver.findElement(By.linkText('Rejection History')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Rejection History') { + console.log('Passed: Rejection History tab title text matched as expected'); + } else { + errors.push(`Expected: "Rejection History"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Rejection History tab title font-family matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Rejection History tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Rejection History tab title text color matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Rejection History tab title background color matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Previous Rejections Ordered By Date') { + console.log('Passed: Rejection History tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Rejection History tab tool-tip "View Previous Rejections Ordered By Date"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Pending Alignments default text + { + description: 'Pending Alignments default text, size, and color', + action: async () => { + const multipleChecks = 'Pending Alignments default text'; + + const element = await driver.findElement(By.css('#tabs-2 b')); + + //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 === `No aligned content pending approval at this time for this user's group for the date(s) chosen.`) { + console.log('Passed: Pending Alignments default text matched as expected'); + } else { + errors.push(`Expected: "No aligned content pending approval at this time for this user's group for the date(s) chosen."; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Pending Alignments default text font-family matched as expected'); + } else { + errors.push(`Expected: Pending Alignments default text font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '13px') { + console.log('Passed: Pending Alignments default text font-size matched as expected'); + } else { + errors.push(`Expected: Pending Alignments default text font-size "13px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Pending Alignments default text color matched as expected'); + } else { + errors.push(`Expected: Pending Alignments default 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 Approval History tab', + action: async () => { + await driver.findElement(By.linkText('Approval History')).click(); + console.log('----->| NEXT ACTION: Clicked Approval History tab'); + + //Wait for page readyState + await driver.wait(async () => { + const readyState = await driver.executeScript('return document.readyState'); + return readyState === 'complete'; + }, 30000, 'Approval History page did not fully load within 30 seconds'); + + //Wait until the element exists in the DOM + const tabDefaultText = await driver.wait( + until.elementLocated(By.css('#tabs-3 b')), + 30000 + ); + + //Wait until it becomes visible + await driver.wait( + until.elementIsVisible(tabDefaultText), + 30000 + ); + } + }, + + //Pending Alignments tab + { + description: 'Pending Alignments tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Pending Alignments tab title'; + + const element = await driver.findElement(By.linkText('Pending Alignments')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Pending Alignments') { + console.log('Passed: Pending Alignments tab title text matched as expected'); + } else { + errors.push(`Expected: "Pending Alignments"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Pending Alignments tab title font-family matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Pending Alignments tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Pending Alignments tab title text color matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Pending Alignments tab title background color matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Alignments Pending Approval Ordered By Title') { + console.log('Passed: Pending Alignments tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab tool-tip "View Alignments Pending Approval Ordered By Title"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Content Submissions tab + { + description: 'Content Submissions tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Content Submissions tab title'; + + const element = await driver.findElement(By.linkText('Content Submissions')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Content Submissions') { + console.log('Passed: Content Submissions tab title text matched as expected'); + } else { + errors.push(`Expected: "Content Submissions"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Content Submissions tab title font-family matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Content Submissions tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Content Submissions tab title text color matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Content Submissions tab title background color matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Content Submissions Ordered By Title') { + console.log('Passed: Content Submissions tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab tool-tip "View Content Submissions Ordered By Title"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Approval History tab + { + description: 'Approval History tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Approval History tab title'; + + const element = await driver.findElement(By.linkText('Approval History')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Approval History') { + console.log('Passed: Approval History tab title text matched as expected'); + } else { + errors.push(`Expected: "Approval History"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Approval History tab title font-family matched as expected'); + } else { + errors.push(`Expected: Approval History tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Approval History tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Approval History tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Approval History tab title text color matched as expected'); + } else { + errors.push(`Expected: Approval History tab title text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(255, 255, 255, 1)') { + console.log('Passed: Approval History tab title background color matched as expected'); + } else { + errors.push(`Expected: Approval History tab title background color: "rgba(255, 255, 255, 1)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Previous Approvals Ordered By Date') { + console.log('Passed: Approval History tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Approval History tab tool-tip "View Previous Approvals Ordered By Date"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Rejection History tab + { + description: 'Rejection History tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Rejection History tab title'; + + const element = await driver.findElement(By.linkText('Rejection History')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Rejection History') { + console.log('Passed: Rejection History tab title text matched as expected'); + } else { + errors.push(`Expected: "Rejection History"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Rejection History tab title font-family matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Rejection History tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Rejection History tab title text color matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Rejection History tab title background color matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Previous Rejections Ordered By Date') { + console.log('Passed: Rejection History tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Rejection History tab tool-tip "View Previous Rejections Ordered By Date"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Approval History default text + { + description: 'Approval History default text, size, and color', + action: async () => { + const multipleChecks = 'Approval History default text'; + + const element = await driver.findElement(By.css('#tabs-3 b')); + + //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 === `No approval history for this user for the date(s) chosen.`) { + console.log('Passed: Approval History default text matched as expected'); + } else { + errors.push(`Expected: "No approval history for this user for the date(s) chosen."; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Approval History default text font-family matched as expected'); + } else { + errors.push(`Expected: Approval History default text font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '13px') { + console.log('Passed: Approval History default text font-size matched as expected'); + } else { + errors.push(`Expected: Approval History default text font-size "13px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Approval History default text color matched as expected'); + } else { + errors.push(`Expected: Approval History default 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')); + } + } + }, + + //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.getDomAttribute('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', 'approveApprovalHistoryPage'); + + 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', 'approveApprovalHistoryPageResults.xlsx'); + +const clearOldResults = () => { + //Remove old screenshots + const screenshotDir = path.join('screenshots', 'approveApprovalHistoryPage'); + 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: Approve - Approval History Page(approveApprovalHistoryPage); All test steps completed successfully'); + testStatus = 'Passed'; + } else { + console.log('------------->| THE END |<-------------'); + console.log('FAILED: Approve - Approval History Page(approveApprovalHistoryPage); 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 approveApprovalHistoryPage; diff --git a/tests/Approve/approveContentSubmissionsPage.js b/tests/Approve/approveContentSubmissionsPage.js new file mode 100644 index 0000000..07afb0c --- /dev/null +++ b/tests/Approve/approveContentSubmissionsPage.js @@ -0,0 +1,1541 @@ +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 approveContentSubmissionsPage = (req, res) => { + res.send('

ExACT Automated Test Script: Approve - Content Submissions Page(approveContentSubmissionsPage): 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 - DATES (MM/DD/YYYY): End date defaults to today, Start date defaults to 7 days ago +const formatDate = (date) => `${String(date.getMonth() + 1).padStart(2, '0')}/${String(date.getDate()).padStart(2, '0')}/${date.getFullYear()}`; +const now = new Date(); +const todaysDate = formatDate(now); +const sevenDaysAgo = new Date(now); +sevenDaysAgo.setDate(now.getDate() - 7); +const startDate = formatDate(sevenDaysAgo); + +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('------------->| APPROVE - CONTENT SUBMISSIONS 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 Approve navigation link', + action: async () => { + await driver.findElement(By.linkText('Approve')).click(); + console.log('----->| NEXT ACTION: Clicked Approve navigation link'); + + //Wait for page readyState + await driver.wait(async () => { + const readyState = await driver.executeScript('return document.readyState'); + return readyState === 'complete'; + }, 30000, 'Pending Alignments page did not fully load within 30 seconds'); + + //Wait until the element exists in the DOM + const tabDefaultText = await driver.wait( + until.elementLocated(By.css('#tabs-2 b')), + 30000 + ); + + //Wait until it becomes visible + await driver.wait( + until.elementIsVisible(tabDefaultText), + 30000 + ); + } + }, + + //Content Approval title + { + description: 'Content Approval title text, size, and color', + action: async () => { + const multipleChecks = 'Content Approval 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 === 'Content Approval') { + console.log('Passed: Content Approval title text matched as expected'); + } else { + errors.push(`Expected: "Content Approval"; Actual: "${elementText}"`); + } + + //font + if (elementFont === `"DM Serif Display", serif`) { + console.log('Passed: Content Approval title font-family matched as expected'); + } else { + errors.push(`Expected: Content Approval title font-family "DM Serif Display, serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '32px') { + console.log('Passed: Content Approval title text font-size matched as expected'); + } else { + errors.push(`Expected: Content Approval title text font-size "32px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Content Approval title text color matched as expected'); + } else { + errors.push(`Expected: Content Approval 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')); + } + } + }, + + //Data range label + { + description: 'Data range label text, size, and color', + action: async () => { + const multipleChecks = 'Data range label'; + + const element = await driver.findElement(By.css('#get_report')); + const elementStart = await driver.findElement(By.css('.form-group:nth-child(1) > .form-label')); + + //Get text, font, size, and color + const elementText = await driver.executeScript( + `return Array.from(arguments[0].childNodes) + .filter(node => node.nodeType === Node.TEXT_NODE) + .map(node => node.textContent) + .join('') + .trim();`, + element + ); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + + const elementStartText = await elementStart.getText(); + const elementStartFont = await elementStart.getCssValue('font-family'); + const elementStartSize = await elementStart.getCssValue('font-size'); + const elementStartColor = await elementStart.getCssValue('color'); + + //Track all errors + const errors = []; + + //text + if (elementText === 'Data range:') { + console.log('Passed: Data range: label text matched as expected'); + } else { + errors.push(`Expected: "Data range:"; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Data range: label font-family matched as expected'); + } else { + errors.push(`Expected: Data range: label font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '13px') { + console.log('Passed: Data range: label text font-size matched as expected'); + } else { + errors.push(`Expected: Data range: label text font-size "13px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Data range: label text color matched as expected'); + } else { + errors.push(`Expected: Data range: label text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`); + } + + //Start text + if (elementStartText === 'Start') { + console.log('Passed: Start label text matched as expected'); + } else { + errors.push(`Expected: "Start"; Actual: "${elementStartText}"`); + } + + //Start font + if (elementStartFont === 'Poppins, sans-serif') { + console.log('Passed: Start label font-family matched as expected'); + } else { + errors.push(`Expected: Start label font-family "Poppins, sans-serif"; Actual: ${elementStartFont}`); + } + + //Start size + if (elementStartSize === '13px') { + console.log('Passed: Start label text font-size matched as expected'); + } else { + errors.push(`Expected: Start label text font-size "13px"; Actual: "${elementStartSize}"`); + } + + //Start color + if (elementStartColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Start label text color matched as expected'); + } else { + errors.push(`Expected: Start label text color: "rgba(40, 39, 90, 1)"; Actual: "${elementStartColor}"`); + } + + //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')); + } + } + }, + + //Data range: Start date textbox value + { + description: 'Data range: Start date textbox value text, size, and color', + action: async () => { + const multipleChecks = 'Data range: Start date textbox value'; + + const element = await driver.findElement(By.css('#startdate')); + + //Get text, font, size, and color + const elementText = await element.getAttribute('value'); + 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 === startDate) { + console.log('Passed: Data range: Start date textbox value text matched as expected'); + } else { + errors.push(`Expected: Data range: Start date to be: "${startDate}"; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Data range: Start date textbox value font-family matched as expected'); + } else { + errors.push(`Expected: Data range: Start date textbox value font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '16px') { + console.log('Passed: Data range: Start date textbox text font-size matched as expected'); + } else { + errors.push(`Expected: Data range: Start date textbox text font-size "16px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(73, 80, 87, 1)') { + console.log('Passed: Data range: Start date textbox text color matched as expected'); + } else { + errors.push(`Expected: Data range: Start date textbox text color: "rgba(73, 80, 87, 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')); + } + } + }, + + //End label + { + description: 'End label text, size, and color', + action: async () => { + const multipleChecks = 'End label'; + + const element = await driver.findElement(By.css('.form-group:nth-child(2) > .form-label')); + + //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 === 'End') { + console.log('Passed: End label text matched as expected'); + } else { + errors.push(`Expected: "End"; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: End label font-family matched as expected'); + } else { + errors.push(`Expected: End label font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '13px') { + console.log('Passed: End label text font-size matched as expected'); + } else { + errors.push(`Expected: End label text font-size "13px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: End label text color matched as expected'); + } else { + errors.push(`Expected: End label 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')); + } + } + }, + + //Data range: End date textbox value + { + description: 'Data range: End date textbox value text, size, and color', + action: async () => { + const multipleChecks = 'Data range: End date textbox value'; + + const element = await driver.findElement(By.css('#enddate')); + + //Get text, font, size, and color + const elementText = await element.getAttribute('value'); + 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 === todaysDate) { + console.log('Passed: Data range: End date textbox value text matched as expected'); + } else { + errors.push(`Expected: Data range: End date to be: "${todaysDate}"; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Data range: End date textbox value font-family matched as expected'); + } else { + errors.push(`Expected: Data range: End date textbox value font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '16px') { + console.log('Passed: Data range: End date textbox text font-size matched as expected'); + } else { + errors.push(`Expected: Data range: End date textbox text font-size "16px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(73, 80, 87, 1)') { + console.log('Passed: Data range: End date textbox text color matched as expected'); + } else { + errors.push(`Expected: Data range: End date textbox text color: "rgba(73, 80, 87, 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')); + } + } + }, + + //Submit button + { + description: 'Submit button', + action: async () => { + const multipleChecks = 'Submit button'; + + const element = await driver.findElement(By.css('#submit')); + + //Get text, text font, text size, text color, and button color + const elementText = await element.getAttribute('value'); + const elementTextFont = await element.getCssValue('font-family'); + const elementTextSize = await element.getCssValue('font-size'); + const elementTextColor = await element.getCssValue('color'); + const elementButtonColor = await element.getCssValue('background-color'); + + //Track all errors + const errors = []; + + //text + if (elementText === 'Submit') { + console.log('Passed: Submit button text matched as expected'); + } else { + errors.push(`Expected: "Submit"; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Submit button text font matched as expected'); + } else { + errors.push(`Expected: Submit button text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '14px') { + console.log('Passed: Submit button text font-size matched as expected'); + } else { + errors.push(`Expected: Submit button text font-size "14px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(255, 255, 255, 1)') { + console.log('Passed: Submit button text color matched as expected'); + } else { + errors.push(`Expected: Submit button text color: "rgba(255, 255, 255, 1)"; Actual: "${elementTextColor}"`); + } + + //button color + if (elementButtonColor === 'rgba(48, 200, 172, 1)') { + console.log('Passed: Submit button background color matched as expected'); + } else { + errors.push(`Expected: Submit button background color: "rgba(48, 200, 172, 1)"; Actual: "${elementButtonColor}"`); + } + + //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')); + } + } + }, + + //Pending Alignments tab + { + description: 'Pending Alignments tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Pending Alignments tab title'; + + const element = await driver.findElement(By.linkText('Pending Alignments')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Pending Alignments') { + console.log('Passed: Pending Alignments tab title text matched as expected'); + } else { + errors.push(`Expected: "Pending Alignments"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Pending Alignments tab title font-family matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Pending Alignments tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Pending Alignments tab title text color matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(255, 255, 255, 1)') { + console.log('Passed: Pending Alignments tab title background color matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title background color: "rgba(255, 255, 255, 1"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Alignments Pending Approval Ordered By Title') { + console.log('Passed: Pending Alignments tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab tool-tip "View Alignments Pending Approval Ordered By Title"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Content Submissions tab + { + description: 'Content Submissions tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Content Submissions tab title'; + + const element = await driver.findElement(By.linkText('Content Submissions')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Content Submissions') { + console.log('Passed: Content Submissions tab title text matched as expected'); + } else { + errors.push(`Expected: "Content Submissions"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Content Submissions tab title font-family matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Content Submissions tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Content Submissions tab title text color matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Content Submissions tab title background color matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Content Submissions Ordered By Title') { + console.log('Passed: Content Submissions tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab tool-tip "View Content Submissions Ordered By Title"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Approval History tab + { + description: 'Approval History tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Approval History tab title'; + + const element = await driver.findElement(By.linkText('Approval History')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Approval History') { + console.log('Passed: Approval History tab title text matched as expected'); + } else { + errors.push(`Expected: "Approval History"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Approval History tab title font-family matched as expected'); + } else { + errors.push(`Expected: Approval History tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Approval History tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Approval History tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Approval History tab title text color matched as expected'); + } else { + errors.push(`Expected: Approval History tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Approval History tab title background color matched as expected'); + } else { + errors.push(`Expected: Approval History tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Previous Approvals Ordered By Date') { + console.log('Passed: Approval History tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Approval History tab tool-tip "View Previous Approvals Ordered By Date"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Rejection History tab + { + description: 'Rejection History tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Rejection History tab title'; + + const element = await driver.findElement(By.linkText('Rejection History')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Rejection History') { + console.log('Passed: Rejection History tab title text matched as expected'); + } else { + errors.push(`Expected: "Rejection History"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Rejection History tab title font-family matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Rejection History tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Rejection History tab title text color matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Rejection History tab title background color matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Previous Rejections Ordered By Date') { + console.log('Passed: Rejection History tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Rejection History tab tool-tip "View Previous Rejections Ordered By Date"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Pending Alignments default text + { + description: 'Pending Alignments default text, size, and color', + action: async () => { + const multipleChecks = 'Pending Alignments default text'; + + const element = await driver.findElement(By.css('#tabs-2 b')); + + //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 === `No aligned content pending approval at this time for this user's group for the date(s) chosen.`) { + console.log('Passed: Pending Alignments default text matched as expected'); + } else { + errors.push(`Expected: "No aligned content pending approval at this time for this user's group for the date(s) chosen."; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Pending Alignments default text font-family matched as expected'); + } else { + errors.push(`Expected: Pending Alignments default text font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '13px') { + console.log('Passed: Pending Alignments default text font-size matched as expected'); + } else { + errors.push(`Expected: Pending Alignments default text font-size "13px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Pending Alignments default text color matched as expected'); + } else { + errors.push(`Expected: Pending Alignments default 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 Content Submissions tab', + action: async () => { + await driver.findElement(By.linkText('Content Submissions')).click(); + console.log('----->| NEXT ACTION: Clicked Content Submissions tab'); + + //Wait for page readyState + await driver.wait(async () => { + const readyState = await driver.executeScript('return document.readyState'); + return readyState === 'complete'; + }, 30000, 'Content Submissions page did not fully load within 30 seconds'); + + //Wait until the element exists in the DOM + const tabDefaultText = await driver.wait( + until.elementLocated(By.css('#tabs-1 b')), + 30000 + ); + + //Wait until it becomes visible + await driver.wait( + until.elementIsVisible(tabDefaultText), + 30000 + ); + } + }, + + //Pending Alignments tab + { + description: 'Pending Alignments tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Pending Alignments tab title'; + + const element = await driver.findElement(By.linkText('Pending Alignments')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Pending Alignments') { + console.log('Passed: Pending Alignments tab title text matched as expected'); + } else { + errors.push(`Expected: "Pending Alignments"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Pending Alignments tab title font-family matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Pending Alignments tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Pending Alignments tab title text color matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Pending Alignments tab title background color matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Alignments Pending Approval Ordered By Title') { + console.log('Passed: Pending Alignments tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab tool-tip "View Alignments Pending Approval Ordered By Title"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Content Submissions tab + { + description: 'Content Submissions tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Content Submissions tab title'; + + const element = await driver.findElement(By.linkText('Content Submissions')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Content Submissions') { + console.log('Passed: Content Submissions tab title text matched as expected'); + } else { + errors.push(`Expected: "Content Submissions"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Content Submissions tab title font-family matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Content Submissions tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Content Submissions tab title text color matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(255, 255, 255, 1)') { + console.log('Passed: Content Submissions tab title background color matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title background color: "rgba(255, 255, 255, 1)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Content Submissions Ordered By Title') { + console.log('Passed: Content Submissions tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab tool-tip "View Content Submissions Ordered By Title"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Approval History tab + { + description: 'Approval History tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Approval History tab title'; + + const element = await driver.findElement(By.linkText('Approval History')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Approval History') { + console.log('Passed: Approval History tab title text matched as expected'); + } else { + errors.push(`Expected: "Approval History"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Approval History tab title font-family matched as expected'); + } else { + errors.push(`Expected: Approval History tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Approval History tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Approval History tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Approval History tab title text color matched as expected'); + } else { + errors.push(`Expected: Approval History tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Approval History tab title background color matched as expected'); + } else { + errors.push(`Expected: Approval History tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Previous Approvals Ordered By Date') { + console.log('Passed: Approval History tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Approval History tab tool-tip "View Previous Approvals Ordered By Date"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Rejection History tab + { + description: 'Rejection History tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Rejection History tab title'; + + const element = await driver.findElement(By.linkText('Rejection History')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Rejection History') { + console.log('Passed: Rejection History tab title text matched as expected'); + } else { + errors.push(`Expected: "Rejection History"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Rejection History tab title font-family matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Rejection History tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Rejection History tab title text color matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Rejection History tab title background color matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Previous Rejections Ordered By Date') { + console.log('Passed: Rejection History tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Rejection History tab tool-tip "View Previous Rejections Ordered By Date"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Content Submissions default text + { + description: 'Content Submissions default text, size, and color', + action: async () => { + const multipleChecks = 'Content Submissions default text'; + + const element = await driver.findElement(By.css('#tabs-1 b')); + + //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 === `No content submissions waiting for approval at this time for this user's group for the date(s) chosen.`) { + console.log('Passed: Content Submissions default text matched as expected'); + } else { + errors.push(`Expected: "No content submissions waiting for approval at this time for this user's group for the date(s) chosen."; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Content Submissions default text font-family matched as expected'); + } else { + errors.push(`Expected: Content Submissions default text font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '13px') { + console.log('Passed: Content Submissions default text font-size matched as expected'); + } else { + errors.push(`Expected: Content Submissions default text font-size "13px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Content Submissions default text color matched as expected'); + } else { + errors.push(`Expected: Content Submissions default 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')); + } + } + }, + + //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.getDomAttribute('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', 'approveContentSubmissionsPage'); + + 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', 'approveContentSubmissionsPageResults.xlsx'); + +const clearOldResults = () => { + //Remove old screenshots + const screenshotDir = path.join('screenshots', 'approveContentSubmissionsPage'); + 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: Approve - Content Submissions Page(approveContentSubmissionsPage); All test steps completed successfully'); + testStatus = 'Passed'; + } else { + console.log('------------->| THE END |<-------------'); + console.log('FAILED: Approve - Content Submissions Page(approveContentSubmissionsPage); 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 approveContentSubmissionsPage; diff --git a/tests/Approve/approvePage.js b/tests/Approve/approvePendingAlignmentsPage.js similarity index 97% rename from tests/Approve/approvePage.js rename to tests/Approve/approvePendingAlignmentsPage.js index 298e3b0..c61007b 100644 --- a/tests/Approve/approvePage.js +++ b/tests/Approve/approvePendingAlignmentsPage.js @@ -4,8 +4,8 @@ import fs, { link } from 'fs'; import XLSX from 'xlsx'; import path from 'path'; -const approvePage = (req, res) => { - res.send('

ExACT Automated Test Script: Approve Page(approvePage): Initiated

'); +const approvePendingAlignmentsPage = (req, res) => { + res.send('

ExACT Automated Test Script: Approve - Pending Alignments Page(approvePendingAlignmentsPage): Initiated

'); (async function example() { let driver = await new Builder() .forBrowser('chrome') @@ -40,7 +40,7 @@ const steps = [ action: async () => { const multipleChecks = 'Log In'; - console.log('------------->| APPROVE PAGE |<-------------'); + console.log('------------->| APPROVE - CONTENT SUBMISSIONS PAGE |<-------------'); const errors = []; await driver.findElement(By.css('.form-control:nth-child(2)')).sendKeys('exact_juan'); @@ -180,17 +180,17 @@ const steps = [ await driver.wait(async () => { const readyState = await driver.executeScript('return document.readyState'); return readyState === 'complete'; - }, 30000, 'Approve page did not fully load within 30 seconds'); + }, 30000, 'Pending Alignments page did not fully load within 30 seconds'); //Wait until the element exists in the DOM - const approvePage = await driver.wait( - until.elementLocated(By.css('h2')), + const tabDefaultText = await driver.wait( + until.elementLocated(By.css('#tabs-2 b')), 30000 ); //Wait until it becomes visible await driver.wait( - until.elementIsVisible(approvePage), + until.elementIsVisible(tabDefaultText), 30000 ); } @@ -1046,7 +1046,7 @@ const logStep = (worksheet, stepDescription, status, stepIndex, timestamp, scree const takeScreenshot = async (driver, stepIndex, stepDescription) => { const screenshot = await driver.takeScreenshot(); - const dir = path.join('screenshots', 'approvePage'); + const dir = path.join('screenshots', 'approvePendingAlignmentsPage'); const screenshotFileName = `step_${stepIndex}_${stepDescription.replace(/\s+/g, '_')}.png`; const screenshotPath = path.join(dir, screenshotFileName); @@ -1054,11 +1054,11 @@ const takeScreenshot = async (driver, stepIndex, stepDescription) => { return screenshotPath; }; -const resultsFile = path.join('results', 'approvePageResults.xlsx'); +const resultsFile = path.join('results', 'approvePendingAlignmentsPageResults.xlsx'); const clearOldResults = () => { //Remove old screenshots - const screenshotDir = path.join('screenshots', 'approvePage'); + const screenshotDir = path.join('screenshots', 'approvePendingAlignmentsPage'); if (fs.existsSync(screenshotDir)) { fs.rmSync(screenshotDir, { recursive: true, force: true }); } @@ -1133,11 +1133,11 @@ try { if (allStepsPassed) { console.log('------------->| THE END |<-------------'); - console.log('PASSED: Approve Page(approvePage); All test steps completed successfully'); + console.log('PASSED: Approve - Pending Alignments Page(approvePendingAlignmentsPage); All test steps completed successfully'); testStatus = 'Passed'; } else { console.log('------------->| THE END |<-------------'); - console.log('FAILED: Approve Page(approvePage); One or more test steps failed'); + console.log('FAILED: Approve - Pending Alignments Page(approvePendingAlignmentsPage); One or more test steps failed'); console.log('FAILED STEPS:'); failedSteps.forEach(step => console.error(` ✗ ${step}`)); testStatus = 'Failed'; @@ -1156,4 +1156,4 @@ try { })(); } -export default approvePage; +export default approvePendingAlignmentsPage; diff --git a/tests/Approve/approveRejectionHistoryPage.js b/tests/Approve/approveRejectionHistoryPage.js new file mode 100644 index 0000000..aba9779 --- /dev/null +++ b/tests/Approve/approveRejectionHistoryPage.js @@ -0,0 +1,1541 @@ +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 approveRejectionHistoryPage = (req, res) => { + res.send('

ExACT Automated Test Script: Approve - Rejection History Page(approveRejectionHistoryPage): 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 - DATES (MM/DD/YYYY): End date defaults to today, Start date defaults to 7 days ago +const formatDate = (date) => `${String(date.getMonth() + 1).padStart(2, '0')}/${String(date.getDate()).padStart(2, '0')}/${date.getFullYear()}`; +const now = new Date(); +const todaysDate = formatDate(now); +const sevenDaysAgo = new Date(now); +sevenDaysAgo.setDate(now.getDate() - 7); +const startDate = formatDate(sevenDaysAgo); + +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('------------->| APPROVE - REJECTION HISTORY 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 Approve navigation link', + action: async () => { + await driver.findElement(By.linkText('Approve')).click(); + console.log('----->| NEXT ACTION: Clicked Approve navigation link'); + + //Wait for page readyState + await driver.wait(async () => { + const readyState = await driver.executeScript('return document.readyState'); + return readyState === 'complete'; + }, 30000, 'Pending Alignments page did not fully load within 30 seconds'); + + //Wait until the element exists in the DOM + const tabDefaultText = await driver.wait( + until.elementLocated(By.css('#tabs-2 b')), + 30000 + ); + + //Wait until it becomes visible + await driver.wait( + until.elementIsVisible(tabDefaultText), + 30000 + ); + } + }, + + //Content Approval title + { + description: 'Content Approval title text, size, and color', + action: async () => { + const multipleChecks = 'Content Approval 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 === 'Content Approval') { + console.log('Passed: Content Approval title text matched as expected'); + } else { + errors.push(`Expected: "Content Approval"; Actual: "${elementText}"`); + } + + //font + if (elementFont === `"DM Serif Display", serif`) { + console.log('Passed: Content Approval title font-family matched as expected'); + } else { + errors.push(`Expected: Content Approval title font-family "DM Serif Display, serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '32px') { + console.log('Passed: Content Approval title text font-size matched as expected'); + } else { + errors.push(`Expected: Content Approval title text font-size "32px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Content Approval title text color matched as expected'); + } else { + errors.push(`Expected: Content Approval 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')); + } + } + }, + + //Data range label + { + description: 'Data range label text, size, and color', + action: async () => { + const multipleChecks = 'Data range label'; + + const element = await driver.findElement(By.css('#get_report')); + const elementStart = await driver.findElement(By.css('.form-group:nth-child(1) > .form-label')); + + //Get text, font, size, and color + const elementText = await driver.executeScript( + `return Array.from(arguments[0].childNodes) + .filter(node => node.nodeType === Node.TEXT_NODE) + .map(node => node.textContent) + .join('') + .trim();`, + element + ); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + + const elementStartText = await elementStart.getText(); + const elementStartFont = await elementStart.getCssValue('font-family'); + const elementStartSize = await elementStart.getCssValue('font-size'); + const elementStartColor = await elementStart.getCssValue('color'); + + //Track all errors + const errors = []; + + //text + if (elementText === 'Data range:') { + console.log('Passed: Data range: label text matched as expected'); + } else { + errors.push(`Expected: "Data range:"; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Data range: label font-family matched as expected'); + } else { + errors.push(`Expected: Data range: label font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '13px') { + console.log('Passed: Data range: label text font-size matched as expected'); + } else { + errors.push(`Expected: Data range: label text font-size "13px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Data range: label text color matched as expected'); + } else { + errors.push(`Expected: Data range: label text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`); + } + + //Start text + if (elementStartText === 'Start') { + console.log('Passed: Start label text matched as expected'); + } else { + errors.push(`Expected: "Start"; Actual: "${elementStartText}"`); + } + + //Start font + if (elementStartFont === 'Poppins, sans-serif') { + console.log('Passed: Start label font-family matched as expected'); + } else { + errors.push(`Expected: Start label font-family "Poppins, sans-serif"; Actual: ${elementStartFont}`); + } + + //Start size + if (elementStartSize === '13px') { + console.log('Passed: Start label text font-size matched as expected'); + } else { + errors.push(`Expected: Start label text font-size "13px"; Actual: "${elementStartSize}"`); + } + + //Start color + if (elementStartColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Start label text color matched as expected'); + } else { + errors.push(`Expected: Start label text color: "rgba(40, 39, 90, 1)"; Actual: "${elementStartColor}"`); + } + + //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')); + } + } + }, + + //Data range: Start date textbox value + { + description: 'Data range: Start date textbox value text, size, and color', + action: async () => { + const multipleChecks = 'Data range: Start date textbox value'; + + const element = await driver.findElement(By.css('#startdate')); + + //Get text, font, size, and color + const elementText = await element.getAttribute('value'); + 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 === startDate) { + console.log('Passed: Data range: Start date textbox value text matched as expected'); + } else { + errors.push(`Expected: Data range: Start date to be: "${startDate}"; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Data range: Start date textbox value font-family matched as expected'); + } else { + errors.push(`Expected: Data range: Start date textbox value font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '16px') { + console.log('Passed: Data range: Start date textbox text font-size matched as expected'); + } else { + errors.push(`Expected: Data range: Start date textbox text font-size "16px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(73, 80, 87, 1)') { + console.log('Passed: Data range: Start date textbox text color matched as expected'); + } else { + errors.push(`Expected: Data range: Start date textbox text color: "rgba(73, 80, 87, 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')); + } + } + }, + + //End label + { + description: 'End label text, size, and color', + action: async () => { + const multipleChecks = 'End label'; + + const element = await driver.findElement(By.css('.form-group:nth-child(2) > .form-label')); + + //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 === 'End') { + console.log('Passed: End label text matched as expected'); + } else { + errors.push(`Expected: "End"; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: End label font-family matched as expected'); + } else { + errors.push(`Expected: End label font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '13px') { + console.log('Passed: End label text font-size matched as expected'); + } else { + errors.push(`Expected: End label text font-size "13px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: End label text color matched as expected'); + } else { + errors.push(`Expected: End label 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')); + } + } + }, + + //Data range: End date textbox value + { + description: 'Data range: End date textbox value text, size, and color', + action: async () => { + const multipleChecks = 'Data range: End date textbox value'; + + const element = await driver.findElement(By.css('#enddate')); + + //Get text, font, size, and color + const elementText = await element.getAttribute('value'); + 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 === todaysDate) { + console.log('Passed: Data range: End date textbox value text matched as expected'); + } else { + errors.push(`Expected: Data range: End date to be: "${todaysDate}"; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Data range: End date textbox value font-family matched as expected'); + } else { + errors.push(`Expected: Data range: End date textbox value font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '16px') { + console.log('Passed: Data range: End date textbox text font-size matched as expected'); + } else { + errors.push(`Expected: Data range: End date textbox text font-size "16px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(73, 80, 87, 1)') { + console.log('Passed: Data range: End date textbox text color matched as expected'); + } else { + errors.push(`Expected: Data range: End date textbox text color: "rgba(73, 80, 87, 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')); + } + } + }, + + //Submit button + { + description: 'Submit button', + action: async () => { + const multipleChecks = 'Submit button'; + + const element = await driver.findElement(By.css('#submit')); + + //Get text, text font, text size, text color, and button color + const elementText = await element.getAttribute('value'); + const elementTextFont = await element.getCssValue('font-family'); + const elementTextSize = await element.getCssValue('font-size'); + const elementTextColor = await element.getCssValue('color'); + const elementButtonColor = await element.getCssValue('background-color'); + + //Track all errors + const errors = []; + + //text + if (elementText === 'Submit') { + console.log('Passed: Submit button text matched as expected'); + } else { + errors.push(`Expected: "Submit"; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Submit button text font matched as expected'); + } else { + errors.push(`Expected: Submit button text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '14px') { + console.log('Passed: Submit button text font-size matched as expected'); + } else { + errors.push(`Expected: Submit button text font-size "14px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(255, 255, 255, 1)') { + console.log('Passed: Submit button text color matched as expected'); + } else { + errors.push(`Expected: Submit button text color: "rgba(255, 255, 255, 1)"; Actual: "${elementTextColor}"`); + } + + //button color + if (elementButtonColor === 'rgba(48, 200, 172, 1)') { + console.log('Passed: Submit button background color matched as expected'); + } else { + errors.push(`Expected: Submit button background color: "rgba(48, 200, 172, 1)"; Actual: "${elementButtonColor}"`); + } + + //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')); + } + } + }, + + //Pending Alignments tab + { + description: 'Pending Alignments tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Pending Alignments tab title'; + + const element = await driver.findElement(By.linkText('Pending Alignments')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Pending Alignments') { + console.log('Passed: Pending Alignments tab title text matched as expected'); + } else { + errors.push(`Expected: "Pending Alignments"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Pending Alignments tab title font-family matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Pending Alignments tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Pending Alignments tab title text color matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(255, 255, 255, 1)') { + console.log('Passed: Pending Alignments tab title background color matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title background color: "rgba(255, 255, 255, 1"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Alignments Pending Approval Ordered By Title') { + console.log('Passed: Pending Alignments tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab tool-tip "View Alignments Pending Approval Ordered By Title"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Content Submissions tab + { + description: 'Content Submissions tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Content Submissions tab title'; + + const element = await driver.findElement(By.linkText('Content Submissions')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Content Submissions') { + console.log('Passed: Content Submissions tab title text matched as expected'); + } else { + errors.push(`Expected: "Content Submissions"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Content Submissions tab title font-family matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Content Submissions tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Content Submissions tab title text color matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Content Submissions tab title background color matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Content Submissions Ordered By Title') { + console.log('Passed: Content Submissions tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab tool-tip "View Content Submissions Ordered By Title"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Approval History tab + { + description: 'Approval History tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Approval History tab title'; + + const element = await driver.findElement(By.linkText('Approval History')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Approval History') { + console.log('Passed: Approval History tab title text matched as expected'); + } else { + errors.push(`Expected: "Approval History"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Approval History tab title font-family matched as expected'); + } else { + errors.push(`Expected: Approval History tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Approval History tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Approval History tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Approval History tab title text color matched as expected'); + } else { + errors.push(`Expected: Approval History tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Approval History tab title background color matched as expected'); + } else { + errors.push(`Expected: Approval History tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Previous Approvals Ordered By Date') { + console.log('Passed: Approval History tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Approval History tab tool-tip "View Previous Approvals Ordered By Date"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Rejection History tab + { + description: 'Rejection History tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Rejection History tab title'; + + const element = await driver.findElement(By.linkText('Rejection History')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Rejection History') { + console.log('Passed: Rejection History tab title text matched as expected'); + } else { + errors.push(`Expected: "Rejection History"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Rejection History tab title font-family matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Rejection History tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Rejection History tab title text color matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Rejection History tab title background color matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Previous Rejections Ordered By Date') { + console.log('Passed: Rejection History tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Rejection History tab tool-tip "View Previous Rejections Ordered By Date"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Pending Alignments default text + { + description: 'Pending Alignments default text, size, and color', + action: async () => { + const multipleChecks = 'Pending Alignments default text'; + + const element = await driver.findElement(By.css('#tabs-2 b')); + + //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 === `No aligned content pending approval at this time for this user's group for the date(s) chosen.`) { + console.log('Passed: Pending Alignments default text matched as expected'); + } else { + errors.push(`Expected: "No aligned content pending approval at this time for this user's group for the date(s) chosen."; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Pending Alignments default text font-family matched as expected'); + } else { + errors.push(`Expected: Pending Alignments default text font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '13px') { + console.log('Passed: Pending Alignments default text font-size matched as expected'); + } else { + errors.push(`Expected: Pending Alignments default text font-size "13px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Pending Alignments default text color matched as expected'); + } else { + errors.push(`Expected: Pending Alignments default 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 Rejection History tab', + action: async () => { + await driver.findElement(By.linkText('Rejection History')).click(); + console.log('----->| NEXT ACTION: Clicked Rejection History tab'); + + //Wait for page readyState + await driver.wait(async () => { + const readyState = await driver.executeScript('return document.readyState'); + return readyState === 'complete'; + }, 30000, 'Rejection History page did not fully load within 30 seconds'); + + //Wait until the element exists in the DOM + const tabDefaultText = await driver.wait( + until.elementLocated(By.css('#tabs-4 b')), + 30000 + ); + + //Wait until it becomes visible + await driver.wait( + until.elementIsVisible(tabDefaultText), + 30000 + ); + } + }, + + //Pending Alignments tab + { + description: 'Pending Alignments tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Pending Alignments tab title'; + + const element = await driver.findElement(By.linkText('Pending Alignments')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Pending Alignments') { + console.log('Passed: Pending Alignments tab title text matched as expected'); + } else { + errors.push(`Expected: "Pending Alignments"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Pending Alignments tab title font-family matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Pending Alignments tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Pending Alignments tab title text color matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Pending Alignments tab title background color matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Alignments Pending Approval Ordered By Title') { + console.log('Passed: Pending Alignments tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Pending Alignments tab tool-tip "View Alignments Pending Approval Ordered By Title"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Content Submissions tab + { + description: 'Content Submissions tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Content Submissions tab title'; + + const element = await driver.findElement(By.linkText('Content Submissions')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Content Submissions') { + console.log('Passed: Content Submissions tab title text matched as expected'); + } else { + errors.push(`Expected: "Content Submissions"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Content Submissions tab title font-family matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Content Submissions tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Content Submissions tab title text color matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Content Submissions tab title background color matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Content Submissions Ordered By Title') { + console.log('Passed: Content Submissions tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Content Submissions tab tool-tip "View Content Submissions Ordered By Title"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Approval History tab + { + description: 'Approval History tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Approval History tab title'; + + const element = await driver.findElement(By.linkText('Approval History')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Approval History') { + console.log('Passed: Approval History tab title text matched as expected'); + } else { + errors.push(`Expected: "Approval History"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Approval History tab title font-family matched as expected'); + } else { + errors.push(`Expected: Approval History tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Approval History tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Approval History tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(182, 186, 181, 1)') { + console.log('Passed: Approval History tab title text color matched as expected'); + } else { + errors.push(`Expected: Approval History tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(0, 0, 0, 0)') { + console.log('Passed: Approval History tab title background color matched as expected'); + } else { + errors.push(`Expected: Approval History tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Previous Approvals Ordered By Date') { + console.log('Passed: Approval History tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Approval History tab tool-tip "View Previous Approvals Ordered By Date"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Rejection History tab + { + description: 'Rejection History tab title text, size, color, and background color', + action: async () => { + const multipleChecks = 'Rejection History tab title'; + + const element = await driver.findElement(By.linkText('Rejection History')); + + //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'); + const elementTitle = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //element text + if (elementText === 'Rejection History') { + console.log('Passed: Rejection History tab title text matched as expected'); + } else { + errors.push(`Expected: "Rejection History"; Actual: "${elementText}"`); + } + + //element font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Rejection History tab title font-family matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //element size + if (elementSize === '15px') { + console.log('Passed: Rejection History tab title text font-size matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title text font-size "15px"; Actual: "${elementSize}"`); + } + + //element color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Rejection History tab title text color matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`); + } + + //element background color + if (elementBgColor === 'rgba(255, 255, 255, 1)') { + console.log('Passed: Rejection History tab title background color matched as expected'); + } else { + errors.push(`Expected: Rejection History tab title background color: "rgba(255, 255, 255, 1)"; Actual: "${elementBgColor}"`); + } + + //element tool-tip text + if (elementTitle === 'View Previous Rejections Ordered By Date') { + console.log('Passed: Rejection History tab tool-tip text matched as expected'); + } else { + errors.push(`Expected: Rejection History tab tool-tip "View Previous Rejections Ordered By Date"; Actual: "${elementTitle}"`); + } + + //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')); + } + } + }, + + //Rejection History default text + { + description: 'Rejection History default text, size, and color', + action: async () => { + const multipleChecks = 'Rejection History default text'; + + const element = await driver.findElement(By.css('#tabs-4 b')); + + //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 === `No rejection history for this user for the date(s) chosen.`) { + console.log('Passed: Rejection History default text matched as expected'); + } else { + errors.push(`Expected: "No rejection history for this user for the date(s) chosen."; Actual: "${elementText}"`); + } + + //font + if (elementFont === 'Poppins, sans-serif') { + console.log('Passed: Rejection History default text font-family matched as expected'); + } else { + errors.push(`Expected: Rejection History default text font-family "Poppins, sans-serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '13px') { + console.log('Passed: Rejection History default text font-size matched as expected'); + } else { + errors.push(`Expected: Rejection History default text font-size "13px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Rejection History default text color matched as expected'); + } else { + errors.push(`Expected: Rejection History default 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')); + } + } + }, + + //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.getDomAttribute('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', 'approveRejectionHistoryPage'); + + 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', 'approveRejectionHistoryPageResults.xlsx'); + +const clearOldResults = () => { + //Remove old screenshots + const screenshotDir = path.join('screenshots', 'approveRejectionHistoryPage'); + 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: Approve - Rejection History Page(approveRejectionHistoryPage); All test steps completed successfully'); + testStatus = 'Passed'; + } else { + console.log('------------->| THE END |<-------------'); + console.log('FAILED: Approve - Rejection History Page(approveRejectionHistoryPage); 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 approveRejectionHistoryPage;