Files
EdGateAutomatedRegression/tests/ExACT_alignContentPage.js

1298 lines
48 KiB
JavaScript

import { Builder, By, Key, until } from 'selenium-webdriver';
import fs from 'fs';
import XLSX from 'xlsx';
import path from 'path';
const ExACT_alignContentPage = (req, res) => {
res.send('<h2>ExACT Automated Test Script - Align Content Page: Initiated</h2>');
(async function example() {
let driver = await new Builder().forBrowser('chrome').build();
let testStatus = 'Failed';
let workbook;
let worksheet;
const startTime = new Date().toISOString();
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');
}
},
//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 dashboard to load - Correlation Coverages View Details button
{
description: 'Wait for dashboard 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 dashboard to load - Correlation Coverages View Details button
{
description: 'Wait for dashboard 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 () => {
const elementText = await driver.findElement(By.css('.list-group:nth-child(2) > .list-group-item:nth-child(1)')).getText();
if (elementText !== 'Grade:') {
throw new Error(`Expected: "Grade:"; Actual: "${elementText}"`);
}
console.log('Passed: Grade: label matched as expected');
}
},
//Subject:
{
description: 'Validate Subject label',
action: async () => {
const elementText = await driver.findElement(By.css('.list-group:nth-child(2) > .list-group-item:nth-child(2)')).getText();
if (elementText !== 'Subject:') {
throw new Error(`Expected: "Subject:"; Actual: "${elementText}"`);
}
console.log('Passed: Subject: label matched as expected');
}
},
//Alignment Status:
{
description: 'Validate Alignment Status label',
action: async () => {
const elementText = await driver.findElement(By.css('.list-group:nth-child(2) > .list-group-item:nth-child(3)')).getText();
if (elementText !== 'Alignment Status:') {
throw new Error(`Expected: "Alignment Status:"; Actual: "${elementText}"`);
}
console.log('Passed: Alignment Status: label 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 (1064) label
{
description: 'Validate Subject Science (1064) label',
action: async () => {
const elementText = await driver.findElement(By.css('.show > li:nth-child(4) .checkbox')).getText();
if (elementText !== 'Science (1064)') {
throw new Error(`Expected: Subject: "Science (2384)" checkbox label; Actual: "${elementText}"`);
}
console.log('Passed: Subject Science (1064) 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 (414) label
{
description: 'Validate Subject Language Arts (414) label',
action: async () => {
const elementText = await driver.findElement(By.css('.show > li:nth-child(5) .checkbox')).getText();
if (elementText !== 'Language Arts (414)') {
throw new Error(`Expected: Subject: "Language Arts (414)" checkbox label; Actual: "${elementText}"`);
}
console.log('Passed: Subject Language Arts (414) 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 (75) label
{
description: 'Validate Subject Social Studies (75) label',
action: async () => {
const elementText = await driver.findElement(By.css('.show > li:nth-child(6) .checkbox')).getText();
if (elementText !== 'Social Studies (75)') {
throw new Error(`Expected: Subject: "Social Studies (75)" checkbox label; Actual: "${elementText}"`);
}
console.log('Passed: Subject Social Studies (75) checkbox label matched as expected');
}
},
//NEXT ACTION - Select subject Mathematics and Language Arts
{ description: 'Select subject Mathematics', action: async () => await driver.findElement(By.css('.show > li:nth-child(4) input')).click() },
{ description: 'Select subject Language Arts', 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 (3259) label
{
description: 'Validate Alignment Status Not Aligned (3259) label',
action: async () => {
const elementText = await driver.findElement(By.css('.show > li:nth-child(3) .checkbox')).getText();
if (elementText !== 'Not Aligned (3259)') {
throw new Error(`Expected: Alignment Status: "Not Aligned (3259)" checkbox label; Actual: "${elementText}"`);
}
console.log('Passed: Alignment Status: Not Aligned (3259) 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 (17) label
{
description: 'Validate Alignment Status Pending (17) label',
action: async () => {
const elementText = await driver.findElement(By.css('.show > li:nth-child(5) .checkbox')).getText();
if (elementText !== 'Pending (17)') {
throw new Error(`Expected: Alignment Status: "Pending (17)" checkbox label; Actual: "${elementText}"`);
}
console.log('Passed: Alignment Status Pending (17) 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 (6) label
{
description: 'Validate Alignment Status Aligned (6) label',
action: async () => {
const elementText = await driver.findElement(By.css('.show > li:nth-child(6) .checkbox')).getText();
if (elementText !== 'Aligned (6)') {
throw new Error(`Expected: Alignment Status: "Aligned (6)" checkbox label; Actual: "${elementText}"`);
}
console.log('Passed: Alignment Status Aligned (6) 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 () => {
const elementText = await driver.findElement(By.css('.list-group:nth-child(2) > .list-group-item:nth-child(1)')).getText();
if (elementText !== 'Grade:') {
throw new Error(`Expected: "Grade:"; Actual: "${elementText}"`);
}
console.log('Passed: Grade: label matched as expected');
}
},
//Subject:
{
description: 'Validate Subject label',
action: async () => {
const elementText = await driver.findElement(By.css('.list-group:nth-child(2) > .list-group-item:nth-child(2)')).getText();
if (elementText !== 'Subject:') {
throw new Error(`Expected: "Subject:"; Actual: "${elementText}"`);
}
console.log('Passed: Subject: label matched as expected');
}
},
//Alignment Status:
{
description: 'Validate Alignment Status label',
action: async () => {
const elementText = await driver.findElement(By.css('.list-group:nth-child(2) > .list-group-item:nth-child(3)')).getText();
if (elementText !== 'Alignment Status:') {
throw new Error(`Expected: "Alignment Status:"; Actual: "${elementText}"`);
}
console.log('Passed: Alignment Status: label matched as expected');
}
},
//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');
}
},
//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 count
{
description: 'Validate Biology - QA count',
action: async () => {
const elementText = await driver.findElement(By.css('.form-group:nth-child(1)')).getText();
if (elementText !== 'Biology - QA (2)') {
throw new Error(`Expected: "Biology - QA (2)"; Actual: "${elementText}"`);
}
console.log('Passed: Biology - QA (2) 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');
}
},
//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 count
{
description: 'Validate Grade: 6 count',
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"; 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 count
{
description: 'Validate Grade: 7 count',
action: async () => {
const elementText = await driver.findElement(By.css('label:nth-child(9)')).getText();
if (elementText !== '7') {
throw new Error(`Expected: Grade: "7"; Actual: "${elementText}"`);
}
console.log('Passed: Grade: 7 label matched as expected');
}
},
//Grade: 8 checkbox
{
description: 'Verify Grade: 8 checkbox icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('#metagrades48')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('Grade: 8 checkbox icon not found');
}
console.log('Passed: Grade: 8 checkbox icon present');
}
},
//Grade: 8 count
{
description: 'Validate Grade: 8 count',
action: async () => {
const elementText = await driver.findElement(By.css('label:nth-child(12)')).getText();
if (elementText !== '8') {
throw new Error(`Expected: Grade: "8"; 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 count
{
description: 'Validate Grade: 9 count',
action: async () => {
const elementText = await driver.findElement(By.css('label:nth-child(15)')).getText();
if (elementText !== '9') {
throw new Error(`Expected: Grade: "9"; 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 count
{
description: 'Validate Grade: 10 count',
action: async () => {
const elementText = await driver.findElement(By.css('label:nth-child(18)')).getText();
if (elementText !== '10') {
throw new Error(`Expected: Grade: "10"; 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: 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
{
description: 'Verify Subject: 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('Subject: Science checkbox icon not found');
}
console.log('Passed: Subject: Science checkbox icon present');
}
},
//Subject: Science count
{
description: 'Validate Subject: Science count',
action: async () => {
const elementText = await driver.findElement(By.css('.form-group:nth-child(6) > label')).getText();
if (elementText !== 'Science (2)') {
throw new Error(`Expected: "Subject: Science (2)"; Actual: "${elementText}"`);
}
console.log('Passed: Subject: Science (2) label 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', '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, '');
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, 'alignContentPageResults.xlsx');
} finally {
await driver.quit();
}
})();
}
export default ExACT_alignContentPage;