diff --git a/tests/Frameworks/frameworkManagementPage.js b/tests/Frameworks/frameworkManagementPage.js new file mode 100644 index 0000000..34a94d6 --- /dev/null +++ b/tests/Frameworks/frameworkManagementPage.js @@ -0,0 +1,2676 @@ +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 frameworkManagementPage = (req, res) => { + res.send('

ExACT Automated Test Script: Framework Management Page(frameworkManagementPage); 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 +//My Content Widget +const myContentItemTotals = '5038 items'; + +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('------------->| CORRELATION DASHBOARD |<-------------'); + 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 Frameworks navigation link', + action: async () => { + await driver.findElement(By.linkText('Frameworks')).click(); + console.log('----->| NEXT ACTION: Clicked Frameworks navigation link'); + + //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 until the element exists in the DOM + const pageTitle = await driver.wait( + until.elementLocated(By.css('h2')), + 30000 + ); + + //Wait until it becomes visible + await driver.wait( + until.elementIsVisible(pageTitle), + 30000 + ); + } + }, + + //Framework Management page title + { + description: 'Framework Management page title text, size, and color', + action: async () => { + const multipleChecks = 'Framework Management page title'; + + const element = await driver.findElement(By.css('h2')); + + //Get text, font, size, and color + const elementText = await element.getText(); + const elementFont = await element.getCssValue('font-family'); + const elementSize = await element.getCssValue('font-size'); + const elementColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //text + if (elementText === 'Framework Management') { + console.log('Passed: Framework Management page title text matched as expected'); + } else { + errors.push(`Expected: "Framework Management"; Actual: "${elementText}"`); + } + + //font + if (elementFont === `"DM Serif Display", serif`) { + console.log('Passed: Framework Management page title font-family matched as expected'); + } else { + errors.push(`Expected: Framework Management page title font-family "DM Serif Display, serif"; Actual: ${elementFont}`); + } + + //size + if (elementSize === '32px') { + console.log('Passed: Framework Management page title text font-size matched as expected'); + } else { + errors.push(`Expected: Framework Management page title text font-size "32px"; Actual: "${elementSize}"`); + } + + //color + if (elementColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Framework Management page title text color matched as expected'); + } else { + errors.push(`Expected: Framework Management page title text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`); + } + + //Throw summary if any validation failed + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + + //Publishing button + { + description: 'Publishing button text, font, size, color, href, and button color', + action: async () => { + const multipleChecks = 'Publishing button'; + + const elementIcon = await driver.findElement(By.css('.btn > .fa-cloud-upload')); + const element = await driver.findElement(By.linkText('Publishing')); + const expectedHref = 'https://correlation.edgate.com/exact/publish_frameworks.php'; + + //Get button text, text font, text size, text color, and button color + const elementText = await element.getText(''); + 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 = []; + + //icon present + if (await elementIcon.isDisplayed()) { + console.log('Passed: Publishing button icon was displayed as expected'); + } else { + errors.push('Expected: Publishing button icon was not displayed'); + } + + //text + if (elementText === 'Publishing') { + console.log('Passed: Publishing button text matched as expected'); + } else { + errors.push(`Expected: "Publishing"; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Publishing button text font matched as expected'); + } else { + errors.push(`Expected: Publishing button text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '16px') { + console.log('Passed: Publishing button text font-size matched as expected'); + } else { + errors.push(`Expected: Publishing button text font-size "16px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(255, 255, 255, 1)') { + console.log('Passed: Publishing button text color matched as expected'); + } else { + errors.push(`Expected: Publishing button text color: "rgba(255, 255, 255, 1)"; Actual: "${elementTextColor}"`); + } + + //button color + if (elementButtonColor === 'rgba(48, 200, 172, 1)') { + console.log('Passed: Publishing button background color matched as expected'); + } else { + errors.push(`Expected: Publishing button background color: "rgba(48, 200, 172, 1)"; Actual: "${elementButtonColor}"`); + } + + //href + const actualHref = await element.getAttribute('href'); + if (actualHref && actualHref === expectedHref) { + console.log('Passed: Publishing button href matched as expected'); + } else { + errors.push(`Expected: Publishing button href to be "${expectedHref}"; but found "${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')); + } + } + }, + + //Import Framework button + { + description: 'Import Framework button text, font, size, color, href, and button color', + action: async () => { + const multipleChecks = 'Import Framework button'; + + const elementIcon = await driver.findElement(By.css('.fa-upload')); + const element = await driver.findElement(By.linkText('Import Framework')); + const expectedHref = 'https://correlation.edgate.com/exact/import_framework_modal.php'; + + //Get button text, text font, text size, text color, and button color + const elementText = await element.getText(''); + 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 = []; + + //icon present + if (await elementIcon.isDisplayed()) { + console.log('Passed: Import Framework button icon was displayed as expected'); + } else { + errors.push('Expected: Import Framework button icon was not displayed'); + } + + //text + if (elementText === 'Import Framework') { + console.log('Passed: Import Framework button text matched as expected'); + } else { + errors.push(`Expected: "Import Framework"; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Import Framework button text font matched as expected'); + } else { + errors.push(`Expected: Import Framework button text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '16px') { + console.log('Passed: Import Framework button text font-size matched as expected'); + } else { + errors.push(`Expected: Import Framework button text font-size "16px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(255, 255, 255, 1)') { + console.log('Passed: Import Framework button text color matched as expected'); + } else { + errors.push(`Expected: Import Framework button text color: "rgba(255, 255, 255, 1)"; Actual: "${elementTextColor}"`); + } + + //button color + if (elementButtonColor === 'rgba(48, 200, 172, 1)') { + console.log('Passed: Import Framework button background color matched as expected'); + } else { + errors.push(`Expected: Import Framework button background color: "rgba(48, 200, 172, 1)"; Actual: "${elementButtonColor}"`); + } + + //href + const actualHref = await element.getAttribute('href'); + if (actualHref && actualHref === expectedHref) { + console.log('Passed: Import Framework button href matched as expected'); + } else { + errors.push(`Expected: Import Framework button href to be "${expectedHref}"; but found "${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')); + } + } + }, + + //Create button + { + description: 'Create button text, font, size, color, href, and button color', + action: async () => { + const multipleChecks = 'Create button'; + + const elementIcon = await driver.findElement(By.css('.fa-plus-circle')); + const element = await driver.findElement(By.linkText('Create')); + const expectedHref = 'https://correlation.edgate.com/exact/org_add_modal.php'; + + //Get button text, text font, text size, text color, and button color + const elementText = await element.getText(''); + 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 = []; + + //icon present + if (await elementIcon.isDisplayed()) { + console.log('Passed: Create button icon was displayed as expected'); + } else { + errors.push('Expected: Create button icon was not displayed'); + } + + //text + if (elementText === 'Create') { + console.log('Passed: Create button text matched as expected'); + } else { + errors.push(`Expected: "Create"; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Create button text font matched as expected'); + } else { + errors.push(`Expected: Create button text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '16px') { + console.log('Passed: Create button text font-size matched as expected'); + } else { + errors.push(`Expected: Create button text font-size "16px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(255, 255, 255, 1)') { + console.log('Passed: Create button text color matched as expected'); + } else { + errors.push(`Expected: Create button text color: "rgba(255, 255, 255, 1)"; Actual: "${elementTextColor}"`); + } + + //button color + if (elementButtonColor === 'rgba(48, 200, 172, 1)') { + console.log('Passed: Create button background color matched as expected'); + } else { + errors.push(`Expected: Create button background color: "rgba(48, 200, 172, 1)"; Actual: "${elementButtonColor}"`); + } + + //href + const actualHref = await element.getAttribute('href'); + if (actualHref && actualHref === expectedHref) { + console.log('Passed: Create button href matched as expected'); + } else { + errors.push(`Expected: Create button href to be "${expectedHref}"; but found "${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')); + } + } + }, + + //SEARCH ROW + //Search textbox + { + description: 'Verify Search textbox', + action: async () => { + const multipleChecks = 'Search textbox'; + + const element = await driver.findElement(By.css('#FilterOrganization')); + const elementIcon = await driver.findElement(By.css('.fa-times')); + + //Track all errors + const errors = []; + + //textbox + if (element) { + console.log('Passed: Search textbox is present'); + } else { + errors.push('Expected: Search textbox not found'); + } + + //icon + if (elementIcon) { + console.log('Passed: Search textbox clear icon is present'); + } else { + errors.push('Expected: Search textbox clear icon not found'); + } + + //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')); + } + } + }, + + //Advanced Search button + { + description: 'Advanced Search button text, font, size, color, and button color', + action: async () => { + const multipleChecks = 'Advanced Search button'; + + const elementIcon = await driver.findElement(By.css('.btn > .fa-search')); + const element = await driver.findElement(By.css('div:nth-child(4) > .btn')); + + //Get button text, text font, text size, text color, and button color + const elementText = await element.getText(''); + 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 = []; + + //icon present + if (await elementIcon.isDisplayed()) { + console.log('Passed: Advanced Search button icon was displayed as expected'); + } else { + errors.push('Expected: Advanced Search button icon was not displayed'); + } + + //text + if (elementText === 'Advanced Search') { + console.log('Passed: Advanced Search button text matched as expected'); + } else { + errors.push(`Expected: "Advanced Search"; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Advanced Search button text font matched as expected'); + } else { + errors.push(`Expected: Advanced Search button text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '16px') { + console.log('Passed: Advanced Search button text font-size matched as expected'); + } else { + errors.push(`Expected: Advanced Search button text font-size "16px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(255, 255, 255, 1)') { + console.log('Passed: Advanced Search button text color matched as expected'); + } else { + errors.push(`Expected: Advanced Search button text color: "rgba(255, 255, 255, 1)"; Actual: "${elementTextColor}"`); + } + + //button color + if (elementButtonColor === 'rgba(48, 200, 172, 1)') { + console.log('Passed: Advanced Search button background color matched as expected'); + } else { + errors.push(`Expected: Advanced Search 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')); + } + } + }, + + //FRAMEWORK LIST + //Framework 4, 5, and 6 are hidden (Creating Org folder is collapsed) + { + description: 'Organization 1 and Frameworks 1-3 visible; Frameworks 4-6 hidden', + action: async () => { + const multipleChecks = 'Framework list before search'; + + const visibleItems = [ + { name: 'Organization 1 folder icon', locator: By.css('#folder1279361494') }, + { name: 'Organization 1 title', locator: By.linkText('Creating Org') }, + { name: 'Framework 1 file icon', locator: By.css('.org:nth-child(2) > .fa') }, + { name: 'Framework 1 title', locator: By.linkText('ECS-2933 Testing On Prod') }, + { name: 'Framework 2 file icon', locator: By.css('.org:nth-child(3) > .fa') }, + { name: 'Framework 2 title', locator: By.linkText('Widget Test') }, + { name: 'Framework 3 file icon', locator: By.css('.list-group-item:nth-child(4) > .fa') }, + { name: 'Framework 3 title', locator: By.linkText('ecs31444') }, + ]; + + const hiddenItems = [ + { name: 'Framework 4 file icon', locator: By.css('.doc:nth-child(1) > .fa') }, + { name: 'Framework 4 title', locator: By.linkText('5th Grade Import ECS-2732') }, + { name: 'Framework 5 file icon', locator: By.css('.doc:nth-child(2) > .fa') }, + { name: 'Framework 5 title', locator: By.linkText('Imported Framework Updated') }, + { name: 'Framework 6 file icon', locator: By.css('.doc:nth-child(3) > .fa') }, + { name: 'Framework 6 title', locator: By.linkText('NewTicket') }, + ]; + + //Track all errors + const errors = []; + + //Visible = in the page and displayed + for (const item of visibleItems) { + const matches = await driver.findElements(item.locator); + const isDisplayed = matches.length > 0 && await matches[0].isDisplayed(); + + if (isDisplayed) { + console.log(`Passed: ${item.name} was displayed as expected`); + } else { + errors.push(`Expected: ${item.name} was not displayed; Actual: hidden`); + } + } + + //Hidden = not in the page, or in the page but not displayed + for (const item of hiddenItems) { + const matches = await driver.findElements(item.locator); + const isDisplayed = matches.length > 0 && await matches[0].isDisplayed(); + + if (!isDisplayed) { + console.log(`Passed: ${item.name} was hidden as expected`); + } else { + errors.push(`Expected: ${item.name} was not hidden; Actual: displayed`); + } + } + + 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')); + } + } + }, + + //Organization 1 + { + description: 'Organization 1 folder icon, text, font, size, color and tooltip', + action: async () => { + const multipleChecks = 'Organization 1 - Creating Org'; + + const elementIcon = await driver.findElement(By.css('#folder1279361494')); + const expectedClass = 'fa fa-folder mr-1 frame-icon'; + const element = await driver.findElement(By.linkText('Creating Org')); + + //Get button text, text font, text size, text color, and button color + const elementIconColor = await elementIcon.getCssValue('color'); + const elementText = await element.getText(''); + const elementTextFont = await element.getCssValue('font-family'); + const elementTextSize = await element.getCssValue('font-size'); + const elementTextColor = await element.getCssValue('color'); + const elementTooltip = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //image class + const actualClass = await elementIcon.getAttribute('class'); + if (actualClass && actualClass === expectedClass) { + console.log('Passed: Organization 1 folder icon class matched expected'); + } else { + errors.push(`Expected: Organization 1 folder icon class: "${expectedClass}"; but found "${actualClass}"`); + } + + //icon color + if (elementIconColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Organization 1 folder icon color matched as expected'); + } else { + errors.push(`Expected: Organization 1 folder icon color: "rgba(40, 39, 90, 1)"; Actual: "${elementIconColor}"`); + } + + //text + if (elementText === 'Creating Org') { + console.log('Passed: Organization 1 title text matched as expected'); + } else { + errors.push(`Expected: "Creating Org "; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Organization 1 title text font matched as expected'); + } else { + errors.push(`Expected: Organization 1 title text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '18.59px') { + console.log('Passed: Organization 1 title text font-size matched as expected'); + } else { + errors.push(`Expected: Organization 1 title text font-size "18.59px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(73, 80, 87, 1)') { + console.log('Passed: Organization 1 title text color matched as expected'); + } else { + errors.push(`Expected: Organization 1 title text color: "rgba(73, 80, 87, 1)"; Actual: "${elementTextColor}"`); + } + + //tooltip + if (elementTooltip === 'Click to expand/collapse') { + console.log('Passed: Organization 1 title tooltip matched as expected'); + } else { + errors.push(`Expected: Organization 1 title tooltip: "Click to expand/collapse"; Actual: "${elementTooltip}"`); + } + + //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')); + } + } + }, + + //Organization 1 edit icon on hover + { + description: 'Organization 1 edit icon is displayed on hover', + action: async () => { + const element = await driver.findElement(By.linkText('Creating Org')); + + //Edit (pencil) icon that belongs to the Creating Org row only + const editIcon = await driver.findElement(By.css('li[data-li="1279361494"] > .opts .fa-pencil-square-o')); + + //Hover over the Organization 1 title + await driver.actions({ async: true }).move({ origin: element }).perform(); + console.log('----->| NEXT ACTION: Hover over Creating Org title to display edit icon'); + + //Give the edit icon up to 5 seconds to appear + try { + await driver.wait(until.elementIsVisible(editIcon), 5000); + console.log('Passed: Organization 1 edit icon was displayed on hover as expected'); + } catch { + throw new Error('Expected: Organization 1 edit icon to be displayed on hover; Actual: Not displayed'); + } + } + }, + + //Framework 1 + { + description: 'Framework 1 file icon, text, font, size, and color', + action: async () => { + const multipleChecks = 'Framework 1 - ECS-2933 Testing On Prod'; + + const elementIcon = await driver.findElement(By.css('.org:nth-child(2) > .fa')); + const element = await driver.findElement(By.linkText('ECS-2933 Testing On Prod')); + + //Get button text, text font, text size, text color, and button color + const elementText = await element.getText(''); + const elementTextFont = await element.getCssValue('font-family'); + const elementTextSize = await element.getCssValue('font-size'); + const elementTextColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //icon present + if (await elementIcon.isDisplayed()) { + console.log('Passed: Framework 1 file icon was displayed as expected'); + } else { + errors.push('Expected: Framework 1 file icon was not displayed'); + } + + //text + if (elementText === 'ECS-2933 Testing On Prod') { + console.log('Passed: Framework 1 title text matched as expected'); + } else { + errors.push(`Expected: "ECS-2933 Testing On Prod"; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Framework 1 title text font matched as expected'); + } else { + errors.push(`Expected: Framework 1 title text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '18.59px') { + console.log('Passed: Framework 1 title text font-size matched as expected'); + } else { + errors.push(`Expected: Framework 1 title text font-size "18.59px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(73, 80, 87, 1)') { + console.log('Passed: Framework 1 title text color matched as expected'); + } else { + errors.push(`Expected: Framework 1 title text color: "rgba(73, 80, 87, 1)"; Actual: "${elementTextColor}"`); + } + + //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')); + } + } + }, + + //Framework 2 + { + description: 'Framework 2 file icon, text, font, size, and color', + action: async () => { + const multipleChecks = 'Framework 2 - Widget Test'; + + const elementIcon = await driver.findElement(By.css('.org:nth-child(3) > .fa')); + const element = await driver.findElement(By.linkText('Widget Test')); + + //Get button text, text font, text size, text color, and button color + const elementText = await element.getText(''); + const elementTextFont = await element.getCssValue('font-family'); + const elementTextSize = await element.getCssValue('font-size'); + const elementTextColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //icon present + if (await elementIcon.isDisplayed()) { + console.log('Passed: Framework 2 file icon was displayed as expected'); + } else { + errors.push('Expected: Framework 2 file icon was not displayed'); + } + + //text + if (elementText === 'Widget Test') { + console.log('Passed: Framework 2 title text matched as expected'); + } else { + errors.push(`Expected: "Widget Test"; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Framework 2 title text font matched as expected'); + } else { + errors.push(`Expected: Framework 2 title text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '18.59px') { + console.log('Passed: Framework 2 title text font-size matched as expected'); + } else { + errors.push(`Expected: Framework 2 title text font-size "18.59px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(73, 80, 87, 1)') { + console.log('Passed: Framework 2 title text color matched as expected'); + } else { + errors.push(`Expected: Framework 2 title text color: "rgba(73, 80, 87, 1)"; Actual: "${elementTextColor}"`); + } + + //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')); + } + } + }, + + //Framework 3 + { + description: 'Framework 3 file icon, text, font, size, and color', + action: async () => { + const multipleChecks = 'Framework 3 - ecs31444'; + + const elementIcon = await driver.findElement(By.css('.list-group-item:nth-child(4) > .fa')); + const element = await driver.findElement(By.linkText('ecs31444')); + + //Get button text, text font, text size, text color, and button color + const elementText = await element.getText(''); + const elementTextFont = await element.getCssValue('font-family'); + const elementTextSize = await element.getCssValue('font-size'); + const elementTextColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //icon present + if (await elementIcon.isDisplayed()) { + console.log('Passed: Framework 3 file icon was displayed as expected'); + } else { + errors.push('Expected: Framework 3 file icon was not displayed'); + } + + //text + if (elementText === 'ecs31444') { + console.log('Passed: Framework 3 title text matched as expected'); + } else { + errors.push(`Expected: "ecs31444"; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Framework 3 title text font matched as expected'); + } else { + errors.push(`Expected: Framework 3 title text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '18.59px') { + console.log('Passed: Framework 3 title text font-size matched as expected'); + } else { + errors.push(`Expected: Framework 3 title text font-size "18.59px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(73, 80, 87, 1)') { + console.log('Passed: Framework 3 title text color matched as expected'); + } else { + errors.push(`Expected: Framework 3 title text color: "rgba(73, 80, 87, 1)"; Actual: "${elementTextColor}"`); + } + + //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: 'Search for hidden Framework title', + action: async () => { + //Slow type so the list has time to filter after each keystroke + const filterInput = await driver.findElement(By.css('#FilterOrganization')); + for (const char of 'imported frame') { + await filterInput.sendKeys(char); + await driver.sleep(200); + } + console.log('----->| NEXT ACTION: Searched for "Imported Framework"'); + await driver.sleep(2000); + + //Wait until it becomes visible | Imported Framework Updated file icon + const fileIcon = await driver.wait(until.elementLocated(By.css('.doc:nth-child(2) > .fa')), 30000); + await driver.wait(until.elementIsVisible(fileIcon), 30000); + } + }, + + //Search results - only Organization 1 and Framework 5 visible + { + description: 'Search results show only Organization 1 and Framework 5', + action: async () => { + const multipleChecks = 'Search results for "imported frame"'; + + const visibleItems = [ + { name: 'Organization 1 folder icon', locator: By.css('#folder1279361494') }, + { name: 'Organization 1 title', locator: By.linkText('Creating Org') }, + { name: 'Framework 5 file icon', locator: By.css('.doc:nth-child(2) > .fa') }, + { name: 'Framework 5 title', locator: By.linkText('Imported Framework Updated') }, + ]; + + const hiddenItems = [ + { name: 'Framework 1 file icon', locator: By.css('.org:nth-child(2) > .fa') }, + { name: 'Framework 1 title', locator: By.linkText('ECS-2933 Testing On Prod') }, + { name: 'Framework 2 file icon', locator: By.css('.org:nth-child(3) > .fa') }, + { name: 'Framework 2 title', locator: By.linkText('Widget Test') }, + { name: 'Framework 3 file icon', locator: By.css('.list-group-item:nth-child(4) > .fa') }, + { name: 'Framework 3 title', locator: By.linkText('ecs31444') }, + { name: 'Framework 4 file icon', locator: By.css('.doc:nth-child(1) > .fa') }, + { name: 'Framework 4 title', locator: By.linkText('5th Grade Import ECS-2732') }, + { name: 'Framework 6 file icon', locator: By.css('.doc:nth-child(3) > .fa') }, + { name: 'Framework 6 title', locator: By.linkText('NewTicket') }, + ]; + + //Track all errors + const errors = []; + + //Visible = in the page and displayed + for (const item of visibleItems) { + const matches = await driver.findElements(item.locator); + const isDisplayed = matches.length > 0 && await matches[0].isDisplayed(); + + if (isDisplayed) { + console.log(`Passed: ${item.name} was displayed as expected`); + } else { + errors.push(`Expected: ${item.name} was not displayed; Actual: hidden`); + } + } + + //Hidden = not in the page, or in the page but not displayed + for (const item of hiddenItems) { + const matches = await driver.findElements(item.locator); + const isDisplayed = matches.length > 0 && await matches[0].isDisplayed(); + + if (!isDisplayed) { + console.log(`Passed: ${item.name} was hidden as expected`); + } else { + errors.push(`Expected: ${item.name} was not hidden; Actual: displayed`); + } + } + + 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')); + } + } + }, + + //Organization 1 + { + description: 'Organization 1 folder icon, text, font, size, color and tooltip', + action: async () => { + const multipleChecks = 'Organization 1 - Creating Org'; + + const elementIcon = await driver.findElement(By.css('#folder1279361494')); + const expectedClass = 'fa mr-1 frame-icon fa-folder-open'; + const element = await driver.findElement(By.linkText('Creating Org')); + + //Get button text, text font, text size, text color, and button color + const elementIconColor = await elementIcon.getCssValue('color'); + const elementText = await element.getText(''); + const elementTextFont = await element.getCssValue('font-family'); + const elementTextSize = await element.getCssValue('font-size'); + const elementTextColor = await element.getCssValue('color'); + const elementTooltip = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //image class + const actualClass = await elementIcon.getAttribute('class'); + if (actualClass && actualClass === expectedClass) { + console.log('Passed: Organization 1 folder icon class matched expected'); + } else { + errors.push(`Expected: Organization 1 folder icon class: "${expectedClass}"; but found "${actualClass}"`); + } + + //icon color + if (elementIconColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Organization 1 folder icon color matched as expected'); + } else { + errors.push(`Expected: Organization 1 folder icon color: "rgba(40, 39, 90, 1)"; Actual: "${elementIconColor}"`); + } + + //text + if (elementText === 'Creating Org') { + console.log('Passed: Organization 1 title text matched as expected'); + } else { + errors.push(`Expected: "Creating Org "; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Organization 1 title text font matched as expected'); + } else { + errors.push(`Expected: Organization 1 title text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '18.59px') { + console.log('Passed: Organization 1 title text font-size matched as expected'); + } else { + errors.push(`Expected: Organization 1 title text font-size "18.59px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(0, 86, 179, 1)') { + console.log('Passed: Organization 1 title text color matched as expected'); + } else { + errors.push(`Expected: Organization 1 title text color: "rgba(0, 86, 179, 1)"; Actual: "${elementTextColor}"`); + } + + //tooltip + if (elementTooltip === 'Click to expand/collapse') { + console.log('Passed: Organization 1 title tooltip matched as expected'); + } else { + errors.push(`Expected: Organization 1 title tooltip: "Click to expand/collapse"; Actual: "${elementTooltip}"`); + } + + //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')); + } + } + }, + + //Framework 5 + { + description: 'Framework 5 file icon, text, font, size, and color', + action: async () => { + const multipleChecks = 'Framework 5 - Imported Framework Updated'; + + const elementIcon = await driver.findElement(By.css('.doc:nth-child(2) > .fa')); + const element = await driver.findElement(By.linkText('Imported Framework Updated')); + + //Get button text, text font, text size, text color, and button color + const elementText = await element.getText(''); + const elementTextFont = await element.getCssValue('font-family'); + const elementTextSize = await element.getCssValue('font-size'); + const elementTextColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //icon present + if (await elementIcon.isDisplayed()) { + console.log('Passed: Framework 5 file icon was displayed as expected'); + } else { + errors.push('Expected: Framework 5 file icon was not displayed'); + } + + //text + if (elementText === 'Imported Framework Updated') { + console.log('Passed: Framework 5 title text matched as expected'); + } else { + errors.push(`Expected: "Imported Framework Updated"; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Framework 5 title text font matched as expected'); + } else { + errors.push(`Expected: Framework 5 title text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '20.449px') { + console.log('Passed: Framework 5 title text font-size matched as expected'); + } else { + errors.push(`Expected: Framework 5 title text font-size "20.449px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(73, 80, 87, 1)') { + console.log('Passed: Framework 5 title text color matched as expected'); + } else { + errors.push(`Expected: Framework 5 title text color: "rgba(73, 80, 87, 1)"; Actual: "${elementTextColor}"`); + } + + //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 the Clear search icon', + action: async () => { + await driver.findElement(By.css('.fa-times')).click(); + console.log('----->| NEXT ACTION: Clicked the Clear search icon'); + await driver.sleep(2000); + + //Wait until it becomes visible | ecs31444 file icon + const fileIcon = await driver.wait(until.elementLocated(By.css('.list-group-item:nth-child(4) > .fa')), 30000); + await driver.wait(until.elementIsVisible(fileIcon), 30000); + } + }, + + //Framework 4, 5, and 6 hidden (Creating Org folder is collapsed) + { + description: 'Organization 1 and Frameworks 1-3 visible; Frameworks 4-6 hidden', + action: async () => { + const multipleChecks = 'Framework list before search'; + + const visibleItems = [ + { name: 'Organization 1 folder icon', locator: By.css('#folder1279361494') }, + { name: 'Organization 1 title', locator: By.linkText('Creating Org') }, + { name: 'Framework 1 file icon', locator: By.css('.org:nth-child(2) > .fa') }, + { name: 'Framework 1 title', locator: By.linkText('ECS-2933 Testing On Prod') }, + { name: 'Framework 2 file icon', locator: By.css('.org:nth-child(3) > .fa') }, + { name: 'Framework 2 title', locator: By.linkText('Widget Test') }, + { name: 'Framework 3 file icon', locator: By.css('.list-group-item:nth-child(4) > .fa') }, + { name: 'Framework 3 title', locator: By.linkText('ecs31444') }, + ]; + + const hiddenItems = [ + { name: 'Framework 4 file icon', locator: By.css('.doc:nth-child(1) > .fa') }, + { name: 'Framework 4 title', locator: By.linkText('5th Grade Import ECS-2732') }, + { name: 'Framework 5 file icon', locator: By.css('.doc:nth-child(2) > .fa') }, + { name: 'Framework 5 title', locator: By.linkText('Imported Framework Updated') }, + { name: 'Framework 6 file icon', locator: By.css('.doc:nth-child(3) > .fa') }, + { name: 'Framework 6 title', locator: By.linkText('NewTicket') }, + ]; + + //Track all errors + const errors = []; + + //Visible = in the page and displayed + for (const item of visibleItems) { + const matches = await driver.findElements(item.locator); + const isDisplayed = matches.length > 0 && await matches[0].isDisplayed(); + + if (isDisplayed) { + console.log(`Passed: ${item.name} was displayed as expected`); + } else { + errors.push(`Expected: ${item.name} was not displayed; Actual: hidden`); + } + } + + //Hidden = not in the page, or in the page but not displayed + for (const item of hiddenItems) { + const matches = await driver.findElements(item.locator); + const isDisplayed = matches.length > 0 && await matches[0].isDisplayed(); + + if (!isDisplayed) { + console.log(`Passed: ${item.name} was hidden as expected`); + } else { + errors.push(`Expected: ${item.name} was not hidden; Actual: displayed`); + } + } + + 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 Creating Org link', + action: async () => { + await driver.findElement(By.linkText('Creating Org')).click(); + console.log('----->| NEXT ACTION: Clicked Creating Org link'); + + //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 until the element exists in the DOM + const frameworkFileIcon = await driver.wait( + until.elementLocated(By.css('.doc:nth-child(1) > .fa')), + 30000 + ); + + //Wait until it becomes visible + await driver.wait( + until.elementIsVisible(frameworkFileIcon), + 30000 + ); + } + }, + + //Organization 1 and Frameworks 1-6 visible (Creating Org folder is expanded) + { + description: 'Organization 1 and Frameworks 1-6 visible', + action: async () => { + const multipleChecks = 'Framework list with Creating Org expanded'; + + const visibleItems = [ + { name: 'Organization 1 folder icon', locator: By.css('#folder1279361494') }, + { name: 'Organization 1 title', locator: By.linkText('Creating Org') }, + { name: 'Framework 1 file icon', locator: By.css('.org:nth-child(2) > .fa') }, + { name: 'Framework 1 title', locator: By.linkText('ECS-2933 Testing On Prod') }, + { name: 'Framework 2 file icon', locator: By.css('.org:nth-child(3) > .fa') }, + { name: 'Framework 2 title', locator: By.linkText('Widget Test') }, + { name: 'Framework 3 file icon', locator: By.css('.list-group-item:nth-child(4) > .fa') }, + { name: 'Framework 3 title', locator: By.linkText('ecs31444') }, + { name: 'Framework 4 file icon', locator: By.css('.doc:nth-child(1) > .fa') }, + { name: 'Framework 4 title', locator: By.linkText('5th Grade Import ECS-2732') }, + { name: 'Framework 5 file icon', locator: By.css('.doc:nth-child(2) > .fa') }, + { name: 'Framework 5 title', locator: By.linkText('Imported Framework Updated') }, + { name: 'Framework 6 file icon', locator: By.css('.doc:nth-child(3) > .fa') }, + { name: 'Framework 6 title', locator: By.linkText('NewTicket') }, + ]; + + //Track all errors + const errors = []; + + //Visible = in the page and displayed + for (const item of visibleItems) { + const matches = await driver.findElements(item.locator); + const isDisplayed = matches.length > 0 && await matches[0].isDisplayed(); + + if (isDisplayed) { + console.log(`Passed: ${item.name} was displayed as expected`); + } else { + errors.push(`Expected: ${item.name} was not displayed; Actual: hidden`); + } + } + + 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')); + } + } + }, + + //Organization 1 + { + description: 'Organization 1 folder icon, text, font, size, color and tooltip', + action: async () => { + const multipleChecks = 'Organization 1 - Creating Org'; + + const elementIcon = await driver.findElement(By.css('#folder1279361494')); + const expectedClass = 'fa mr-1 frame-icon fa-folder-open'; + const element = await driver.findElement(By.linkText('Creating Org')); + + //Get button text, text font, text size, text color, and button color + const elementIconColor = await elementIcon.getCssValue('color'); + const elementText = await element.getText(''); + const elementTextFont = await element.getCssValue('font-family'); + const elementTextSize = await element.getCssValue('font-size'); + const elementTextColor = await element.getCssValue('color'); + const elementTooltip = await element.getAttribute('title'); + + //Track all errors + const errors = []; + + //image class + const actualClass = await elementIcon.getAttribute('class'); + if (actualClass && actualClass === expectedClass) { + console.log('Passed: Organization 1 folder icon class matched expected'); + } else { + errors.push(`Expected: Organization 1 folder icon class: "${expectedClass}"; but found "${actualClass}"`); + } + + //icon color + if (elementIconColor === 'rgba(40, 39, 90, 1)') { + console.log('Passed: Organization 1 folder icon color matched as expected'); + } else { + errors.push(`Expected: Organization 1 folder icon color: "rgba(40, 39, 90, 1)"; Actual: "${elementIconColor}"`); + } + + //text + if (elementText === 'Creating Org') { + console.log('Passed: Organization 1 title text matched as expected'); + } else { + errors.push(`Expected: "Creating Org "; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Organization 1 title text font matched as expected'); + } else { + errors.push(`Expected: Organization 1 title text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '18.59px') { + console.log('Passed: Organization 1 title text font-size matched as expected'); + } else { + errors.push(`Expected: Organization 1 title text font-size "18.59px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(0, 86, 179, 1)') { + console.log('Passed: Organization 1 title text color matched as expected'); + } else { + errors.push(`Expected: Organization 1 title text color: "rgba(0, 86, 179, 1)"; Actual: "${elementTextColor}"`); + } + + //tooltip + if (elementTooltip === 'Click to expand/collapse') { + console.log('Passed: Organization 1 title tooltip matched as expected'); + } else { + errors.push(`Expected: Organization 1 title tooltip: "Click to expand/collapse"; Actual: "${elementTooltip}"`); + } + + //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')); + } + } + }, + + //Framework 4 + { + description: 'Framework 4 file icon, text, font, size, and color', + action: async () => { + const multipleChecks = 'Framework 4 - 5th Grade Import ECS-2732'; + + const elementIcon = await driver.findElement(By.css('.doc:nth-child(1) > .fa')); + const element = await driver.findElement(By.linkText('5th Grade Import ECS-2732')); + + //Get button text, text font, text size, text color, and button color + const elementText = await element.getText(''); + const elementTextFont = await element.getCssValue('font-family'); + const elementTextSize = await element.getCssValue('font-size'); + const elementTextColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //icon present + if (await elementIcon.isDisplayed()) { + console.log('Passed: Framework 4 file icon was displayed as expected'); + } else { + errors.push('Expected: Framework 4 file icon was not displayed'); + } + + //text + if (elementText === '5th Grade Import ECS-2732') { + console.log('Passed: Framework 4 title text matched as expected'); + } else { + errors.push(`Expected: "5th Grade Import ECS-2732"; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Framework 4 title text font matched as expected'); + } else { + errors.push(`Expected: Framework 4 title text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '20.449px') { + console.log('Passed: Framework 4 title text font-size matched as expected'); + } else { + errors.push(`Expected: Framework 4 title text font-size "20.449px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(73, 80, 87, 1)') { + console.log('Passed: Framework 4 title text color matched as expected'); + } else { + errors.push(`Expected: Framework 4 title text color: "rgba(73, 80, 87, 1)"; Actual: "${elementTextColor}"`); + } + + //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')); + } + } + }, + + //Framework 5 + { + description: 'Framework 5 file icon, text, font, size, and color', + action: async () => { + const multipleChecks = 'Framework 5 - Imported Framework Updated'; + + const elementIcon = await driver.findElement(By.css('.doc:nth-child(2) > .fa')); + const element = await driver.findElement(By.linkText('Imported Framework Updated')); + + //Get button text, text font, text size, text color, and button color + const elementText = await element.getText(''); + const elementTextFont = await element.getCssValue('font-family'); + const elementTextSize = await element.getCssValue('font-size'); + const elementTextColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //icon present + if (await elementIcon.isDisplayed()) { + console.log('Passed: Framework 5 file icon was displayed as expected'); + } else { + errors.push('Expected: Framework 5 file icon was not displayed'); + } + + //text + if (elementText === 'Imported Framework Updated') { + console.log('Passed: Framework 5 title text matched as expected'); + } else { + errors.push(`Expected: "Imported Framework Updated"; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Framework 5 title text font matched as expected'); + } else { + errors.push(`Expected: Framework 5 title text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '20.449px') { + console.log('Passed: Framework 5 title text font-size matched as expected'); + } else { + errors.push(`Expected: Framework 5 title text font-size "20.449px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(73, 80, 87, 1)') { + console.log('Passed: Framework 5 title text color matched as expected'); + } else { + errors.push(`Expected: Framework 5 title text color: "rgba(73, 80, 87, 1)"; Actual: "${elementTextColor}"`); + } + + //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')); + } + } + }, + + //Framework 6 + { + description: 'Framework 6 file icon, text, font, size, and color', + action: async () => { + const multipleChecks = 'Framework 6 - NewTicket'; + + const elementIcon = await driver.findElement(By.css('.doc:nth-child(3) > .fa')); + const element = await driver.findElement(By.linkText('NewTicket')); + + //Get button text, text font, text size, text color, and button color + const elementText = await element.getText(''); + const elementTextFont = await element.getCssValue('font-family'); + const elementTextSize = await element.getCssValue('font-size'); + const elementTextColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //icon present + if (await elementIcon.isDisplayed()) { + console.log('Passed: Framework 6 file icon was displayed as expected'); + } else { + errors.push('Expected: Framework 6 file icon was not displayed'); + } + + //text + if (elementText === 'NewTicket') { + console.log('Passed: Framework 6 title text matched as expected'); + } else { + errors.push(`Expected: "NewTicket"; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Framework 6 title text font matched as expected'); + } else { + errors.push(`Expected: Framework 6 title text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '20.449px') { + console.log('Passed: Framework 6 title text font-size matched as expected'); + } else { + errors.push(`Expected: Framework 6 title text font-size "20.449px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(73, 80, 87, 1)') { + console.log('Passed: Framework 6 title text color matched as expected'); + } else { + errors.push(`Expected: Framework 6 title text color: "rgba(73, 80, 87, 1)"; Actual: "${elementTextColor}"`); + } + + //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')); + } + } + }, + + //Framework 1 + { + description: 'Framework 1 file icon, text, font, size, and color', + action: async () => { + const multipleChecks = 'Framework 1 - ECS-2933 Testing On Prod'; + + const elementIcon = await driver.findElement(By.css('.org:nth-child(2) > .fa')); + const element = await driver.findElement(By.linkText('ECS-2933 Testing On Prod')); + + //Get button text, text font, text size, text color, and button color + const elementText = await element.getText(''); + const elementTextFont = await element.getCssValue('font-family'); + const elementTextSize = await element.getCssValue('font-size'); + const elementTextColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //icon present + if (await elementIcon.isDisplayed()) { + console.log('Passed: Framework 1 file icon was displayed as expected'); + } else { + errors.push('Expected: Framework 1 file icon was not displayed'); + } + + //text + if (elementText === 'ECS-2933 Testing On Prod') { + console.log('Passed: Framework 1 title text matched as expected'); + } else { + errors.push(`Expected: "ECS-2933 Testing On Prod"; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Framework 1 title text font matched as expected'); + } else { + errors.push(`Expected: Framework 1 title text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '18.59px') { + console.log('Passed: Framework 1 title text font-size matched as expected'); + } else { + errors.push(`Expected: Framework 1 title text font-size "18.59px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(73, 80, 87, 1)') { + console.log('Passed: Framework 1 title text color matched as expected'); + } else { + errors.push(`Expected: Framework 1 title text color: "rgba(73, 80, 87, 1)"; Actual: "${elementTextColor}"`); + } + + //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')); + } + } + }, + + //Framework 2 + { + description: 'Framework 2 file icon, text, font, size, and color', + action: async () => { + const multipleChecks = 'Framework 2 - Widget Test'; + + const elementIcon = await driver.findElement(By.css('.org:nth-child(3) > .fa')); + const element = await driver.findElement(By.linkText('Widget Test')); + + //Get button text, text font, text size, text color, and button color + const elementText = await element.getText(''); + const elementTextFont = await element.getCssValue('font-family'); + const elementTextSize = await element.getCssValue('font-size'); + const elementTextColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //icon present + if (await elementIcon.isDisplayed()) { + console.log('Passed: Framework 2 file icon was displayed as expected'); + } else { + errors.push('Expected: Framework 2 file icon was not displayed'); + } + + //text + if (elementText === 'Widget Test') { + console.log('Passed: Framework 2 title text matched as expected'); + } else { + errors.push(`Expected: "Widget Test"; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Framework 2 title text font matched as expected'); + } else { + errors.push(`Expected: Framework 2 title text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '18.59px') { + console.log('Passed: Framework 2 title text font-size matched as expected'); + } else { + errors.push(`Expected: Framework 2 title text font-size "18.59px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(73, 80, 87, 1)') { + console.log('Passed: Framework 2 title text color matched as expected'); + } else { + errors.push(`Expected: Framework 2 title text color: "rgba(73, 80, 87, 1)"; Actual: "${elementTextColor}"`); + } + + //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')); + } + } + }, + + //Framework 3 + { + description: 'Framework 3 file icon, text, font, size, and color', + action: async () => { + const multipleChecks = 'Framework 3 - ecs31444'; + + const elementIcon = await driver.findElement(By.css('.list-group-item:nth-child(4) > .fa')); + const element = await driver.findElement(By.linkText('ecs31444')); + + //Get button text, text font, text size, text color, and button color + const elementText = await element.getText(''); + const elementTextFont = await element.getCssValue('font-family'); + const elementTextSize = await element.getCssValue('font-size'); + const elementTextColor = await element.getCssValue('color'); + + //Track all errors + const errors = []; + + //icon present + if (await elementIcon.isDisplayed()) { + console.log('Passed: Framework 3 file icon was displayed as expected'); + } else { + errors.push('Expected: Framework 3 file icon was not displayed'); + } + + //text + if (elementText === 'ecs31444') { + console.log('Passed: Framework 3 title text matched as expected'); + } else { + errors.push(`Expected: "ecs31444"; Actual: "${elementText}"`); + } + + //font-family + if (elementTextFont === "Poppins, sans-serif") { + console.log('Passed: Framework 3 title text font matched as expected'); + } else { + errors.push(`Expected: Framework 3 title text font "Poppins, sans-serif"; Actual: ${elementTextFont}`); + } + + //font size + if (elementTextSize === '18.59px') { + console.log('Passed: Framework 3 title text font-size matched as expected'); + } else { + errors.push(`Expected: Framework 3 title text font-size "18.59px"; Actual: "${elementTextSize}"`); + } + + //color + if (elementTextColor === 'rgba(73, 80, 87, 1)') { + console.log('Passed: Framework 3 title text color matched as expected'); + } else { + errors.push(`Expected: Framework 3 title text color: "rgba(73, 80, 87, 1)"; Actual: "${elementTextColor}"`); + } + + //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')); + } + } + }, + + //Framework 5 option icons on hover + { + description: 'Framework 5 option icons are displayed on hover', + action: async () => { + //Imported Framework Updated row (id 1279361500) inside the Creating Org folder + const row = await driver.findElement(By.xpath('//ul[@id="org-1279361494"]/li[.//a[contains(@href, "id=1279361500")]]')); + const optionsArea = await row.findElement(By.css('.opts')); + + //Option icons, identified by the page each one opens + const optionIcons = [ + { name: 'Publish Framework icon', href: 'framework_publish_modal.php', expectedTitle: 'Publish Framework' }, + { name: 'View Framework icon', href: 'viewframework.php' }, + { name: 'Download This Framework icon', href: 'export_framework_modal.php', expectedTitle: 'Download This Framework' }, + { name: 'Framework View icon', href: 'framework_view_modal.php' }, + { name: 'Edit icon', href: 'org_edit_modal.php' }, + ]; + + //Hover over the Framework 5 row + await driver.actions({ async: true }).move({ origin: row }).perform(); + console.log('----->| NEXT ACTION: Hover over Imported Framework Updated title to display edit icon'); + + //Track all errors + const errors = []; + + //Give each icon up to 5 seconds to appear + for (const icon of optionIcons) { + const matches = await optionsArea.findElements(By.css(`a[href*="${icon.href}"] .fa`)); + + if (matches.length === 0) { + errors.push(`Expected: Framework 5 ${icon.name} to exist; Actual: not found`); + continue; + } + + try { + await driver.wait(until.elementIsVisible(matches[0]), 5000); + console.log(`Passed: Framework 5 ${icon.name} was displayed on hover as expected`); + } catch { + errors.push(`Expected: Framework 5 ${icon.name} to be displayed on hover; Actual: not displayed`); + } + + //Title (tooltip) is on the icon's link + if (icon.expectedTitle) { + const iconLink = await optionsArea.findElement(By.css(`a[href*="${icon.href}"]`)); + const iconTitle = await iconLink.getAttribute('title'); + + if (iconTitle === icon.expectedTitle) { + console.log(`Passed: Framework 5 ${icon.name} title matched as expected`); + } else { + errors.push(`Expected: Framework 5 ${icon.name} title: "${icon.expectedTitle}"; Actual: "${iconTitle}"`); + } + } + } + + if (errors.length > 0) { + //Add summary line only when multiple checks failed + if (errors.length > 1) { + errors.unshift('Framework 5 option icons on hover - Multiple validation checks did not pass'); + } + + //Throw collected messages — catch() will prefix with "FAILED:" + throw new Error(errors.join('\n')); + } + } + }, + +/* + + + //Organization label + { + description: 'Validate Organization label', + action: async () => { + try { + const element = await driver.findElement(By.css('#divtype')); + + //Get different versions of the text for debugging + const fullText = await element.getText(); + + //Check for the expected text in different ways + const expectedText = 'Organization'; + const trimmedFullText = fullText.trim(); + const firstLine = trimmedFullText.split('\n')[0].trim(); + + //Try multiple matching strategies + if (firstLine.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text in first line`); + } else if (trimmedFullText.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text within full text`); + } else { + throw new Error( + `Text validation failed.\nExpected: "${expectedText}"\n` + + `Full text: "${fullText}"\n` + + `First line: "${firstLine}"\n` + ); + } + + } catch (error) { + console.error('Detailed error during validation:', error); + throw error; //Re-throw after logging + } + } + }, + + //Organization value + { + description: 'Validate Organization value', + action: async () => { + try { + const element = await driver.findElement(By.css('#divname > .form-label')); + + //Get different versions of the text for debugging + const fullText = await element.getText(); + + //Check for the expected text in different ways + const expectedText = 'Name'; + const trimmedFullText = fullText.trim(); + const firstLine = trimmedFullText.split('\n')[0].trim(); + + //Try multiple matching strategies + if (firstLine.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text in first line`); + } else if (trimmedFullText.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text within full text`); + } else { + throw new Error( + `Text validation failed.\nExpected: "${expectedText}"\n` + + `Full text: "${fullText}"\n` + + `First line: "${firstLine}"\n` + ); + } + + } catch (error) { + console.error('Detailed error during validation:', error); + throw error; //Re-throw after logging + } + } + }, + + + //Type value + { + description: 'Validate Type value', + action: async () => { + try { + const element = await driver.findElement(By.css('#divtype')); + + //Get different versions of the text for debugging + const fullText = await element.getText(); + + //Check for the expected text in different ways + const expectedText = 'Framework'; + const trimmedFullText = fullText.trim(); + const firstLine = trimmedFullText.split('\n')[0].trim(); + + //Try multiple matching strategies + if (firstLine.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text in first line`); + } else if (trimmedFullText.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text within full text`); + } else { + throw new Error( + `Text validation failed.\nExpected: "${expectedText}"\n` + + `Full text: "${fullText}"\n` + + `First line: "${firstLine}"\n` + ); + } + + } catch (error) { + console.error('Detailed error during validation:', error); + throw error; //Re-throw after logging + } + } + }, + + + + //Name value + { + description: 'Validate Name value', + action: async () => { + try { + const element = await driver.findElement(By.css('#divname')); + + //Get different versions of the text for debugging + const fullText = await element.getText(); + + //Check for the expected text in different ways + const expectedText = 'Juan Testing Again & Again'; + const trimmedFullText = fullText.trim(); + const firstLine = trimmedFullText.split('\n')[0].trim(); + + //Try multiple matching strategies + if (firstLine.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text in first line`); + } else if (trimmedFullText.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text within full text`); + } else { + throw new Error( + `Text validation failed.\nExpected: "${expectedText}"\n` + + `Full text: "${fullText}"\n` + + `First line: "${firstLine}"\n` + ); + } + + } catch (error) { + console.error('Detailed error during validation:', error); + throw error; //Re-throw after logging + } + } + }, + + + + //Parent value + { + description: 'Validate Parent value', + action: async () => { + try { + const element = await driver.findElement(By.css('.form-row:nth-child(1) > #divparent')); + + //Get different versions of the text for debugging + const fullText = await element.getText(); + + //Check for the expected text in different ways + const expectedText = 'Parent'; + const trimmedFullText = fullText.trim(); + const firstLine = trimmedFullText.split('\n')[0].trim(); + + //Try multiple matching strategies + if (firstLine.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text in first line`); + } else if (trimmedFullText.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text within full text`); + } else { + throw new Error( + `Text validation failed.\nExpected: "${expectedText}"\n` + + `Full text: "${fullText}"\n` + + `First line: "${firstLine}"\n` + ); + } + + } catch (error) { + console.error('Detailed error during validation:', error); + throw error; //Re-throw after logging + } + } + }, + + + + //Description value + { + description: 'Validate Description value', + action: async () => { + try { + const element = await driver.findElement(By.css('#divdescription')); + + //Get different versions of the text for debugging + const fullText = await element.getText(); + + //Check for the expected text in different ways + const expectedText = 'This is my Framework testing description.'; + const trimmedFullText = fullText.trim(); + const firstLine = trimmedFullText.split('\n')[0].trim(); + + //Try multiple matching strategies + if (firstLine.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text in first line`); + } else if (trimmedFullText.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text within full text`); + } else { + throw new Error( + `Text validation failed.\nExpected: "${expectedText}"\n` + + `Full text: "${fullText}"\n` + + `First line: "${firstLine}"\n` + ); + } + + } catch (error) { + console.error('Detailed error during validation:', error); + throw error; //Re-throw after logging + } + } + }, + + + + //Creator value + { + description: 'Validate Creator value', + action: async () => { + try { + const element = await driver.findElement(By.css('#divcreator')); + + //Get different versions of the text for debugging + const fullText = await element.getText(); + + //Check for the expected text in different ways + const expectedText = 'Juancho'; + const trimmedFullText = fullText.trim(); + const firstLine = trimmedFullText.split('\n')[0].trim(); + + //Try multiple matching strategies + if (firstLine.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text in first line`); + } else if (trimmedFullText.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text within full text`); + } else { + throw new Error( + `Text validation failed.\nExpected: "${expectedText}"\n` + + `Full text: "${fullText}"\n` + + `First line: "${firstLine}"\n` + ); + } + + } catch (error) { + console.error('Detailed error during validation:', error); + throw error; //Re-throw after logging + } + } + }, + + + + //Publisher value + { + description: 'Validate Publisher value', + action: async () => { + try { + const element = await driver.findElement(By.css('#divpublisher')); + + //Get different versions of the text for debugging + const fullText = await element.getText(); + + //Check for the expected text in different ways + const expectedText = 'Publishers Clearing House'; + const trimmedFullText = fullText.trim(); + const firstLine = trimmedFullText.split('\n')[0].trim(); + + //Try multiple matching strategies + if (firstLine.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text in first line`); + } else if (trimmedFullText.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text within full text`); + } else { + throw new Error( + `Text validation failed.\nExpected: "${expectedText}"\n` + + `Full text: "${fullText}"\n` + + `First line: "${firstLine}"\n` + ); + } + + } catch (error) { + console.error('Detailed error during validation:', error); + throw error; //Re-throw after logging + } + } + }, + + + //Status value + { + description: 'Validate Status value', + action: async () => { + try { + const element = await driver.findElement(By.css('#divstatus')); + + //Get different versions of the text for debugging + const fullText = await element.getText(); + + //Check for the expected text in different ways + const expectedText = 'Draft'; + const trimmedFullText = fullText.trim(); + const firstLine = trimmedFullText.split('\n')[0].trim(); + + //Try multiple matching strategies + if (firstLine.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text in first line`); + } else if (trimmedFullText.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text within full text`); + } else { + throw new Error( + `Text validation failed.\nExpected: "${expectedText}"\n` + + `Full text: "${fullText}"\n` + + `First line: "${firstLine}"\n` + ); + } + + } catch (error) { + console.error('Detailed error during validation:', error); + throw error; //Re-throw after logging + } + } + }, + + + + //Effective Date value + { + description: 'Validate Effective Date value', + action: async () => { + try { + const element = await driver.findElement(By.css('#diveffective')); + + //Get different versions of the text for debugging + const fullText = await element.getText(); + + //Check for the expected text in different ways + const expectedText = '12/02/2022'; + const trimmedFullText = fullText.trim(); + const firstLine = trimmedFullText.split('\n')[0].trim(); + + //Try multiple matching strategies + if (firstLine.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text in first line`); + } else if (trimmedFullText.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text within full text`); + } else { + throw new Error( + `Text validation failed.\nExpected: "${expectedText}"\n` + + `Full text: "${fullText}"\n` + + `First line: "${firstLine}"\n` + ); + } + + } catch (error) { + console.error('Detailed error during validation:', error); + throw error; //Re-throw after logging + } + } + }, + + + + //Language value + { + description: 'Validate Language value', + action: async () => { + try { + const element = await driver.findElement(By.css('#divlang')); + + //Get different versions of the text for debugging + const fullText = await element.getText(); + + //Check for the expected text in different ways + const expectedText = 'English'; + const trimmedFullText = fullText.trim(); + const firstLine = trimmedFullText.split('\n')[0].trim(); + + //Try multiple matching strategies + if (firstLine.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text in first line`); + } else if (trimmedFullText.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text within full text`); + } else { + throw new Error( + `Text validation failed.\nExpected: "${expectedText}"\n` + + `Full text: "${fullText}"\n` + + `First line: "${firstLine}"\n` + ); + } + + } catch (error) { + console.error('Detailed error during validation:', error); + throw error; //Re-throw after logging + } + } + }, + + + + //Version value + { + description: 'Validate Version value', + action: async () => { + try { + const element = await driver.findElement(By.css('#divversion')); + + //Get different versions of the text for debugging + const fullText = await element.getText(); + + //Check for the expected text in different ways + const expectedText = '2022.1.1'; + const trimmedFullText = fullText.trim(); + const firstLine = trimmedFullText.split('\n')[0].trim(); + + //Try multiple matching strategies + if (firstLine.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text in first line`); + } else if (trimmedFullText.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text within full text`); + } else { + throw new Error( + `Text validation failed.\nExpected: "${expectedText}"\n` + + `Full text: "${fullText}"\n` + + `First line: "${firstLine}"\n` + ); + } + + } catch (error) { + console.error('Detailed error during validation:', error); + throw error; //Re-throw after logging + } + } + }, + + + + //Notes value + { + description: 'Validate Notes value', + action: async () => { + try { + const element = await driver.findElement(By.css('#divnotes')); + + //Get different versions of the text for debugging + const fullText = await element.getText(); + + //Check for the expected text in different ways + const expectedText = 'This only contains Kindergarten for now.'; + const trimmedFullText = fullText.trim(); + const firstLine = trimmedFullText.split('\n')[0].trim(); + + //Try multiple matching strategies + if (firstLine.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text in first line`); + } else if (trimmedFullText.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text within full text`); + } else { + throw new Error( + `Text validation failed.\nExpected: "${expectedText}"\n` + + `Full text: "${fullText}"\n` + + `First line: "${firstLine}"\n` + ); + } + + } catch (error) { + console.error('Detailed error during validation:', error); + throw error; //Re-throw after logging + } + } + }, + + + + //Created value + { + description: 'Validate Created value', + action: async () => { + try { + const element = await driver.findElement(By.css('.form-row:nth-child(4) > #divsource')); + + //Get different versions of the text for debugging + const fullText = await element.getText(); + + //Check for the expected text in different ways + const expectedText = 'Wed, 23 Nov 2022 21:05:03 -0800'; + const trimmedFullText = fullText.trim(); + const firstLine = trimmedFullText.split('\n')[0].trim(); + + //Try multiple matching strategies + if (firstLine.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text in first line`); + } else if (trimmedFullText.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text within full text`); + } else { + throw new Error( + `Text validation failed.\nExpected: "${expectedText}"\n` + + `Full text: "${fullText}"\n` + + `First line: "${firstLine}"\n` + ); + } + + } catch (error) { + console.error('Detailed error during validation:', error); + throw error; //Re-throw after logging + } + } + }, + + + + //Last Modified value + { + description: 'Validate Last Modified value', + action: async () => { + try { + const element = await driver.findElement(By.css('.form-row:nth-child(4) > #divparent')); + + //Get different versions of the text for debugging + const fullText = await element.getText(); + + //Check for the expected text in different ways + const expectedText = 'Wed, 26 Feb 2025 15:50:11 -0800'; + const trimmedFullText = fullText.trim(); + const firstLine = trimmedFullText.split('\n')[1].trim(); + + //Try multiple matching strategies + if (firstLine.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text in first line`); + } else if (trimmedFullText.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text within full text`); + } else { + throw new Error( + `Text validation failed.\nExpected: "${expectedText}"\n` + + `Full text: "${fullText}"\n` + + `First line: "${firstLine}"\n` + ); + } + + } catch (error) { + console.error('Detailed error during validation:', error); + throw error; //Re-throw after logging + } + } + }, + + + //Type value text + { + description: 'Validate Type value text', + action: async () => { + try { + const element = await driver.findElement(By.css('#divtype')); + + //Get different versions of the text for debugging + const fullText = await element.getText(); + + //Check for the expected text in different ways + const expectedText = 'Framework'; + const trimmedFullText = fullText.trim(); + const firstLine = trimmedFullText.split('\n')[0].trim(); + + //Try multiple matching strategies + if (firstLine.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text in first line`); + } else if (trimmedFullText.includes(expectedText)) { + console.log(`Passed: "${expectedText}" text within full text`); + } else { + throw new Error( + `Text validation failed.\nExpected: "${expectedText}"\n` + + `Full text: "${fullText}"\n` + + `First line: "${firstLine}"\n` + ); + } + + } catch (error) { + console.error('Detailed error during validation:', error); + throw error; //Re-throw after logging + } + } + }, + +*/ + //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', 'frameworkManagementPage'); + + const screenshotFileName = `step_${stepIndex}_${stepDescription.replace(/\s+/g, '_')}.png`; + const screenshotPath = path.join(dir, screenshotFileName); + fs.writeFileSync(screenshotPath, screenshot, 'base64'); + return screenshotPath; +}; + +const clearOldResults = () => { + //Remove old screenshots + const screenshotDir = path.join('screenshots', 'frameworkManagementPage'); + if (fs.existsSync(screenshotDir)) { + fs.rmSync(screenshotDir, { recursive: true, force: true }); + } + fs.mkdirSync(screenshotDir, { recursive: true }); + + //Remove old Excel file + if (fs.existsSync('frameworkManagementPageResults.xlsx')) { + fs.unlinkSync('frameworkManagementPageResults.xlsx'); + } +}; + +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; + } + } + + //Check if log out was successful + + if (allStepsPassed) { + console.log('------------->| THE END |<-------------'); + console.log('PASSED: Framework Management Page(frameworkManagementPage); All test steps completed successfully'); + testStatus = 'Passed'; + } else { + console.log('------------->| THE END |<-------------'); + console.log('FAILED: Framework Management Page(frameworkManagementPage); 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, 'frameworkManagementPageResults.xlsx'); +} finally { + await driver.quit(); +} + })(); +} + +export default frameworkManagementPage;