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 alignContentPage = (req, res) => { res.send('

ExACT Automated Test Script: Align Content Page(alignContentPage); 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('------------->| ALIGN CONTENT 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 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 ); } }, //Align icon color -gray { description: 'Validate Align icon color', action: async () => { const elementStyle = await driver.findElement(By.css('.fb-align')).getCssValue('color'); if (elementStyle !== 'rgba(99, 99, 99, 1)') { throw new Error(`Align icon color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Align icon color matched as expected'); } }, //NEXT ACTION - Navigate to Align page { description: 'Click Align navigation link', action: async () => await driver.findElement(By.linkText('Align')).click() }, //Wait for page to load - Correlation Coverages View Details button { description: 'Wait for page load to completely', action: async () => { return await driver.wait(until.elementLocated(By.css('h2')), 10000).catch(() => false); } }, //Browse page title { description: 'Validate Browse page title', action: async () => { const elementText = await driver.findElement(By.css('h2')).getText(); if (elementText !== 'Browse') { throw new Error(`Expected: "Browse"; Actual: "${elementText}"`); } console.log('Passed: Browse page title matched as expected'); } }, //Browse page title text color -dark blue { description: 'Validate Browse page title text color', action: async () => { const elementStyle = await driver.findElement(By.css('h2')).getCssValue('color'); if (elementStyle !== 'rgba(40, 39, 90, 1)') { throw new Error(`Browse page title text color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Browse page title text color matched as expected'); } }, //Browse page title text font { description: 'Validate Browse page title text font size', action: async () => { const elementStyle = await driver.findElement(By.css('h2')).getCssValue('font-size'); if (elementStyle !== '32px') { throw new Error(`Browse page title text font-size did not match; Actual: "${elementStyle}"`); } console.log('Passed: Browse page title text font-size matched as expected'); } }, //Content tab label (active) { description: 'Validate Content tab label', action: async () => { const elementText = await driver.findElement(By.linkText('Content')).getText(); if (elementText !== 'Content') { throw new Error(`Expected: "Content"; Actual: "${elementText}"`); } console.log('Passed: Content tab label matched as expected'); } }, //Content tab text color -white (active) { description: 'Validate Content tab color', action: async () => { const elementStyle = await driver.findElement(By.linkText('Content')).getCssValue('color'); if (elementStyle !== 'rgba(255, 255, 255, 1)') { throw new Error(`Content tab text color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Content tab text color matched as expected'); } }, //Content tab color -dark blue (active) { description: 'Validate Content tab color', action: async () => { const elementStyle = await driver.findElement(By.linkText('Content')).getCssValue('background-color'); if (elementStyle !== 'rgba(40, 39, 90, 1)') { throw new Error(`Content tab color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Content tab color matched as expected'); } }, //Standards tab label (dimmed) { description: 'Validate Standards tab label', action: async () => { const elementText = await driver.findElement(By.linkText('Standards')).getText(); if (elementText !== 'Standards') { throw new Error(`Expected: "Standards"; Actual: "${elementText}"`); } console.log('Passed: Standards tab label matched as expected'); } }, //Standards tab text color -gray (dimmed) { description: 'Validate Standards tab color', action: async () => { const elementStyle = await driver.findElement(By.linkText('Standards')).getCssValue('color'); if (elementStyle !== 'rgba(182, 186, 181, 1)') { throw new Error(`Standards tab text color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Standards tab text color matched as expected'); } }, //Standards tab color -white (dimmed) { description: 'Validate Standards tab color', action: async () => { const elementStyle = await driver.findElement(By.linkText('Standards')).getCssValue('background-color'); if (elementStyle !== 'rgba(0, 0, 0, 0)') { throw new Error(`Standards tab color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Standards tab color matched as expected'); } }, //Concepts tab label (dimmed) { description: 'Validate Concepts tab label', action: async () => { const elementText = await driver.findElement(By.linkText('Concepts')).getText(); if (elementText !== 'Concepts') { throw new Error(`Expected: "Concepts"; Actual: "${elementText}"`); } console.log('Passed: Concepts tab label matched as expected'); } }, //Concepts tab text color -white (dimmed) { description: 'Validate Concepts tab color', action: async () => { const elementStyle = await driver.findElement(By.linkText('Concepts')).getCssValue('color'); if (elementStyle !== 'rgba(182, 186, 181, 1)') { throw new Error(`Concepts tab text color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Concepts tab text color matched as expected'); } }, //Concepts tab color -white (dimmed) { description: 'Validate Concepts tab color', action: async () => { const elementStyle = await driver.findElement(By.linkText('Concepts')).getCssValue('background-color'); if (elementStyle !== 'rgba(0, 0, 0, 0)') { throw new Error(`Concepts tab color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Concepts tab color matched as expected'); } }, //Available Content header { description: 'Validate Available Content header', action: async () => { const elementText = await driver.findElement(By.css('#content form > p')).getText(); if (elementText !== 'Available Content') { throw new Error(`Expected: "Available Content"; Actual: "${elementText}"`); } console.log('Passed: Available Content header matched as expected'); } }, //Available Content 1 { description: 'Validate Available Content 1 label', action: async () => { const elementText = await driver.findElement(By.linkText('Demo - User Submitted Content')).getText(); if (elementText !== 'Demo - User Submitted Content') { throw new Error(`Expected: "Demo - User Submitted Content"; Actual: "${elementText}"`); } console.log('Passed: Demo - User Submitted Content label matched as expected'); } }, //Available Content 2 { description: 'Validate Available Content 2 label', action: async () => { const elementText = await driver.findElement(By.linkText('Upload Demo')).getText(); if (elementText !== 'Upload Demo') { throw new Error(`Expected: "Upload Demo"; Actual: "${elementText}"`); } console.log('Passed: Upload Demo label matched as expected'); } }, //Available Content 3 { description: 'Validate Available Content 3 label', action: async () => { const elementText = await driver.findElement(By.linkText('Exploring - Access')).getText(); if (elementText !== 'Exploring - Access') { throw new Error(`Expected: "Exploring - Access"; Actual: "${elementText}"`); } console.log('Passed: Exploring - Access label matched as expected'); } }, //Available Content 4 { description: 'Validate Available Content 4 label', action: async () => { const elementText = await driver.findElement(By.linkText('Exploring - PowerPoint')).getText(); if (elementText !== 'Exploring - PowerPoint') { throw new Error(`Expected: "Exploring - PowerPoint"; Actual: "${elementText}"`); } console.log('Passed: Exploring - PowerPoint label matched as expected'); } }, //Available Content 5 { description: 'Validate Available Content 5 label', action: async () => { const elementText = await driver.findElement(By.linkText('Exploring - Word')).getText(); if (elementText !== 'Exploring - Word') { throw new Error(`Expected: "Exploring - Word"; Actual: "${elementText}"`); } console.log('Passed: Exploring - Word label matched as expected'); } }, //Available Content - Advanced Options { description: 'Validate Available Content - Advance Options label', action: async () => { const elementText = await driver.findElement(By.linkText('Advanced Options')).getText(); if (elementText !== 'Advanced Options') { throw new Error(`Expected: "Advanced Options"; Actual: "${elementText}"`); } console.log('Passed: Advanced Options label matched as expected'); } }, //Advanced Options text color -green { description: 'Validate Advanced Options text color', action: async () => { const elementStyle = await driver.findElement(By.linkText('Advanced Options')).getCssValue('color'); if (elementStyle !== 'rgba(48, 200, 172, 1)') { throw new Error(`Advanced Options text color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Advanced Options text color matched as expected'); } }, //NEXT ACTION - Click Advanced Options link { description: 'Click Advanced Options link', action: async () => await driver.findElement(By.linkText('Advanced Options')).click() }, //Wait for DIV to load - Correlation Coverages View Details button { description: 'Wait for DIV load to completely', action: async () => { return await driver.wait(until.elementLocated(By.css('#searchbox-content > p')), 10000).catch(() => false); } }, //Apply filters to results: { description: 'Validate Apply filters to results label', action: async () => { const elementText = await driver.findElement(By.css('#searchbox-content > p')).getText(); if (elementText !== 'Apply filters to results:') { throw new Error(`Expected: "Apply filters to results:"; Actual: "${elementText}"`); } console.log('Passed: Apply filters to results: label matched as expected'); } }, //Grade: { description: 'Validate Grade label', action: async () => { try { const element = await driver.findElement(By.css('.list-group:nth-child(2) > .list-group-item:nth-child(1)')); //Get different versions of the text for debugging const fullText = await element.getText(); //Check for the expected text in different ways const expectedText = 'Grade'; const trimmedFullText = fullText.trim(); const firstLine = trimmedFullText.split('\n')[0].trim(); //Try multiple matching strategies if (firstLine.includes(expectedText)) { console.log(`Passed: "${expectedText}" text found in first line`); } else if (trimmedFullText.includes(expectedText)) { console.log(`Passed: "${expectedText}" text found 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 } } }, //Grade dropdown value { description: 'Validate Grade dropdown value', action: async () => { const elementText = await driver.findElement(By.css('.list-group-item:nth-child(1) .multiselect-selected-text')).getText(); if (elementText !== 'None selected') { throw new Error(`Expected: Grade: "None selected" dropdown value did not match; Actual: "${elementText}"`); } console.log('Passed: Grade: None selected dropdown value matched as expected'); } }, //Subject: { description: 'Validate Subject label', action: async () => { try { const element = await driver.findElement(By.css('.list-group:nth-child(2) > .list-group-item:nth-child(2)')); //Get different versions of the text for debugging const fullText = await element.getText(); //Check for the expected text in different ways const expectedText = 'Subject'; const trimmedFullText = fullText.trim(); const firstLine = trimmedFullText.split('\n')[0].trim(); //Try multiple matching strategies if (firstLine.includes(expectedText)) { console.log(`Passed: "${expectedText}" text found in first line`); } else if (trimmedFullText.includes(expectedText)) { console.log(`Passed: "${expectedText}" text found 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 } } }, //Subject dropdown value { description: 'Validate Subject dropdown value', action: async () => { const elementText = await driver.findElement(By.css('.list-group-item:nth-child(2) .multiselect-selected-text')).getText(); if (elementText !== 'None selected') { throw new Error(`Expected: Subject: "None selected" dropdown value did not match; Actual: "${elementText}"`); } console.log('Passed: Subject: None selected dropdown value matched as expected'); } }, //Alignment Status: { description: 'Validate Alignment Status label', action: async () => { try { const element = await driver.findElement(By.css('.list-group:nth-child(2) > .list-group-item:nth-child(3)')); //Get different versions of the text for debugging const fullText = await element.getText(); //Check for the expected text in different ways const expectedText = 'Alignment Status:'; const trimmedFullText = fullText.trim(); const firstLine = trimmedFullText.split('\n')[0].trim(); //Try multiple matching strategies if (firstLine.includes(expectedText)) { console.log(`Passed: "${expectedText}" text found in first line`); } else if (trimmedFullText.includes(expectedText)) { console.log(`Passed: "${expectedText}" text found 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 } } }, //Alignment Status dropdown value { description: 'Validate Alignment Status dropdown value', action: async () => { const elementText = await driver.findElement(By.css('.list-group-item:nth-child(3) .multiselect-selected-text')).getText(); if (elementText !== 'None selected') { throw new Error(`Expected: Alignment Status: "None selected" dropdown value did not match; Actual: "${elementText}"`); } console.log('Passed: Alignment Status: None selected dropdown value matched as expected'); } }, //NEXT ACTION - Click Grade dropdown { description: 'Click Grade dropdown', action: async () => await driver.findElement(By.css('.list-group-item:nth-child(1) .multiselect')).click() }, { description: 'Wait for action to complete', action: async () => await driver.sleep(2000) }, //Maginfying glass icon { description: 'Verify magnifying glass icon is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > .multiselect-item .input-group-prepend img')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Magnifying glass icon not found'); } console.log('Passed: Magnifying glass arrow icon present'); } }, //Search dropdown placeholder { description: 'Validate Search dropdown placeholder', action: async () => { const elementValue = await driver.findElement(By.css('.show > .multiselect-item .form-control')).getAttribute('placeholder'); if (elementValue !== 'Search') { throw new Error(`Expected: "Search" placeholder text; Actual: "${elementValue}"`); } console.log('Passed: "Search" placeholder text, matched as expected'); } }, //Seach X icon { description: 'Verify Grade, Search X icon is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.list-group-item:nth-child(1) .input-group-append img')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Grade, Search X icon not found'); } console.log('Passed: Grade, Search X icon present'); } }, //Grade: Select all checkbox { description: 'Verify Select all checkbox is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > .multiselect-item > .multiselect-all input')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Select all checkbox not found'); } console.log('Passed: Select all checkbox present'); } }, //Grade: Select all label { description: 'Validate Grade, Select all label', action: async () => { const elementText = await driver.findElement(By.css('.show > .multiselect-item .checkbox')).getText(); if (elementText !== 'Select all') { throw new Error(`Expected: "Select all" checkbox label; Actual: "${elementText}"`); } console.log('Passed: Select all checkbox label matched as expected'); } }, //Grade: 9 checkbox { description: 'Verify Grade 9 checkbox is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > li:nth-child(3) input')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Grade: 9 checkbox not found'); } console.log('Passed: Grade 9 checkbox present'); } }, //Grade: 9 (2424) label { description: 'Validate Grade 9 (2424) label', action: async () => { const elementText = await driver.findElement(By.css('.show > li:nth-child(3) .checkbox')).getText(); if (elementText !== '9 (2424)') { throw new Error(`Expected: Grade: "9 (2424)" checkbox label; Actual: "${elementText}"`); } console.log('Passed: Grade 9 (2424) checkbox label matched as expected'); } }, //Grade: 10 checkbox { description: 'Verify Grade 10 checkbox is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > li:nth-child(4) input')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Grade: 10 checkbox not found'); } console.log('Passed: Grade 10 checkbox present'); } }, //Grade: 10 (2384) label { description: 'Validate Grade 10 (2384) label', action: async () => { const elementText = await driver.findElement(By.css('.show > li:nth-child(4) .checkbox')).getText(); if (elementText !== '10 (2384)') { throw new Error(`Expected: Grade: "10 (2384)" checkbox label; Actual: "${elementText}"`); } console.log('Passed: Grade 10 (2384) checkbox label matched as expected'); } }, //Grade: 12 checkbox { description: 'Verify Grade 12 checkbox is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > li:nth-child(5) input')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Grade: 12 checkbox not found'); } console.log('Passed: Grade 12 checkbox present'); } }, //Grade: 12 (2282) label { description: 'Validate Grade 12 (2282) label', action: async () => { const elementText = await driver.findElement(By.css('.show > li:nth-child(5) .checkbox')).getText(); if (elementText !== '12 (2282)') { throw new Error(`Expected: Grade: "12 (2282)" checkbox label; Actual: "${elementText}"`); } console.log('Passed: Grade 12 (2282) checkbox label matched as expected'); } }, //Grade: 11 checkbox { description: 'Verify Grade 11 checkbox is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > li:nth-child(6) input')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Grade: 11 checkbox not found'); } console.log('Passed: Grade 11 checkbox present'); } }, //Grade: 11 (2208) label { description: 'Validate Grade 11 (2208) label', action: async () => { const elementText = await driver.findElement(By.css('.show > li:nth-child(6) .checkbox')).getText(); if (elementText !== '11 (2208)') { throw new Error(`Expected: Grade: "11 (2208)" checkbox label; Actual: "${elementText}"`); } console.log('Passed: Grade 11 (2208) checkbox label matched as expected'); } }, //NEXT ACTION - Select grade 8 { description: 'Select grade 8', action: async () => await driver.findElement(By.css('.show > li:nth-child(10) input')).click() }, { description: 'Wait for action to complete', action: async () => await driver.sleep(1000) }, //NEXT ACTION - CLick subject dropdown { description: 'Click Subject dropdown', action: async () => await driver.findElement(By.css('.list-group-item:nth-child(2) .multiselect-selected-text')).click() }, { description: 'Wait for action to complete', action: async () => await driver.sleep(2000) }, //Maginfying glass icon { description: 'Verify magnifying glass icon is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > .multiselect-item .input-group-prepend img')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Magnifying glass icon not found'); } console.log('Passed: Magnifying glass arrow icon present'); } }, //Search dropdown placeholder { description: 'Validate Search dropdown placeholder', action: async () => { const elementValue = await driver.findElement(By.css('.show > .multiselect-item .form-control')).getAttribute('placeholder'); if (elementValue !== 'Search') { throw new Error(`Expected: "Search" placeholder text; Actual: "${elementValue}"`); } console.log('Passed: "Search" placeholder text, matched as expected'); } }, //Seach X icon { description: 'Verify Search X icon is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.list-group-item:nth-child(1) .input-group-append img')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Search X icon not found'); } console.log('Passed: Search X icon present'); } }, //Select all checkbox { description: 'Verify Select all checkbox is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > .multiselect-item > .multiselect-all input')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Select all checkbox not found'); } console.log('Passed: Select all checkbox present'); } }, //Select all label { description: 'Validate Grade, Select all label', action: async () => { const elementText = await driver.findElement(By.css('.show > .multiselect-item .checkbox')).getText(); if (elementText !== 'Select all') { throw new Error(`Expected: "Select all" checkbox label; Actual: "${elementText}"`); } console.log('Passed: Select all checkbox label matched as expected'); } }, //Subject: Mathematics checkbox { description: 'Verify Subject Mathematics checkbox is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > li:nth-child(3) input')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Subject: Mathematics checkbox not found'); } console.log('Passed: Subject Mathematics checkbox present'); } }, //Subject: Mathematics (2011) label { description: 'Validate Subject Mathematics (2011) label', action: async () => { const elementText = await driver.findElement(By.css('.show > li:nth-child(3) .checkbox')).getText(); if (elementText !== 'Mathematics (2011)') { throw new Error(`Expected: Subject: "Mathematics (2011)" checkbox label; Actual: "${elementText}"`); } console.log('Passed: Subject Mathematics (2011) checkbox label matched as expected'); } }, //Subject: Science checkbox { description: 'Verify Subject Science checkbox is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > li:nth-child(4) input')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Subject: Science checkbox not found'); } console.log('Passed: Subject Science checkbox present'); } }, //Subject: Science (1066) label { description: 'Validate Subject Science (1066) label', action: async () => { const elementText = await driver.findElement(By.css('.show > li:nth-child(4) .checkbox')).getText(); if (elementText !== 'Science (1066)') { throw new Error(`Expected: Subject: "Science (1066)" checkbox label; Actual: "${elementText}"`); } console.log('Passed: Subject Science (1066) checkbox label matched as expected'); } }, //Subject: Language Arts checkbox { description: 'Verify Subject Language Arts checkbox is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > li:nth-child(5) input')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Subject: Language Arts checkbox not found'); } console.log('Passed: Subject Language Arts checkbox present'); } }, //Subject: Language Arts (416) label { description: 'Validate Subject Language Arts (416) label', action: async () => { const elementText = await driver.findElement(By.css('.show > li:nth-child(5) .checkbox')).getText(); if (elementText !== 'Language Arts (416)') { throw new Error(`Expected: Subject: "Language Arts (416)" checkbox label; Actual: "${elementText}"`); } console.log('Passed: Subject Language Arts (416) checkbox label matched as expected'); } }, //Subject: Social Studies checkbox { description: 'Verify Subject Social Studies checkbox is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > li:nth-child(6) input')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Subject: Social Studies checkbox not found'); } console.log('Passed: Subject Social Studies checkbox present'); } }, //Subject: Social Studies (102) label { description: 'Validate Subject Social Studies (102) label', action: async () => { const elementText = await driver.findElement(By.css('.show > li:nth-child(6) .checkbox')).getText(); if (elementText !== 'Social Studies (102)') { throw new Error(`Expected: Subject: "Social Studies (102)" checkbox label; Actual: "${elementText}"`); } console.log('Passed: Subject Social Studies (102) checkbox label matched as expected'); } }, //NEXT ACTION - Select subject Science and Social Studies { description: 'Select subject Science', action: async () => await driver.findElement(By.css('.show > li:nth-child(4) input')).click() }, { description: 'Select subject Social Studies', action: async () => await driver.findElement(By.css('.show > li:nth-child(6) input')).click() }, { description: 'Wait for action to complete', action: async () => await driver.sleep(1000) }, //NEXT ACTION - CLick alignment status dropdown { description: 'Click Alignment Status dropdown', action: async () => await driver.findElement(By.css('.list-group-item:nth-child(3) .multiselect-selected-text')).click() }, { description: 'Wait for action to complete', action: async () => await driver.sleep(2000) }, //Maginfying glass icon { description: 'Verify magnifying glass icon is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > .multiselect-item .input-group-prepend img')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Magnifying glass icon not found'); } console.log('Passed: Magnifying glass arrow icon present'); } }, //Search dropdown placeholder { description: 'Validate Search dropdown placeholder', action: async () => { const elementValue = await driver.findElement(By.css('.show > .multiselect-item .form-control')).getAttribute('placeholder'); if (elementValue !== 'Search') { throw new Error(`Expected: "Search" placeholder text; Actual: "${elementValue}"`); } console.log('Passed: "Search" placeholder text, matched as expected'); } }, //Seach X icon { description: 'Verify Search X icon is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.list-group-item:nth-child(1) .input-group-append img')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Search X icon not found'); } console.log('Passed: Search X icon present'); } }, //Select all checkbox { description: 'Verify Select all checkbox is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > .multiselect-item > .multiselect-all input')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Select all checkbox not found'); } console.log('Passed: Select all checkbox present'); } }, //Select all label { description: 'Validate Select all label', action: async () => { const elementText = await driver.findElement(By.css('.show > .multiselect-item .checkbox')).getText(); if (elementText !== 'Select all') { throw new Error(`Expected: "Select all" checkbox label; Actual: "${elementText}"`); } console.log('Passed: Select all checkbox label matched as expected'); } }, //Alignment Status: Not Aligned checkbox { description: 'Verify Alignment Status Not Aligned checkbox is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > li:nth-child(3) input')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Alignment Status: Not Aligned checkbox not found'); } console.log('Passed: Alignment Status Not Aligned checkbox present'); } }, //Alignment Status:Not Aligned (3286) label { description: 'Validate Alignment Status Not Aligned (3286) label', action: async () => { const elementText = await driver.findElement(By.css('.show > li:nth-child(3) .checkbox')).getText(); if (elementText !== 'Not Aligned (3286)') { throw new Error(`Expected: Alignment Status: "Not Aligned (3286)" checkbox label; Actual: "${elementText}"`); } console.log('Passed: Alignment Status Not Aligned (3286) checkbox label matched as expected'); } }, //Alignment Status: ECS Alignment checkbox { description: 'Verify Alignment Status ECS Alignment checkbox is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > li:nth-child(4) input')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Alignment Status: ECS Alignment checkbox not found'); } console.log('Passed: Alignment Status ECS Alignment checkbox present'); } }, //Alignment Status: ECS Alignment (244) label { description: 'Validate Alignment Status ECS Alignment (244) label', action: async () => { const elementText = await driver.findElement(By.css('.show > li:nth-child(4) .checkbox')).getText(); if (elementText !== 'ECS Alignment (244)') { throw new Error(`Expected: Alignment Status: "ECS Alignment (244)" checkbox label; Actual: "${elementText}"`); } console.log('Passed: Alignment Status ECS Alignment (244) checkbox label matched as expected'); } }, //Alignment Status: Pending checkbox { description: 'Verify Alignment Status Pending checkbox is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > li:nth-child(5) input')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Alignment Status: Pending checkbox not found'); } console.log('Passed: Alignment Status Pending checkbox present'); } }, //Alignment Status: Pending (13) label { description: 'Validate Alignment Status Pending (13) label', action: async () => { const elementText = await driver.findElement(By.css('.show > li:nth-child(5) .checkbox')).getText(); if (elementText !== 'Pending (13)') { throw new Error(`Expected: Alignment Status: "Pending (13)" checkbox label; Actual: "${elementText}"`); } console.log('Passed: Alignment Status Pending (13) checkbox label matched as expected'); } }, //Alignment Status: Aligned checkbox { description: 'Verify Alignment Status Aligned checkbox is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > li:nth-child(6) input')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Alignment Status: Aligned checkbox not found'); } console.log('Passed: Alignment Status Aligned checkbox present'); } }, //Alignment Status: Aligned (8) label { description: 'Validate Alignment Status Aligned (8) label', action: async () => { const elementText = await driver.findElement(By.css('.show > li:nth-child(6) .checkbox')).getText(); if (elementText !== 'Aligned (8)') { throw new Error(`Expected: Alignment Status: "Aligned (8)" checkbox label; Actual: "${elementText}"`); } console.log('Passed: Alignment Status Aligned (8) checkbox label matched as expected'); } }, //Alignment Status: Needs Review checkbox { description: 'Verify Alignment Status Needs Review checkbox is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.show > li:nth-child(7) input')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Alignment Status: Needs Review checkbox not found'); } console.log('Passed: Alignment Status Needs Review checkbox present'); } }, //Alignment Status: Needs Review (1) label { description: 'Validate Alignment Status Needs Review (1) label', action: async () => { const elementText = await driver.findElement(By.css('.show > li:nth-child(7) .checkbox')).getText(); if (elementText !== 'Needs Review (1)') { throw new Error(`Expected: Alignment Status: "Needs Review (1)" checkbox label; Actual: "${elementText}"`); } console.log('Passed: Alignment Status Needs Review (1) checkbox label matched as expected'); } }, //NEXT ACTION - Select alignment status Pending and Aligned then click main page to close DIV { description: 'Select alignment status Pending', action: async () => await driver.findElement(By.css('.show > li:nth-child(5) input')).click() }, { description: 'Select alignment status Aligned', action: async () => await driver.findElement(By.css('.show > li:nth-child(6) input')).click() }, { description: 'Wait for action to complete', action: async () => await driver.sleep(1000) }, { description: 'Click main window to close DIV', action: async () => await driver.findElement(By.css('#content form')).click() }, { description: 'Wait for action to complete', action: async () => await driver.sleep(1000) }, //VERIFY SELECTIONS //Grade: { description: 'Validate Grade label', action: async () => { try { const element = await driver.findElement(By.css('.list-group:nth-child(2) > .list-group-item:nth-child(1)')); //Get different versions of the text for debugging const fullText = await element.getText(); //Check for the expected text in different ways const expectedText = 'Grade:'; const trimmedFullText = fullText.trim(); const firstLine = trimmedFullText.split('\n')[0].trim(); //Try multiple matching strategies if (firstLine.includes(expectedText)) { console.log(`Passed: "${expectedText}" text found in first line`); } else if (trimmedFullText.includes(expectedText)) { console.log(`Passed: "${expectedText}" text found 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 } } }, //Grade: selection { description: 'Validate selected Grade option', action: async () => { const elementText = await driver.findElement(By.xpath('//*[@id="searchbox-content"]/ul/li[1]/div/button/span')).getText(); if (elementText !== '8 (1530)') { throw new Error(`Expected: Grade: "8 (1530)" option; Actual: "${elementText}"`); } console.log('Passed: Grade: "8 (1530)" option matched as expected'); } }, //Subject: { description: 'Validate Subject label', action: async () => { try { const element = await driver.findElement(By.css('.list-group:nth-child(2) > .list-group-item:nth-child(2)')); //Get different versions of the text for debugging const fullText = await element.getText(); //Check for the expected text in different ways const expectedText = 'Subject:'; const trimmedFullText = fullText.trim(); const firstLine = trimmedFullText.split('\n')[0].trim(); //Try multiple matching strategies if (firstLine.includes(expectedText)) { console.log(`Passed: "${expectedText}" text found in first line`); } else if (trimmedFullText.includes(expectedText)) { console.log(`Passed: "${expectedText}" text found 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 } } }, //Subject: selection { description: 'Validate selected Grade option', action: async () => { const elementText = await driver.findElement(By.xpath('//*[@id="searchbox-content"]/ul/li[2]/div/button/span')).getText(); if (elementText !== 'Science (1066), Social Studies (102)') { throw new Error(`Expected: Subject: "Science (1066), Social Studies (102)" option; Actual: "${elementText}"`); } console.log('Passed: Subject: "Science (1066), Social Studies (102)" option matched as expected'); } }, //Alignment Status: { description: 'Validate Alignment Status label', action: async () => { try { const element = await driver.findElement(By.css('.list-group:nth-child(2) > .list-group-item:nth-child(3)')); //Get different versions of the text for debugging const fullText = await element.getText(); //Check for the expected text in different ways const expectedText = 'Alignment Status:'; const trimmedFullText = fullText.trim(); const firstLine = trimmedFullText.split('\n')[0].trim(); //Try multiple matching strategies if (firstLine.includes(expectedText)) { console.log(`Passed: "${expectedText}" text found in first line`); } else if (trimmedFullText.includes(expectedText)) { console.log(`Passed: "${expectedText}" text found 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 } } }, //Alignment Status: selection { description: 'Validate selected Alignment Status option', action: async () => { const elementText = await driver.findElement(By.xpath('//*[@id="searchbox-content"]/ul/li[3]/div/button/span')).getText(); if (elementText !== 'Pending (13), Aligned (8)') { throw new Error(`Expected: Alignment Status: "Pending (13), Aligned (8)" option; Actual: "${elementText}"`); } console.log('Passed: Alignment Status: "Pending (13), Aligned (8)" option matched as expected'); } }, //Scroll to Biology - QA link { description: 'Scroll to Biology - QA link', action: async () => { const location = await driver.findElement(By.linkText('Biology - QA')); await driver.executeScript("arguments[0].scrollIntoView({block: 'center'});", location); } }, //NEXT ACTION - Navigate to Align page { description: 'Click Biology - QA link', action: async () => await driver.findElement(By.linkText('Biology - QA')).click() }, //Wait page to load { description: 'Wait for page to load', action: async () => { return await driver.wait(until.elementLocated(By.css('.well > b')), 10000).catch(() => false); } }, //FILTERS //Filter Results title { description: 'Validate Filter Results title', action: async () => { const elementText = await driver.findElement(By.css('.well > b')).getText(); if (elementText !== 'Filter Results') { throw new Error(`Expected: "Filter Results"; Actual: "${elementText}"`); } console.log('Passed: Filter Results title matched as expected'); } }, //Filter Results title font size { description: 'Validate Filter Results title font size', action: async () => { const elementText = await driver.findElement(By.css('.well > b')).getCssValue('font-size'); if (elementText !== '13px') { throw new Error(`Expected: Filter Results title font size to be "13px"; Actual: "${elementText}"`); } console.log('Passed: Filter Results title font size matched as expected'); } }, //Content Set title { description: 'Validate Content Set title', action: async () => { const elementText = await driver.findElement(By.css('.form-group:nth-child(1) > b')).getText(); if (elementText !== 'Content Set') { throw new Error(`Expected: "Content Set"; Actual: "${elementText}"`); } console.log('Passed: Content Set title matched as expected'); } }, //Content Set title font size { description: 'Validate Content Set title font size', action: async () => { const elementText = await driver.findElement(By.css('.form-group:nth-child(1) > b')).getCssValue('font-size'); if (elementText !== '13px') { throw new Error(`Expected: Content Set title font size to be "13px"; Actual: "${elementText}"`); } console.log('Passed: Content Set title font size matched as expected'); } }, //Biology - QA checkbox { description: 'Verify Biology - QA checkbox icon is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('#metaorgobjectid873576067')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Biology - QA checkbox icon not found'); } console.log('Passed: Biology - QA checkbox icon present'); } }, //Biology - QA count { description: 'Validate Biology - QA count', action: async () => { try { const element = await driver.findElement(By.css('.form-group:nth-child(1)')); //Get different versions of the text for debugging const fullText = await element.getText(); //Try XPath approach let xpathText; try { xpathText = await driver.findElement( By.xpath('//*[@id="facets"]/div[1]/text()') ).getText(); } catch (e) { xpathText = "XPath method failed: " + e.message; } //Check for the expected text in different ways const expectedText = 'Biology - QA (2)'; 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 if (xpathText.includes(expectedText)) { console.log('Passed: Found expected text via XPath method'); } else { throw new Error( `Text validation failed.\nExpected: "${expectedText}"\n` + `Full text: "${fullText}"\n` + `First line: "${firstLine}"\n` + `XPath result: "${xpathText}"` ); } } catch (error) { console.error('Detailed error during validation:', error); throw error; //Re-throw after logging } } }, //Grade title { description: 'Validate Grade title', action: async () => { try { const element = await driver.findElement(By.css('.form-group:nth-child(3) > b')); //Get different versions of the text for debugging const fullText = await element.getText(); //Check for the expected text in different ways const expectedText = 'Grade'; const trimmedFullText = fullText.trim(); const firstLine = trimmedFullText.split('\n')[0].trim(); //Try multiple matching strategies if (firstLine.includes(expectedText)) { console.log(`Passed: "${expectedText}" text found in first line`); } else if (trimmedFullText.includes(expectedText)) { console.log(`Passed: "${expectedText}" text found 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 } } }, //Grade title font size { description: 'Validate Grade title font size', action: async () => { const elementText = await driver.findElement(By.css('.form-group:nth-child(3) > b')).getCssValue('font-size'); if (elementText !== '13px') { throw new Error(`Expected: Grade title font size to be "13px"; Actual: "${elementText}"`); } console.log('Passed: Grade title font size matched as expected'); } }, //Grade: Clear link text { description: 'Validate Grade: Clear link text', action: async () => { const elementText = await driver.findElement(By.linkText('Clear')).getText(); if (elementText !== 'Clear') { throw new Error(`Expected: Grade: "Clear"; Actual: "${elementText}"`); } console.log('Passed: Grade Clear link text matched as expected'); } }, //Grade: See All link text { description: 'Validate Grade: See All link text', action: async () => { const elementText = await driver.findElement(By.linkText('See All>>')).getText(); if (elementText !== 'See All>>') { throw new Error(`Expected: Grade: "See All>>"; Actual: "${elementText}"`); } console.log('Passed: Grade See All>> link text matched as expected'); } }, //Grade: 6 checkbox { description: 'Verify Grade: 6 checkbox icon is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('#metagrades45')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Grade: 6 checkbox icon not found'); } console.log('Passed: Grade 6 checkbox icon present'); } }, //Grade: 6 label { description: 'Validate Grade: 6 label', action: async () => { const elementText = await driver.findElement(By.css('.form-group:nth-child(3) > label:nth-child(6)')).getText(); if (elementText !== '6') { throw new Error(`Expected: Grade: "6" label; Actual: "${elementText}"`); } console.log('Passed: Grade 6 label matched as expected'); } }, //Grade: 7 checkbox { description: 'Verify Grade: 7 checkbox icon is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('#metagrades47')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Grade: 7 checkbox icon not found'); } console.log('Passed: Grade 7 checkbox icon present'); } }, //Grade: 7 label { description: 'Validate Grade: 7 label', action: async () => { const elementText = await driver.findElement(By.css('label:nth-child(9)')).getText(); if (elementText !== '7') { throw new Error(`Expected: Grade: "7" label; Actual: "${elementText}"`); } console.log('Passed: Grade 7 label matched as expected'); } }, //Grade: 8 checkbox -active { description: 'Validate Grade: 8 checkbox option enabled', action: async () => { const elementStyle = await driver.findElement(By.css('#metagrades48')).getAttribute('checked'); if (elementStyle !== 'true') { throw new Error(`Grade: 8 checkbox option value checked did not match; Actual: "${elementStyle}"`); } console.log('Passed: Grade 8 checkbox option value matched as expected'); } }, //Grade: 8 label { description: 'Validate Grade: 8 label', action: async () => { const elementText = await driver.findElement(By.css('label:nth-child(12)')).getText(); if (elementText !== '8') { throw new Error(`Expected: Grade: "8" label; Actual: "${elementText}"`); } console.log('Passed: Grade 8 label matched as expected'); } }, //Grade: 9 checkbox { description: 'Verify Grade: 9 checkbox icon is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('#metagrades49')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Grade: 9 checkbox icon not found'); } console.log('Passed: Grade 9 checkbox icon present'); } }, //Grade: 9 label { description: 'Validate Grade: 9 label', action: async () => { const elementText = await driver.findElement(By.css('label:nth-child(15)')).getText(); if (elementText !== '9') { throw new Error(`Expected: Grade: "9" label; Actual: "${elementText}"`); } console.log('Passed: Grade 9 label matched as expected'); } }, //Grade: 10 checkbox { description: 'Verify Grade: 10 checkbox icon is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('#metagrades51')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Grade: 10 checkbox icon not found'); } console.log('Passed: Grade 10 checkbox icon present'); } }, //Grade: 10 label { description: 'Validate Grade: 10 label', action: async () => { const elementText = await driver.findElement(By.css('label:nth-child(18)')).getText(); if (elementText !== '10') { throw new Error(`Expected: Grade: "10" label; Actual: "${elementText}"`); } console.log('Passed: Grade 10 label matched as expected'); } }, //More link { description: 'Validate More link', action: async () => { const elementText = await driver.findElement(By.linkText('More>>')).getText(); if (elementText !== 'More>>') { throw new Error(`Expected: "More>>"; Actual: "${elementText}"`); } console.log('Passed: More>> link matched as expected'); } }, //Subject title { description: 'Validate Subject title', action: async () => { const elementText = await driver.findElement(By.css('.form-group:nth-child(6) > b')).getText(); if (elementText !== 'Subject') { throw new Error(`Expected: "Subject"; Actual: "${elementText}"`); } console.log('Passed: Subject title matched as expected'); } }, //Subject title font size { description: 'Validate Subject title font size', action: async () => { const elementText = await driver.findElement(By.css('.form-group:nth-child(6) > b')).getCssValue('font-size'); if (elementText !== '13px') { throw new Error(`Expected: Subject title font size to be "13px"; Actual: "${elementText}"`); } console.log('Passed: Subject title font size matched as expected'); } }, //Subject: Clear link text { description: 'Validate Subject: Clear link text', action: async () => { const elementText = await driver.findElement(By.css('.form-group:nth-child(6) > small > a')).getText(); if (elementText !== 'Clear') { throw new Error(`Expected: Subject: "Clear"; Actual: "${elementText}"`); } console.log('Passed: Subject Clear link text matched as expected'); } }, //Subject: See All link text { description: 'Validate Subject: See All link text', action: async () => { const elementText = await driver.findElement(By.css('.form-group:nth-child(6) .modalink')).getText(); if (elementText !== 'See All>>') { throw new Error(`Expected: Subject: "See All>>"; Actual: "${elementText}"`); } console.log('Passed: Subject See All>> link text matched as expected'); } }, //Subject: Science checkbox -active { description: 'Validate Subject: Science checkbox option enabled', action: async () => { const elementStyle = await driver.findElement(By.css('#metasubjectsScience')).getAttribute('checked'); if (elementStyle !== 'true') { throw new Error(`Subject: Science checkbox option value checked did not match; Actual: "${elementStyle}"`); } console.log('Passed: Subject Science checkbox option value matched as expected'); } }, //Subject: Science label { description: 'Validate Subject: Science label', action: async () => { const elementText = await driver.findElement(By.css('.form-group:nth-child(6) > label')).getText(); if (elementText !== 'Science') { throw new Error(`Expected: Subject: "Science" label; Actual: "${elementText}"`); } console.log('Passed: Subject Science label matched as expected'); } }, //Alignment Status title { description: 'Validate Alignment Status title', action: async () => { const elementText = await driver.findElement(By.css('.form-group:nth-child(8) > b')).getText(); if (elementText !== 'Alignment Status') { throw new Error(`Expected: "Alignment Status" title; Actual: "${elementText}"`); } console.log('Passed: Alignment Status title matched as expected'); } }, //Alignment Status title font size { description: 'Validate Alignment Status title font size', action: async () => { const elementText = await driver.findElement(By.css('.form-group:nth-child(8) > b')).getCssValue('font-size'); if (elementText !== '13px') { throw new Error(`Expected: Alignment Status title font size to be "13px"; Actual: "${elementText}"`); } console.log('Passed: Alignment Status title font size matched as expected'); } }, //Alignment Status: Clear link text { description: 'Validate Alignment Status: Clear link text', action: async () => { const elementText = await driver.findElement(By.css('.form-group:nth-child(8) > small > a')).getText(); if (elementText !== 'Clear') { throw new Error(`Expected: Alignment Status: "Clear"; Actual: "${elementText}"`); } console.log('Passed: Alignment Status Clear link text matched as expected'); } }, //Alignment Status: See All link text { description: 'Validate Alignment Status: See All link text', action: async () => { const elementText = await driver.findElement(By.css('.form-group:nth-child(8) .modalink')).getText(); if (elementText !== 'See All>>') { throw new Error(`Expected: Alignment Status: "See All>>"; Actual: "${elementText}"`); } console.log('Passed: Alignment Status See All>> link text matched as expected'); } }, //Alignment Status: Pending checkbox -active { description: 'Validate Alignment Status: Pending checkbox option enabled', action: async () => { const elementStyle = await driver.findElement(By.css('#metaAlignmentStatusPending')).getAttribute('checked'); if (elementStyle !== 'true') { throw new Error(`Alignment Status: Pending checkbox option value checked did not match; Actual: "${elementStyle}"`); } console.log('Passed: Alignment Status Pending checkbox option value matched as expected'); } }, //Pending label { description: 'Validate Pending label', action: async () => { const elementText = await driver.findElement(By.css('.form-group:nth-child(8) > label')).getText(); if (elementText !== 'Pending') { throw new Error(`Expected: "Pending"; Actual: "${elementText}"`); } console.log('Passed: Pending label matched as expected'); } }, //Reset All link { description: 'Validate Reset All link', action: async () => { const elementText = await driver.findElement(By.linkText('Reset All')).getText(); if (elementText !== 'Reset All') { throw new Error(`Expected: "Reset All"; Actual: "${elementText}"`); } console.log('Passed: Reset All link matched as expected'); } }, //CONTENT RESULTS - PAGINATION ROW //Home link { description: 'Validate Home link', action: async () => { const elementText = await driver.findElement(By.linkText('Home')).getText(); if (elementText !== 'Home') { throw new Error(`Expected: "Home"; Actual: "${elementText}"`); } console.log('Passed: Home link matched as expected'); } }, //Content breadcrumb { description: 'Validate Content breadcrumb', action: async () => { const elementText = await driver.findElement(By.css('.breadcrumb-item:nth-child(2)')).getText(); if (elementText !== 'Content') { throw new Error(`Expected: "Content"; Actual: "${elementText}"`); } console.log('Passed: Content link matched as expected'); } }, //Detail View button { description: 'Validate Detail View button text', action: async () => { const elementText = await driver.findElement(By.linkText('Detail View')).getText(); if (elementText !== 'Detail View') { throw new Error(`Expected: "Detail View" button text; Actual: "${elementText}"`); } console.log('Passed: Detail View button text matched as expected'); } }, //Detail View button color -green { description: 'Validate Detail View button color', action: async () => { const elementStyle = await driver.findElement(By.linkText('Detail View')).getCssValue('background-color'); if (elementStyle !== 'rgba(48, 200, 172, 1)') { throw new Error(`Detail View button color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Detail View button color matched as expected'); } }, //Edit View button { description: 'Validate Edit View button text', action: async () => { const elementText = await driver.findElement(By.linkText('Edit View')).getText(); if (elementText !== 'Edit View') { throw new Error(`Expected: "Edit View" button text; Actual: "${elementText}"`); } console.log('Passed: Edit View button text matched as expected'); } }, //Edit View button color -green { description: 'Validate Edit View button color', action: async () => { const elementStyle = await driver.findElement(By.linkText('Edit View')).getCssValue('background-color'); if (elementStyle !== 'rgba(248, 249, 250, 1)') { throw new Error(`Edit View button color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Edit View button color matched as expected'); } }, //Save icon { description: 'Verify Save icon is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.float-right > a:nth-child(1) > img')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Save icon not found'); } console.log('Passed: Save icon present'); } }, //Save icon tool-tip { description: 'Validate Save icon tool-tip', action: async () => { const elementStyle = await driver.findElement(By.css('body > div.container.body > div > div.right_col > div > div > div.col-xs-12.col-sm-9 > div.float-right.ml-1 > a:nth-child(1)')).getAttribute('title'); if (elementStyle !== 'Save This Search') { throw new Error(`Expected: "Save This Search"; Actual: "${elementStyle}"`); } console.log('Passed: Save This Search tool-tip matched as expected'); } }, //Print icon { description: 'Verify Print icon is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.icon-link > img')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Print icon not found'); } console.log('Passed: Print icon present'); } }, //Printicon tool-tip { description: 'Validate Print icon tool-tip', action: async () => { const elementStyle = await driver.findElement(By.css('.icon-link > img')).getAttribute('title'); if (elementStyle !== 'Print This Page') { throw new Error(`Expected: "Print This Page"; Actual: "${elementStyle}"`); } console.log('Passed: Print This Page tool-tip matched as expected'); } }, //APPLIED FILTERS //Grade8 filter button { description: 'Validate Grade 8 filter button text', action: async () => { const elementText = await driver.findElement(By.css('.badge')).getText(); if (elementText !== 'Grade: 8') { throw new Error(`Expected: "Grade: 8" text did not match; Actual: "${elementText}"`); } console.log('Passed: Grade 8 text matched as expected'); } }, //Grade8 filter button color -dark gray { description: 'Verify Grade 8 filter buttion close icon color', action: async () => { const elementStyle = await driver.findElement(By.css('.badge')).getCssValue('background-color'); if (elementStyle !== 'rgba(108, 117, 125, 1)') { throw new Error(`Expected: Grade: 8 button color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Grade 8 button color matched as expected'); } }, //Grade8 filter button close icon color -red { description: 'Verify Grade 8 filter buttion close icon color', action: async () => { const elementStyle = await driver.findElement(By.css('.glyphicon')).getCssValue('color'); if (elementStyle !== 'rgba(255, 0, 0, 1)') { throw new Error(`Expected: Grade: 8 button close icon color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Grade 8 button close icon color matched as expected'); } }, //Subject Science filter button { description: 'Validate Subject Science filter button text', action: async () => { const elementText = await driver.findElement(By.css('.badge:nth-child(4)')).getText(); if (elementText !== 'Subject: Science') { throw new Error(`Expected: "Subject: Science" text did not match; Actual: "${elementText}"`); } console.log('Passed: Subject Science text matched as expected'); } }, //Subject Science filter button color -dark gray { description: 'Verify Subject Science filter buttion close icon color', action: async () => { const elementStyle = await driver.findElement(By.css('.badge:nth-child(4)')).getCssValue('background-color'); if (elementStyle !== 'rgba(108, 117, 125, 1)') { throw new Error(`Expected: Subject: Science button color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Subject Science button color matched as expected'); } }, //Subject Science button close icon color -red { description: 'Verify Subject Science filter buttion close icon color', action: async () => { const elementStyle = await driver.findElement(By.css('.badge:nth-child(4) .glyphicon')).getCssValue('color'); if (elementStyle !== 'rgba(255, 0, 0, 1)') { throw new Error(`Expected: Subject: Science button close icon color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Subject Science button close icon color matched as expected'); } }, //Subject Social Studies filter button { description: 'Validate Subject Social Studies filter button text', action: async () => { const elementText = await driver.findElement(By.css('.badge:nth-child(5)')).getText(); if (elementText !== 'Subject: Social Studies') { throw new Error(`Expected: "Subject: Social Studies" text did not match; Actual: "${elementText}"`); } console.log('Passed: Subject Social Studies text matched as expected'); } }, //Subject Social Studies filter button color -dark gray { description: 'Verify Subject Social Studies filter buttion close icon color', action: async () => { const elementStyle = await driver.findElement(By.css('.badge:nth-child(5)')).getCssValue('background-color'); if (elementStyle !== 'rgba(108, 117, 125, 1)') { throw new Error(`Expected: Subject: Social Studies button color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Subject Social Studies button color matched as expected'); } }, //Subject Social Studies button close icon color -red { description: 'Verify Subject Social Studies filter buttion close icon color', action: async () => { const elementStyle = await driver.findElement(By.css('.badge:nth-child(5) .glyphicon')).getCssValue('color'); if (elementStyle !== 'rgba(255, 0, 0, 1)') { throw new Error(`Expected: Subject: Social Studies button close icon color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Subject Social Studies button close icon color matched as expected'); } }, //Alignment Status Pending filter button { description: 'Validate Alignment Status Pending filter button text', action: async () => { const elementText = await driver.findElement(By.css('.badge:nth-child(6)')).getText(); if (elementText !== 'Alignment Status: Pending') { throw new Error(`Expected: "Alignment Status: Pending" text did not match; Actual: "${elementText}"`); } console.log('Passed: Alignment Status Pending text matched as expected'); } }, //Alignment Status Pending filter button color -dark gray { description: 'Verify Alignment Status Pending filter buttion close icon color', action: async () => { const elementStyle = await driver.findElement(By.css('.badge:nth-child(6)')).getCssValue('background-color'); if (elementStyle !== 'rgba(108, 117, 125, 1)') { throw new Error(`Expected: Alignment Status: Pending button color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Alignment Status Pending button color matched as expected'); } }, //Alignment Status Pending button close icon color -red { description: 'Verify Alignment Status Pending filter buttion close icon color', action: async () => { const elementStyle = await driver.findElement(By.css('.badge:nth-child(6) .glyphicon')).getCssValue('color'); if (elementStyle !== 'rgba(255, 0, 0, 1)') { throw new Error(`Expected: Alignment Status: Pending button close icon color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Alignment Status Pending button close icon color matched as expected'); } }, //Alignment Status Aligned filter button { description: 'Validate Alignment Status Aligned filter button text', action: async () => { const elementText = await driver.findElement(By.css('.badge:nth-child(7)')).getText(); if (elementText !== 'Alignment Status: Aligned') { throw new Error(`Expected: "Alignment Status: Aligned" text did not match; Actual: "${elementText}"`); } console.log('Passed: Alignment Status Aligned text matched as expected'); } }, //Alignment Status Aligned filter button color -dark gray { description: 'Verify Alignment Status Aligned filter buttion close icon color', action: async () => { const elementStyle = await driver.findElement(By.css('.badge:nth-child(7)')).getCssValue('background-color'); if (elementStyle !== 'rgba(108, 117, 125, 1)') { throw new Error(`Expected: Alignment Status: Aligned button color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Alignment Status Aligned button color matched as expected'); } }, //Alignment Status Aligned button close icon color -red { description: 'Verify Alignment Status Aligned filter buttion close icon color', action: async () => { const elementStyle = await driver.findElement(By.css('.badge:nth-child(7) .glyphicon')).getCssValue('color'); if (elementStyle !== 'rgba(255, 0, 0, 1)') { throw new Error(`Expected: Alignment Status: Aligned button close icon color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Alignment Status Aligned button close icon color matched as expected'); } }, //Filtered Results 2-2 of 2 label (top) { description: 'Validate Filtered Results 1-2 of 2 label', action: async () => { const elementText = await driver.findElement(By.css('.float-left:nth-child(10)')).getText(); if (elementText !== 'Results 1 - 2 of 2') { throw new Error(`Expected: Filtered "Results 1 - 2 of 2" label; Actual: "${elementText}"`); } console.log('Passed: Filtered Results 1 - 2 of 2 label matched as expected'); } }, //CONTENT RESULTS - CONTENT ITEMS //Filtered Content 1 Title { description: 'Validate Content 1 title', action: async () => { const elementText = await driver.findElement(By.linkText('All Species Inventory')).getText(); if (elementText !== 'All Species Inventory') { throw new Error(`Expected: Filtered Content 1 item "All Species Inventory" title; Actual: "${elementText}"`); } console.log('Passed: Filtered Content 1 item All Species Inventory tittle matched as expected'); } }, //Filtered Content 1 edit icon { description: 'Verify Filtered Content 1 edit icon is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.card:nth-child(12) .lo-title .fa')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Filtered Content 1 edit icon not found'); } console.log('Passed: Filtered Content 1 edit icon present'); } }, //Filtered Content 1 edit button text { description: 'Validate Filtered Content 1 edit button text', action: async () => { const elementText = await driver.findElement(By.css('.card:nth-child(12) .ml-3')).getText(); if (elementText !== 'Edit') { throw new Error(`Expected: Filtered Content 1 "Edit" button text; Actual: "${elementText}"`); } console.log('Passed: Filtered Content 1 Edit button text matched as expected'); } }, //Filtered Content 1 edit button color -green { description: 'Validate Filtered Content 1 Edit button color', action: async () => { const elementStyle = await driver.findElement(By.css('.card:nth-child(12) .ml-3')).getCssValue('background-color'); if (elementStyle !== 'rgba(48, 200, 172, 1)') { throw new Error(`Expected: Filtered Content 1 Edit button color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Filtered Content 1 Edit button color matched as expected'); } }, //Filtered Content 1 description { description: 'Validate Filtered Content 1 description', action: async () => { try { const element = await driver.findElement(By.css('.card:nth-child(12) .lo-descr')); //Get different versions of the text for debugging const fullText = await element.getText(); //Check for the expected text in different ways const expectedText = `In this Science Update, from Science NetLinks, you'll hear an interview with Kevin Kelly, co-founder and board chairman of the All Species Foundation in San Francisco. Kelly discusses his mission to discover, identify, and document every species on Earth within the next 25 years. Students then read more information about the project, and conclude by answering some related questions. Science Updates are audio interviews with scientists and are accompanied by a set of questions as well as links to related Science NetLinks lessons and other related resources.`; const trimmedFullText = fullText.trim(); const firstLine = trimmedFullText.split('\n')[0].trim(); //Try multiple matching strategies if (firstLine.includes(expectedText)) { console.log(`Passed: "In this Science Update, from Science NetLinks, you'll hear..." text found in first line`); } else if (trimmedFullText.includes(expectedText)) { console.log(`Passed: "In this Science Update, from Science NetLinks, you'll hear..." text found 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 } } }, //Filtered Content 1 content set label { description: 'Validate Filtered Content 1 content set label', action: async () => { const elementText = await driver.findElement(By.css('.card:nth-child(12) small')).getText(); if (elementText !== 'Content Set: Biology - QA') { throw new Error(`Expected: Filtered Content 1 content set label did not match; Actual: "${elementText}"`); } console.log('Passed: Filtered Content 1 content set label matched as expected'); } }, //Filtered Content 1 alignment label { description: 'Validate Filtered Content 1 Alignment Pending label', action: async () => { const elementText = await driver.findElement(By.css('#alignstatuslink873578654 > .display-alignment')).getText(); if (elementText !== 'Alignment Pending (reset)') { throw new Error(`Expected: Filtered Content 1 Alignment Pending (reset) label did not match; Actual: "${elementText}"`); } console.log('Passed: Filtered Content 1 Alignment Pending (reset) label matched as expected'); } }, //Filtered Content 1 alignment reset label { description: 'Validate Filtered Content 1 Alignment Pending reset label', action: async () => { const elementText = await driver.findElement(By.css('#alignstatuslink873578654 b')).getText(); if (elementText !== 'reset') { throw new Error(`Expected: Filtered Content 1 Alignment Pending reset label did not match; Actual: "${elementText}"`); } console.log('Passed: Filtered Content 1 Alignment Pending reset label matched as expected'); } }, //Filtered Content 1 view standards button icon { description: 'Verify Content 1 View Standards button icon is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.card:nth-child(12) .well .fa')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Content 1 View Standards button icon not found'); } console.log('Passed: Content 1 View Standards button icon present'); } }, //Filtered Content 1 view standards button text { description: 'Validate Content 1 View Standards button text', action: async () => { const elementText = await driver.findElement(By.css('.card:nth-child(12) .well > .btn')).getText(); if (elementText !== 'View Standards') { throw new Error(`Expected: Content 1 View Standards button text did not match; Actual: "${elementText}"`); } console.log('Passed: Content 1 View Standards button text matched as expected'); } }, //Filtered Content 1 view standards button color -green { description: 'Validate Content 1 view standards button color', action: async () => { const elementStyle = await driver.findElement(By.css('.card:nth-child(12) .well > .btn')).getCssValue('background-color'); if (elementStyle !== 'rgba(48, 200, 172, 1)') { throw new Error(`Expected: Content 1 View Standards button color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Content 1 View Standards button color matched as expected'); } }, //Filtered Content 2 Title { description: 'Validate Filtered Content 2 title', action: async () => { const elementText = await driver.findElement(By.linkText('Andrew Skurka: Trekking the Wild North')).getText(); if (elementText !== 'Andrew Skurka: Trekking the Wild North') { throw new Error(`Expected: Filtered Content 2 item "Andrew Skurka: Trekking the Wild North" title; Actual: "${elementText}"`); } console.log('Passed: Filtered Content 2 item Andrew Skurka: Trekking the Wild North tittle matched as expected'); } }, //Filtered Content 2 edit icon { description: 'Verify Content 2 edit icon is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.card:nth-child(13) .lo-title .fa')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Content 2 edit icon not found'); } console.log('Passed: Content 2 edit icon present'); } }, //Filtered Content 2 edit button text { description: 'Validate pagination Show All button text', action: async () => { const elementText = await driver.findElement(By.css('.card:nth-child(13) .ml-3')).getText(); if (elementText !== 'Edit') { throw new Error(`Expected: Content 2 "Edit" button text; Actual: "${elementText}"`); } console.log('Passed: Content 2 Edit button text matched as expected'); } }, //Filtered Content 2 edit button color -green { description: 'Validate Content 2 Edit button color', action: async () => { const elementStyle = await driver.findElement(By.css('.card:nth-child(13) .ml-3')).getCssValue('background-color'); if (elementStyle !== 'rgba(48, 200, 172, 1)') { throw new Error(`Expected: Content 2 Edit button color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Content 2 Edit button color matched as expected'); } }, //Filtered Content 2 description { description: 'Validate Filtered Content 2 description', action: async () => { try { const element = await driver.findElement(By.css('.card:nth-child(13) .lo-descr')); //Get different versions of the text for debugging const fullText = await element.getText(); //Check for the expected text in different ways const expectedText = 'Video. From the Best of NG Live Collection: Get the inside story of the gear and the grit needed by National Geographic grantee Andrew Skurka for his six-month, 4,700-mile expedition through Alaska and the Yukon.'; const trimmedFullText = fullText.trim(); const firstLine = trimmedFullText.split('\n')[0].trim(); //Try multiple matching strategies if (firstLine.includes(expectedText)) { console.log('Passed: "Video. From the Best of NG Live Collection: Get the inside story..." text found in first line'); } else if (trimmedFullText.includes(expectedText)) { console.log('Passed: "Video. From the Best of NG Live Collection: Get the inside story..." text found 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 } } }, //Filtered Content 2 content set label { description: 'Validate Filtered Content 2 content set label', action: async () => { const elementText = await driver.findElement(By.css('.card:nth-child(13) small')).getText(); if (elementText !== 'Content Set: Biology - QA') { throw new Error(`Expected: Filtered Content 2 content set label did not match; Actual: "${elementText}"`); } console.log('Passed: Filtered Content 2 content set label matched as expected'); } }, //Filtered Content 2 alignment label { description: 'Validate Filtered Content 2 Alignment Pending label', action: async () => { const elementText = await driver.findElement(By.css('#alignstatuslink873578658 > .display-alignment')).getText(); if (elementText !== 'Alignment Pending (reset)') { throw new Error(`Expected: Filtered Content 2 Alignment Pending (reset) label did not match; Actual: "${elementText}"`); } console.log('Passed: Filtered Content 2 Alignment Pending (reset) label matched as expected'); } }, //Filtered Content 2 alignment reset label { description: 'Validate Filtered Content 2 Alignment Pending reset label', action: async () => { const elementText = await driver.findElement(By.css('#alignstatuslink873578658 b')).getText(); if (elementText !== 'reset') { throw new Error(`Expected: Filtered Content 2 Alignment Pending reset label did not match; Actual: "${elementText}"`); } console.log('Passed: Filtered Content 2 Alignment Pending reset label matched as expected'); } }, //Filtered Content 2 view standards button icon { description: 'Verify Content 2 View Standards button icon is present', action: async () => { const expectedIcon = await driver.wait(until.elementLocated(By.css('.card:nth-child(13) .well .fa')), 5000).catch(() => false); if (!expectedIcon) { throw new Error('Content 2 View Standards button icon not found'); } console.log('Passed: Content 2 View Standards button icon present'); } }, //Filtered Content 2 view standards button text { description: 'Validate Content 2 View Standards button text', action: async () => { const elementText = await driver.findElement(By.css('.card:nth-child(13) .well > .btn')).getText(); if (elementText !== 'View Standards') { throw new Error(`Expected: Content 2 View Standards button text did not match; Actual: "${elementText}"`); } console.log('Passed: Content 2 View Standards button text matched as expected'); } }, //Filtered Content 2 view standards button color -green { description: 'Validate Content 2 view standards button color', action: async () => { const elementStyle = await driver.findElement(By.css('.card:nth-child(13) .well > .btn')).getCssValue('background-color'); if (elementStyle !== 'rgba(48, 200, 172, 1)') { throw new Error(`Expected: Content 2 View Standards button color did not match; Actual: "${elementStyle}"`); } console.log('Passed: Content 2 View Standards button color matched as expected'); } }, //Filtered Results 2-2 of 2 label (bottom) { description: 'Validate Filtered Results 1-2 of 2 label', action: async () => { const elementText = await driver.findElement(By.css('.float-left:nth-child(15)')).getText(); if (elementText !== 'Results 1 - 2 of 2') { throw new Error(`Expected: Filtered "Results 1 - 2 of 2" label; Actual: "${elementText}"`); } console.log('Passed: Filtered Results 1 - 2 of 2 label matched as expected'); } }, */ //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', 'alignContentPage'); 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', 'alignContentPage'); if (fs.existsSync(screenshotDir)) { fs.rmSync(screenshotDir, { recursive: true, force: true }); } fs.mkdirSync(screenshotDir, { recursive: true }); //Remove old Excel file if (fs.existsSync('alignContentPageResults.xlsx')) { fs.unlinkSync('alignContentPageResults.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; 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: Align - Content Page(alignContentPage); All test steps completed successfully'); testStatus = 'Passed'; } else { console.log('------------->| THE END |<-------------'); console.log('FAILED: Align - Content Page(alignContentPage); 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, 'alignContentPageResults.xlsx'); } finally { await driver.quit(); } })(); } export default alignContentPage;