import { Builder, By, Key, until } from 'selenium-webdriver';
import fs from 'fs';
import XLSX from 'xlsx';
import path from 'path';
const ExACT_contentPage = (req, res) => {
res.send('
ExACT Automated Test Script - Content Page: Initiated
');
(async function example() {
let driver = await new Builder().forBrowser('chrome').build();
let testStatus = 'Failed';
let workbook;
let worksheet;
const startTime = new Date().toISOString();
//Constants
const createContentSetName = 'Automated - QA Content Set - To be deleted';
const steps = [
{ description: 'Navigate to ExACT Landing Page', action: async () => await driver.navigate().to('https://stage.edgate.com/exact/login.php') }, //PROD - https://correlation.edgate.com/exact/login.php
{ description: 'Expand browser', action: async () => await driver.manage().window().maximize() },
//LOGIN
{ description: 'Enter username', action: async () => await driver.findElement(By.css('.form-control:nth-child(2)')).sendKeys('exact_juan') },
{ description: 'Enter password', action: async () => await driver.findElement(By.css('.passfield')).sendKeys('Edgate1!') },
{ description: 'Click Login button', action: async () => await driver.findElement(By.css('.login')).click() },
{ description: 'Wait for login process to complete', action: async () => await driver.sleep(10000) },
//Wait for dashboard to load - Correlation Coverages View Details button
{
description: 'Wait for dashboard load to completely',
action: async () => {
return await driver.wait(until.elementLocated(By.linkText('View Details')), 10000).catch(() => false);
}
},
//Dashboard title
{
description: 'Validate dashboard title',
action: async () => {
const elementText = await driver.findElement(By.css('.e-heading')).getText();
if (elementText !== 'Correlation Dashboard') {
throw new Error(`Expected: "Correlation Dashboard"; Actual: "${elementText}"`);
}
console.log('Passed: Dashboard title matched as expected');
}
},
//Dashboard title text color -dark blue
{
description: 'Validate dashboard title text color',
action: async () => {
const elementStyle = await driver.findElement(By.css('.e-heading')).getCssValue('color');
if (elementStyle !== 'rgba(40, 39, 90, 1)') {
throw new Error(`Dashboard title text color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Dashboard title text color matched as expected');
}
},
//Dashboard title text font
{
description: 'Validate dashboard title text font size',
action: async () => {
const elementStyle = await driver.findElement(By.css('.e-heading')).getCssValue('font-size');
if (elementStyle !== '32px') {
throw new Error(`Dashboard title text font-size did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Dashboard title text font-size matched as expected');
}
},
//MY CONTENT WIDGET
//Dashboard My Content Widget title
{
description: 'Validate dashboard My Content widget title',
action: async () => {
const elementText = await driver.findElement(By.css('.h-100 h2:nth-child(2)')).getText();
if (elementText !== 'My Content') {
throw new Error(`Expected: "My Content"; Actual: "${elementText}"`);
}
console.log('Passed: Dashboard - My Content Widget title matched as expected');
}
},
//Dashboard My Content Widget title text color -dark blue
{
description: 'Validate dashboard My Content widget title text color',
action: async () => {
const elementStyle = await driver.findElement(By.css('.h-100 h2:nth-child(2)')).getCssValue('color');
if (elementStyle !== 'rgba(40, 39, 90, 1)') {
throw new Error(`Dashboard - My Content Widget title text color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Dashboard - My Content Widget title text color matched as expected');
}
},
//Dashboard My Content Widget title text font
{
description: 'Validate dashboard My Content widget title text font size',
action: async () => {
const elementStyle = await driver.findElement(By.css('.h-100 h2:nth-child(2)')).getCssValue('font-size');
if (elementStyle !== '18px') {
throw new Error(`Dashboard - My Content Widget title text font-size did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Dashboard - My Content Widget title text font-size matched as expected');
}
},
//Dashboard My Content Item Count
{
description: 'Validate Dashboard My Content Item Count',
action: async () => {
const elementText = await driver.findElement(By.css('#badge_content_total')).getText();
if (elementText !== '3527 items') {
throw new Error(`Expected: "3527 items"; Actual: "${elementText}"`);
}
console.log('Passed: Dashboard - My Content Item Count matched as expected');
}
},
//Dashboard My Content Item Count button color -dark blue
{
description: 'Validate Dashboard My Content Item Count button color',
action: async () => {
const elementStyle = await driver.findElement(By.css('#badge_content_total')).getCssValue('background-color');
if (elementStyle !== 'rgba(40, 39, 90, 1)') {
throw new Error(`Dashboard - My Content Item Count button color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Dashboard - My Content Item Count button color matched as expected');
}
},
//Dashboard My Content Item Count text color -white
{
description: 'Validate Dashboard My Content Item Count font color',
action: async () => {
const elementStyle = await driver.findElement(By.css('#badge_content_total')).getCssValue('color');
if (elementStyle !== 'rgba(255, 255, 255, 1)') {
throw new Error(`Dashboard - My Content Item Count font color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Dashboard - My Content Item Count font color matched as expected');
}
},
//Ellipsis icon color -dark blue
{
description: 'Validate ellipsis icon color',
action: async () => {
const elementStyle = await driver.findElement(By.css('.fa-ellipsis-h')).getCssValue('color');
if (elementStyle !== 'rgba(40, 39, 90, 1)') {
throw new Error(`Ellipsis icon color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Ellipsis icon color matched as expected');
}
},
//Search icon color -dark blue
{
description: 'Validate search icon color',
action: async () => {
const elementStyle = await driver.findElement(By.css('.col-12 > .fa')).getCssValue('color');
if (elementStyle !== 'rgba(40, 39, 90, 1)') {
throw new Error(`Search icon color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Search icon color matched as expected');
}
},
//Filter textbox placeholder
{
description: 'Validate Filter placeholder text',
action: async () => {
const elementValue = await driver.findElement(By.css('#content-org-filter')).getAttribute('placeholder');
if (elementValue !== 'filter...') {
throw new Error(`Expected: "filter..."; Actual: "${elementValue}"`);
}
console.log('Passed: Filter placeholder text matched as expected');
}
},
//Sort label
{
description: 'Validate sort label',
action: async () => {
const elementText = await driver.findElement(By.css('.col-4')).getText();
if (elementText !== 'Sort:') {
throw new Error(`Expected: "Sort:"; Actual: "${elementText}"`);
}
console.log('Passed: Sort label matched as expected');
}
},
//Sort Dropdown [should be: "Count", option]
{
description: 'Validate sort dropdown option',
action: async () => {
const elementOption = await driver.findElement(By.css('#orgsort > option:nth-child(1)')).getAttribute('value');
if (elementOption !== 'count') {
throw new Error(`Expected: "count"; Actual: "${elementOption}"`);
}
console.log('Passed: Sort dropdown option matched as expected');
}
},
//Biology-QA
{
description: 'Validate Biology-QA title',
action: async () => {
const elementText = await driver.findElement(By.linkText('Biology - QA')).getText();
if (elementText !== 'Biology - QA') {
throw new Error(`Expected: "Biology - QA"; Actual: "${elementText}"`);
}
console.log('Passed: Biology-QA link title matched as expected');
}
},
{
description: 'Validate Biology-QA edit icon color',
action: async () => {
const elementStyle = await driver.findElement(By.css('#mycontentlist > #content-org-list > .content-org .fa')).getCssValue('color');
if (elementStyle !== 'rgba(73, 80, 87, 1)') {
throw new Error(`Biology-QA edit icon color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Bioloby-QA edit icon color matched as expected');
}
},
//Biology-QA Count
{
description: 'Validate Biology-QA Count',
action: async () => {
const elementText = await driver.findElement(By.css('#mycontentlist > #content-org-list > .content-org .badge')).getText();
if (elementText !== '1046') {
throw new Error(`Expected: "1046"; Actual: "${elementText}"`);
}
console.log('Passed: Biology-QA Count matched as expected');
}
},
{ description: 'Click Login button', action: async () => await driver.findElement(By.linkText('Biology - QA')).click() },
//Wait for Biology - QA Content page to load
{
description: 'Wait for Content page load to completely',
action: async () => {
return await driver.wait(until.elementLocated(By.css('.float-left:nth-child(5)')), 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');
}
},
//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');
}
},
//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 label
{
description: 'Validate Biology - QA label',
action: async () => {
const elementText = await driver.findElement(By.css('.form-group:nth-child(1) > label')).getText();
if (elementText !== 'Biology - QA') {
throw new Error(`Expected: "Biology - QA (1046)"; Actual: "${elementText}"`);
}
console.log('Passed: Biology - QA (1046) label matched as expected');
}
},
//Grade title
{
description: 'Validate Grade title',
action: async () => {
const elementText = await driver.findElement(By.css('.form-group:nth-child(3) > b')).getText();
if (elementText !== 'Grade') {
throw new Error(`Expected: "Grade"; Actual: "${elementText}"`);
}
console.log('Passed: Grade title matched as expected');
}
},
//9th grade checkbox
{
description: 'Verify 9th grade checkbox icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('#metagrades49')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('9th grade checkbox icon not found');
}
console.log('Passed: 9th grade checkbox icon present');
}
},
//9th grade label
{
description: 'Validate 9th grade label',
action: async () => {
const elementText = await driver.findElement(By.css('.form-group:nth-child(3) > label:nth-child(4)')).getText();
if (elementText !== '9') {
throw new Error(`Expected: "9"; Actual: "${elementText}"`);
}
console.log('Passed: 9 label matched as expected');
}
},
//10th grade checkbox
{
description: 'Verify 10th grade checkbox icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('#metagrades51')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('10th grade checkbox icon not found');
}
console.log('Passed: 10th grade checkbox icon present');
}
},
//10th grade label
{
description: 'Validate 10th grade label',
action: async () => {
const elementText = await driver.findElement(By.css('.form-group:nth-child(3) > label:nth-child(7)')).getText();
if (elementText !== '10') {
throw new Error(`Expected: "10"; Actual: "${elementText}"`);
}
console.log('Passed: 10 label matched as expected');
}
},
//11th grade checkbox
{
description: 'Verify 11th grade checkbox icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('#metagrades52')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('11th grade checkbox icon not found');
}
console.log('Passed: 11th grade checkbox icon present');
}
},
//11th grade label
{
description: 'Validate 11th grade label',
action: async () => {
const elementText = await driver.findElement(By.css('.form-group:nth-child(3) > label:nth-child(10)')).getText();
if (elementText !== '11') {
throw new Error(`Expected: "11"; Actual: "${elementText}"`);
}
console.log('Passed: 11 label matched as expected');
}
},
//12th grade checkbox
{
description: 'Verify 12th grade checkbox icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('#metagrades53')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('12th grade checkbox icon not found');
}
console.log('Passed: 12th grade checkbox icon present');
}
},
//12th grade label
{
description: 'Validate 12th grade label',
action: async () => {
const elementText = await driver.findElement(By.css('label:nth-child(13)')).getText();
if (elementText !== '12') {
throw new Error(`Expected: "12"; Actual: "${elementText}"`);
}
console.log('Passed: 12 label matched as expected');
}
},
//8th grade checkbox
{
description: 'Verify 8th grade checkbox icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('#metagrades48')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('8th grade checkbox icon not found');
}
console.log('Passed: 8th grade checkbox icon present');
}
},
//8th grade label
{
description: 'Validate 8th grade label',
action: async () => {
const elementText = await driver.findElement(By.css('label:nth-child(16)')).getText();
if (elementText !== '8') {
throw new Error(`Expected: "8"; Actual: "${elementText}"`);
}
console.log('Passed: 8 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');
}
},
//Science checkbox
{
description: 'Verify Science checkbox icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('#metasubjectsScience')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('Science checkbox icon not found');
}
console.log('Passed: Science checkbox icon present');
}
},
//Science label
{
description: 'Validate Science label',
action: async () => {
const elementText = await driver.findElement(By.css('.form-group:nth-child(6) > label:nth-child(4)')).getText();
if (elementText !== 'Science') {
throw new Error(`Expected: "Science"; Actual: "${elementText}"`);
}
console.log('Passed: Science label matched as expected');
}
},
//Mathematics checkbox
{
description: 'Verify Mathematics checkbox icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('#metasubjectsMathematics')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('Mathematics checkbox icon not found');
}
console.log('Passed: Mathematics checkbox icon present');
}
},
//Mathematics label
{
description: 'Validate Mathematics label',
action: async () => {
const elementText = await driver.findElement(By.css('.form-group:nth-child(6) > label:nth-child(7)')).getText();
if (elementText !== 'Mathematics') {
throw new Error(`Expected: "Mathematics"; Actual: "${elementText}"`);
}
console.log('Passed: Mathematics label matched as expected');
}
},
//Social and Emotional Learning checkbox
{
description: 'Verify Social and Emotional Learning checkbox icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.id('metasubjectsSocial and Emotional Learning')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('Social and Emotional Learning checkbox icon not found');
}
console.log('Passed: Social and Emotional Learning checkbox icon present');
}
},
//Social and Emotional Learning label
{
description: 'Validate Social and Emotional Learning label',
action: async () => {
const elementText = await driver.findElement(By.css('.form-group:nth-child(6) > label:nth-child(10)')).getText();
if (elementText !== 'Social and Emotional Learning') {
throw new Error(`Expected: "Social and Emotional Learning"; Actual: "${elementText}"`);
}
console.log('Passed: Social and Emotional Learning 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');
}
},
//RESULTS
//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');
}
},
//Results 1-25 of 1046 label
{
description: 'Validate Results 1-25 of 1046 label',
action: async () => {
const elementText = await driver.findElement(By.css('.float-left:nth-child(5)')).getText();
if (elementText !== 'Results 1 - 25 of 1046') {
throw new Error(`Expected: "Results 1 - 25 of 1046" label; Actual: "${elementText}"`);
}
console.log('Passed: Results 1 - 25 of 1046 label matched as expected');
}
},
//PAGINATION BUTTONS
//Show button text
{
description: 'Validate Show button text',
action: async () => {
const elementText = await driver.findElement(By.css('.form-group:nth-child(6) #contentlimit')).getText();
if (elementText !== 'Show') {
throw new Error(`Expected: "Show" button text; Actual: "${elementText}"`);
}
console.log('Passed: Show button text matched as expected');
}
},
//Show dropdown [should be: "25", option]
{
description: 'Validate Show dropdown option',
action: async () => {
const elementOption = await driver.findElement(By.css('.form-group:nth-child(6) #inputlimit')).getAttribute('value');
if (elementOption !== '25') {
throw new Error(`Expected: "25"; Actual: "${elementOption}"`);
}
console.log('Passed: Show dropdown option matched as expected');
}
},
//Pagination 1 button text
{
description: 'Validate pagination 1 button text',
action: async () => {
const elementText = await driver.findElement(By.css('div:nth-child(4) > nav .active > .page-link')).getText();
if (elementText !== '1') {
throw new Error(`Expected: Pagination "1" button text; Actual: "${elementText}"`);
}
console.log('Passed: Pagination 1 button text matched as expected');
}
},
//Pagination 1 background color -green
{
description: 'Validate pagination 1 button color',
action: async () => {
const elementStyle = await driver.findElement(By.css('div:nth-child(4) > nav .active > .page-link')).getCssValue('background-color');
if (elementStyle !== 'rgba(48, 200, 172, 1)') {
throw new Error(`Expected: Pagination 1 button color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Pagination 1 button color matched as expected');
}
},
//Pagination 2 button text
{
description: 'Validate pagination 2 button text',
action: async () => {
const elementText = await driver.findElement(By.css('div:nth-child(4) > nav .page-item:nth-child(2) > .page-link')).getText();
if (elementText !== '2') {
throw new Error(`Expected: Pagination "2" button text; Actual: "${elementText}"`);
}
console.log('Passed: Pagination 2 button text matched as expected');
}
},
//Pagination 2 text color -green
{
description: 'Validate pagination 2 text color',
action: async () => {
const elementStyle = await driver.findElement(By.css('div:nth-child(4) > nav .page-item:nth-child(2) > .page-link')).getCssValue('color');
if (elementStyle !== 'rgba(48, 200, 172, 1)') {
throw new Error(`Expected: Pagination 2 text color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Pagination 2 text color matched as expected');
}
},
//Pagination 3 button text
{
description: 'Validate pagination 3 button text',
action: async () => {
const elementText = await driver.findElement(By.css('div:nth-child(4) > nav .page-item:nth-child(3) > .page-link')).getText();
if (elementText !== '3') {
throw new Error(`Expected: Pagination "3" button text; Actual: "${elementText}"`);
}
console.log('Passed: Pagination 3 button text matched as expected');
}
},
//Pagination 3 text color -green
{
description: 'Validate pagination 3 text color',
action: async () => {
const elementStyle = await driver.findElement(By.css('div:nth-child(4) > nav .page-item:nth-child(3) > .page-link')).getCssValue('color');
if (elementStyle !== 'rgba(48, 200, 172, 1)') {
throw new Error(`Expected: Pagination 3 text color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Pagination 3 text color matched as expected');
}
},
//Pagination 4 button text
{
description: 'Validate pagination 4 button text',
action: async () => {
const elementText = await driver.findElement(By.css('div:nth-child(4) > nav .page-item:nth-child(4) > .page-link')).getText();
if (elementText !== '4') {
throw new Error(`Expected: Pagination "4" button text; Actual: "${elementText}"`);
}
console.log('Passed: Pagination 4 button text matched as expected');
}
},
//Pagination 4 text color -green
{
description: 'Validate pagination 4 text color',
action: async () => {
const elementStyle = await driver.findElement(By.css('div:nth-child(4) > nav .page-item:nth-child(4) > .page-link')).getCssValue('color');
if (elementStyle !== 'rgba(48, 200, 172, 1)') {
throw new Error(`Expected: Pagination 4 text color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Pagination 4 text color matched as expected');
}
},
//Pagination 5 button text
{
description: 'Validate pagination 5 button text',
action: async () => {
const elementText = await driver.findElement(By.css('div:nth-child(4) > nav .page-item:nth-child(5) > .page-link')).getText();
if (elementText !== '5') {
throw new Error(`Expected: Pagination "5" button text; Actual: "${elementText}"`);
}
console.log('Passed: Pagination 5 button text matched as expected');
}
},
//Pagination 5 text color -green
{
description: 'Validate pagination 5 text color',
action: async () => {
const elementStyle = await driver.findElement(By.css('div:nth-child(4) > nav .page-item:nth-child(5) > .page-link')).getCssValue('color');
if (elementStyle !== 'rgba(48, 200, 172, 1)') {
throw new Error(`Expected: Pagination 5 text color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Pagination 5 text color matched as expected');
}
},
//Pagination separator icon
{
description: 'Verify Pagination separator icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('div:nth-child(4) > nav .ml-1 > a')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('Pagination separator icon not found');
}
console.log('Passed: Pagination separator icon present');
}
},
//Pagination 42 button text
{
description: 'Validate pagination 45 button text',
action: async () => {
const elementText = await driver.findElement(By.css('div:nth-child(4) > nav .page-item:nth-child(7) > .page-link')).getText();
if (elementText !== '42') {
throw new Error(`Expected: Pagination "42" button text; Actual: "${elementText}"`);
}
console.log('Passed: Pagination 42 button text matched as expected');
}
},
//Pagination 42 text color -green
{
description: 'Validate pagination 42 text color',
action: async () => {
const elementStyle = await driver.findElement(By.css('div:nth-child(4) > nav .page-item:nth-child(7) > .page-link')).getCssValue('color');
if (elementStyle !== 'rgba(48, 200, 172, 1)') {
throw new Error(`Expected: Pagination 42 text color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Pagination 42 text color matched as expected');
}
},
//Pagination Show All button text
{
description: 'Validate pagination Show All button text',
action: async () => {
const elementText = await driver.findElement(By.css('div:nth-child(4) > nav .page-item:nth-child(8) > .page-link')).getText();
if (elementText !== 'Show All') {
throw new Error(`Expected: Pagination "Show All" button text; Actual: "${elementText}"`);
}
console.log('Passed: Pagination Show All button text matched as expected');
}
},
//Pagination Show All text color -green
{
description: 'Validate pagination Show All text color',
action: async () => {
const elementStyle = await driver.findElement(By.css('div:nth-child(4) > nav .page-item:nth-child(8) > .page-link')).getCssValue('color');
if (elementStyle !== 'rgba(48, 200, 172, 1)') {
throw new Error(`Expected: Pagination Show All text color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Pagination Show All text color matched as expected');
}
},
//RESULTS CONTENT ITEMS
//Content 1 Title
{
description: 'Validate Content 1 title',
action: async () => {
const elementText = await driver.findElement(By.linkText('AAA My Test III')).getText();
if (elementText !== 'AAA My Test III') {
throw new Error(`Expected: Content 1 item "AAA My Test III" title; Actual: "${elementText}"`);
}
console.log('Passed: Content 1 item AAA My Test III tittle matched as expected');
}
},
//Content 1 edit icon
{
description: 'Verify Content 1 edit icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('.card:nth-child(8) .lo-title .fa')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('Content 1 edit icon not found');
}
console.log('Passed: Content 1 edit icon present');
}
},
//Content 1 edit button text
{
description: 'Validate pagination Show All button text',
action: async () => {
const elementText = await driver.findElement(By.css('.card:nth-child(8) .ml-3')).getText();
if (elementText !== 'Edit') {
throw new Error(`Expected: Content 1 "Edit" button text; Actual: "${elementText}"`);
}
console.log('Passed: Content 1 Edit button text matched as expected');
}
},
//Content 1 edit button color -green
{
description: 'Validate Content 1 Edit button color',
action: async () => {
const elementStyle = await driver.findElement(By.css('.card:nth-child(8) .ml-3')).getCssValue('background-color');
if (elementStyle !== 'rgba(48, 200, 172, 1)') {
throw new Error(`Expected: Content 1 Edit button color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Content 1 Edit button color matched as expected');
}
},
//Content 1 description
{
description: 'Validate Content 1 description',
action: async () => {
const elementText = await driver.findElement(By.css('.card:nth-child(8) .lo-descr')).getText();
if (elementText !== 'Yes, it should work! Perhaps') {
throw new Error(`Expected: Content 1 description text did not match; Actual: "${elementText}"`);
}
console.log('Passed: Content 1 description text matched as expected');
}
},
//Content 1 content set label
{
description: 'Validate Content 1 content set label',
action: async () => {
const elementText = await driver.findElement(By.css('.card:nth-child(8) small')).getText();
if (elementText !== 'Content Set: Biology - QA') {
throw new Error(`Expected: Content 1 content set label did not match; Actual: "${elementText}"`);
}
console.log('Passed: Content 1 content set label matched as expected');
}
},
//Content 1 alignment label
{
description: 'Validate Content 1 ECS Alignement label',
action: async () => {
const elementText = await driver.findElement(By.css('#alignstatuslink874454004 > .display-alignment')).getText();
if (elementText !== 'ECS Alignment (reset)') {
throw new Error(`Expected: Content 1 ECS Alignement label did not match; Actual: "${elementText}"`);
}
console.log('Passed: Content 1 ECS Alignement label matched as expected');
}
},
//Content 1 alignment reset label
{
description: 'Validate Content 1 ECS Alignement reset label',
action: async () => {
const elementText = await driver.findElement(By.css('#alignstatuslink874454004 b')).getText();
if (elementText !== 'reset') {
throw new Error(`Expected: Content 1 ECS Alignement reset label did not match; Actual: "${elementText}"`);
}
console.log('Passed: Content 1 ECS Alignement reset label matched as expected');
}
},
//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(8) .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');
}
},
//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(8) .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');
}
},
//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(8) .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');
}
},
//Content 2 Title
{
description: 'Validate Content 2 title',
action: async () => {
const elementText = await driver.findElement(By.linkText('Abrupt Climate Change')).getText();
if (elementText !== 'Abrupt Climate Change') {
throw new Error(`Expected: Content 1 item "Abrupt Climate Change" title; Actual: "${elementText}"`);
}
console.log('Passed: Content 1 item Abrupt Climate Change tittle matched as expected');
}
},
//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(9) .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');
}
},
//Content 2 edit button text
{
description: 'Validate pagination Show All button text',
action: async () => {
const elementText = await driver.findElement(By.css('.card:nth-child(9) .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');
}
},
//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(9) .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');
}
},
//Content 2 description
{
description: 'Validate Content 2 description',
action: async () => {
const elementText = await driver.findElement(By.css('.card:nth-child(9) .lo-descr')).getText();
if (elementText !== 'This Science NetLinks lesson focuses on a current issue in science in order to help students understand the process by which scientific knowledge is developed and refined. In this lesson, students are introduced to some recent ideas about abrupt climate change. This gives them a glimpse into how scientific theories are formed and refined by new data.') {
throw new Error(`Expected: Content 2 description text did not match; Actual: "${elementText}"`);
}
console.log('Passed: Content 2 description text matched as expected');
}
},
//Content 2 content set label
{
description: 'Validate Content 2 content set label',
action: async () => {
const elementText = await driver.findElement(By.css('.card:nth-child(9) small')).getText();
if (elementText !== 'Content Set: Biology - QA') {
throw new Error(`Expected: Content 2 content set label did not match; Actual: "${elementText}"`);
}
console.log('Passed: Content 2 content set label matched as expected');
}
},
//Content 2 alignment label
{
description: 'Validate Content 2 ECS Alignement label',
action: async () => {
const elementText = await driver.findElement(By.css('#alignstatuslink873578650 > .display-alignment')).getText();
if (elementText !== 'Alignment Pending (reset)') {
throw new Error(`Expected: Content 2 Alignement Pending label did not match; Actual: "${elementText}"`);
}
console.log('Passed: Content 2 Alignement Pending label matched as expected');
}
},
//Content 2 alignment reset label
{
description: 'Validate Content 2 Alignement Pending reset label',
action: async () => {
const elementText = await driver.findElement(By.css('#alignstatuslink873578650 b')).getText();
if (elementText !== 'reset') {
throw new Error(`Expected: Content 2 Alignement Pending reset label did not match; Actual: "${elementText}"`);
}
console.log('Passed: Content 2 Alignement Pending reset label matched as expected');
}
},
//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(9) .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');
}
},
//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(9) .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');
}
},
//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(9) .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');
}
},
];
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', 'contentPage');
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', 'contentPage');
if (fs.existsSync(screenshotDir)) {
fs.rmSync(screenshotDir, { recursive: true, force: true });
}
fs.mkdirSync(screenshotDir, { recursive: true });
// Remove old Excel file
if (fs.existsSync('contentPageResults.xlsx')) {
fs.unlinkSync('contentPageResults.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, '');
for (const step of steps) {
const stepIndex = steps.indexOf(step) + 1;
const timestamp = new Date().toISOString();
try {
await step.action();
const screenshotPath = await takeScreenshot(driver, stepIndex, step.description);
worksheet = logStep(worksheet, step.description, 'Passed', stepIndex, timestamp, screenshotPath);
} catch (error) {
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}`);
testStatus = 'Failed';
}
}
//Check if login was successful
const usernameValidation = await driver.wait(until.elementLocated(By.css('#navbarDropdown > span')), 5000).catch(() => false);
if (usernameValidation) {
console.log('PASSED: System logged in as expected');
testStatus = 'Passed';
} else {
console.log('FAILED: Unable to log in');
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, 'contentPageResults.xlsx');
} finally {
await driver.quit();
}
})();
}
export default ExACT_contentPage;