1522 lines
56 KiB
JavaScript
1522 lines
56 KiB
JavaScript
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 uploadBatchUploadPage = (req, res) => {
|
|
res.send('<h2>ExACT Automated Test Script: Upload - Batch Upload Page(uploadBatchUploadPage); Initiated</h2>');
|
|
(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 - UPLOAD STATUS LIST
|
|
//Expected rows in the upload table, top to bottom. Update this list when the uploads change.
|
|
const expectedUploads = [
|
|
{ uploadName: 'bi_1792114080_1279341079_Upload_Demo_873036958_873035203_1792090693.csv', items: '5', status: 'Completed', uploadedOn: 'Oct 15, 2026 - 6:28 PM', completedOn: 'Oct 15, 2026 - 8:19 PM' },
|
|
{ uploadName: 'bi_1792111802_1279341079_Khan_URLs.csv', items: '279', status: 'Completed', uploadedOn: 'Oct 15, 2026 - 5:57 PM', completedOn: 'Oct 15, 2026 - 8:18 PM' },
|
|
{ uploadName: 'ECS3104_Test.csv', items: '279', status: 'Completed', uploadedOn: 'Oct 2, 2026 - 4:44 PM', completedOn: 'Oct 2, 2026 - 7:05 PM' },
|
|
{ uploadName: 'SecondTestECS3104.csv', items: '279', status: 'Completed', uploadedOn: 'Sep 18, 2026 - 10:58 AM', completedOn: 'Sep 18, 2026 - 12:22 PM' },
|
|
{ uploadName: 'ECS3104_Test.csv', items: '279', status: 'Completed', uploadedOn: 'Sep 18, 2026 - 10:50 AM', completedOn: 'Sep 18, 2026 - 11:45 AM' },
|
|
{ uploadName: 'Khan_URLs.csv', items: '279', status: 'Completed', uploadedOn: 'Sep 18, 2026 - 10:00 AM', completedOn: 'Sep 18, 2026 - 11:19 AM' },
|
|
{ uploadName: 'KhanURLs.csv', items: '279', status: 'Completed', uploadedOn: 'Sep 18, 2026 - 9:39 AM', completedOn: 'Sep 18, 2026 - 10:37 AM' },
|
|
{ uploadName: 'KhanURLs.csv', items: '279', status: 'Completed', uploadedOn: 'Jul 30, 2026 - 8:13 PM', completedOn: 'Jul 30, 2026 - 9:15 PM' },
|
|
{ uploadName: 'ECS3037_Grades.xlsx', items: '25', status: 'Completed', uploadedOn: 'Jun 29, 2026 - 9:42 PM', completedOn: 'Jun 29, 2026 - 9:43 PM' },
|
|
{ uploadName: 'ExACT_Import_Template_TC1.xlsx', items: '1', status: 'Completed', uploadedOn: 'Jun 29, 2026 - 9:26 PM', completedOn: 'Jun 29, 2026 - 9:27 PM' },
|
|
{ uploadName: 'ECS3037_Grades.xlsx', items: '25', status: 'Completed', uploadedOn: 'Jun 29, 2026 - 9:17 PM', completedOn: 'Jun 29, 2026 - 9:18 PM' },
|
|
{ uploadName: 'ExACT_Import_Template_TC1.xlsx', items: '1', status: 'Completed', uploadedOn: 'Jun 29, 2026 - 9:15 PM', completedOn: 'Jun 29, 2026 - 9:16 PM' },
|
|
];
|
|
|
|
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('------------->| UPLOAD - BATCH UPLOAD 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 Upload navigation link',
|
|
action: async () => {
|
|
await driver.findElement(By.linkText('Upload')).click();
|
|
console.log('----->| NEXT ACTION: Clicked Upload navigation link');
|
|
|
|
//Wait for page readyState
|
|
await driver.wait(async () => {
|
|
const readyState = await driver.executeScript('return document.readyState');
|
|
return readyState === 'complete';
|
|
}, 30000, 'Align page did not fully load within 30 seconds');
|
|
|
|
//Wait until the element exists in the DOM
|
|
const uploadTitle = await driver.wait(
|
|
until.elementLocated(By.css('h2')),
|
|
30000
|
|
);
|
|
|
|
//Wait until it becomes visible
|
|
await driver.wait(
|
|
until.elementIsVisible(uploadTitle),
|
|
30000
|
|
);
|
|
}
|
|
},
|
|
|
|
//Upload page title
|
|
{
|
|
description: 'Upload page title text, size, and color',
|
|
action: async () => {
|
|
const multipleChecks = 'Upload page title';
|
|
|
|
const element = await driver.findElement(By.css('h2'));
|
|
|
|
//Get text, font, size, and color
|
|
const elementText = await element.getText();
|
|
const elementFont = await element.getCssValue('font-family');
|
|
const elementSize = await element.getCssValue('font-size');
|
|
const elementColor = await element.getCssValue('color');
|
|
|
|
//Track all errors
|
|
const errors = [];
|
|
|
|
//text
|
|
if (elementText === 'Upload') {
|
|
console.log('Passed: Upload page title text matched as expected');
|
|
} else {
|
|
errors.push(`Expected: "Upload"; Actual: "${elementText}"`);
|
|
}
|
|
|
|
//font
|
|
if (elementFont === `"DM Serif Display", serif`) {
|
|
console.log('Passed: Upload page title font-family matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Upload page title font-family "DM Serif Display, serif"; Actual: ${elementFont}`);
|
|
}
|
|
|
|
//size
|
|
if (elementSize === '32px') {
|
|
console.log('Passed: Upload page title text font-size matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Upload page title text font-size "32px"; Actual: "${elementSize}"`);
|
|
}
|
|
|
|
//color
|
|
if (elementColor === 'rgba(40, 39, 90, 1)') {
|
|
console.log('Passed: Upload page title text color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Upload page title text color: "rgba(40, 39, 90, 1)"; Actual: "${elementColor}"`);
|
|
}
|
|
|
|
//Throw summary if any validation failed
|
|
if (errors.length > 0) {
|
|
//Add summary line only when multiple checks failed
|
|
if (errors.length > 1) {
|
|
errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`);
|
|
}
|
|
|
|
//Throw collected messages — catch() will prefix with "FAILED:"
|
|
throw new Error(errors.join('\n'));
|
|
}
|
|
}
|
|
},
|
|
|
|
//Submit A Resource tab
|
|
{
|
|
description: 'Submit A Resource tab title text, size, color, and background color',
|
|
action: async () => {
|
|
const multipleChecks = 'Submit A Resource tab title';
|
|
|
|
const element = await driver.findElement(By.linkText('Submit A Resource'));
|
|
|
|
//Get text, font, size, color, and background color
|
|
const elementText = await element.getText();
|
|
const elementFont = await element.getCssValue('font-family');
|
|
const elementSize = await element.getCssValue('font-size');
|
|
const elementColor = await element.getCssValue('color');
|
|
const elementBgColor = await element.getCssValue('background-color');
|
|
|
|
//Track all errors
|
|
const errors = [];
|
|
|
|
//element text
|
|
if (elementText === 'Submit A Resource') {
|
|
console.log('Passed: Submit A Resource tab title text matched as expected');
|
|
} else {
|
|
errors.push(`Expected: "Submit A Resource"; Actual: "${elementText}"`);
|
|
}
|
|
|
|
//element font
|
|
if (elementFont === 'Poppins, sans-serif') {
|
|
console.log('Passed: Submit A Resource tab title font-family matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Submit A Resource tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`);
|
|
}
|
|
|
|
//element size
|
|
if (elementSize === '15px') {
|
|
console.log('Passed: Submit A Resource tab title text font-size matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Submit A Resource tab title text font-size "15px"; Actual: "${elementSize}"`);
|
|
}
|
|
|
|
//element color
|
|
if (elementColor === 'rgba(255, 255, 255, 1)') {
|
|
console.log('Passed: Submit A Resource tab title text color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Submit A Resource tab title text color: "rgba(255, 255, 255, 1)"; Actual: "${elementColor}"`);
|
|
}
|
|
|
|
//element background color
|
|
if (elementBgColor === 'rgba(40, 39, 90, 1)') {
|
|
console.log('Passed: Submit A Resource tab title background color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Submit A Resource tab title background color: "rgba(40, 39, 90, 1)"; Actual: "${elementBgColor}"`);
|
|
}
|
|
|
|
//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'));
|
|
}
|
|
}
|
|
},
|
|
|
|
//Batch Upload tab
|
|
{
|
|
description: 'Batch Upload tab title text, size, color, and background color',
|
|
action: async () => {
|
|
const multipleChecks = 'Batch Upload tab title';
|
|
|
|
const element = await driver.findElement(By.linkText('Batch Upload'));
|
|
|
|
//Get text, font, size, color, and background color
|
|
const elementText = await element.getText();
|
|
const elementFont = await element.getCssValue('font-family');
|
|
const elementSize = await element.getCssValue('font-size');
|
|
const elementColor = await element.getCssValue('color');
|
|
const elementBgColor = await element.getCssValue('background-color');
|
|
|
|
//Track all errors
|
|
const errors = [];
|
|
|
|
//element text
|
|
if (elementText === 'Batch Upload') {
|
|
console.log('Passed: Batch Upload tab title text matched as expected');
|
|
} else {
|
|
errors.push(`Expected: "Batch Upload"; Actual: "${elementText}"`);
|
|
}
|
|
|
|
//element font
|
|
if (elementFont === 'Poppins, sans-serif') {
|
|
console.log('Passed: Batch Upload tab title font-family matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Batch Upload tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`);
|
|
}
|
|
|
|
//element size
|
|
if (elementSize === '15px') {
|
|
console.log('Passed: Batch Upload tab title text font-size matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Batch Upload tab title text font-size "15px"; Actual: "${elementSize}"`);
|
|
}
|
|
|
|
//element color
|
|
if (elementColor === 'rgba(182, 186, 181, 1)') {
|
|
console.log('Passed: Batch Upload tab title text color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Batch Upload tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`);
|
|
}
|
|
|
|
//element background color
|
|
if (elementBgColor === 'rgba(0, 0, 0, 0)') {
|
|
console.log('Passed: Batch Upload tab title background color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Batch Upload tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`);
|
|
}
|
|
|
|
//Throw summary if any validation failed
|
|
if (errors.length > 0) {
|
|
//Add summary line only when multiple checks failed
|
|
if (errors.length > 1) {
|
|
errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`);
|
|
}
|
|
|
|
//Throw collected messages — catch() will prefix with "FAILED:"
|
|
throw new Error(errors.join('\n'));
|
|
}
|
|
}
|
|
},
|
|
|
|
//Import Alignments tab
|
|
{
|
|
description: 'Import Alignments tab title text, size, color, and background color',
|
|
action: async () => {
|
|
const multipleChecks = 'Import Alignments tab title';
|
|
|
|
const element = await driver.findElement(By.linkText('Import Alignments'));
|
|
|
|
//Get text, font, size, color, and background color
|
|
const elementText = await element.getText();
|
|
const elementFont = await element.getCssValue('font-family');
|
|
const elementSize = await element.getCssValue('font-size');
|
|
const elementColor = await element.getCssValue('color');
|
|
const elementBgColor = await element.getCssValue('background-color');
|
|
|
|
//Track all errors
|
|
const errors = [];
|
|
|
|
//element text
|
|
if (elementText === 'Import Alignments') {
|
|
console.log('Passed: Import Alignments tab title text matched as expected');
|
|
} else {
|
|
errors.push(`Expected: "Import Alignments"; Actual: "${elementText}"`);
|
|
}
|
|
|
|
//element font
|
|
if (elementFont === 'Poppins, sans-serif') {
|
|
console.log('Passed: Import Alignments tab title font-family matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Import Alignments tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`);
|
|
}
|
|
|
|
//element size
|
|
if (elementSize === '15px') {
|
|
console.log('Passed: Import Alignments tab title text font-size matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Import Alignments tab title text font-size "15px"; Actual: "${elementSize}"`);
|
|
}
|
|
|
|
//element color
|
|
if (elementColor === 'rgba(182, 186, 181, 1)') {
|
|
console.log('Passed: Import Alignments tab title text color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Import Alignments tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`);
|
|
}
|
|
|
|
//element background color
|
|
if (elementBgColor === 'rgba(0, 0, 0, 0)') {
|
|
console.log('Passed: Import Alignments tab title background color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Import Alignments tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`);
|
|
}
|
|
|
|
//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 Batch Upload tab',
|
|
action: async () => {
|
|
await driver.findElement(By.linkText('Batch Upload')).click();
|
|
console.log('----->| NEXT ACTION: Clicked Batch Upload tab');
|
|
|
|
//Wait for page readyState
|
|
await driver.wait(async () => {
|
|
const readyState = await driver.executeScript('return document.readyState');
|
|
return readyState === 'complete';
|
|
}, 30000, 'Batch Upload page did not fully load within 30 seconds');
|
|
|
|
//Wait until the element exists in the DOM
|
|
const batchUploadPageTitle = await driver.wait(
|
|
until.elementLocated(By.css('.batch-section-title')),
|
|
30000
|
|
);
|
|
|
|
//Wait until it becomes visible
|
|
await driver.wait(
|
|
until.elementIsVisible(batchUploadPageTitle),
|
|
30000
|
|
);
|
|
}
|
|
},
|
|
|
|
//Submit A Resource tab
|
|
{
|
|
description: 'Submit A Resource tab title text, size, color, and background color',
|
|
action: async () => {
|
|
const multipleChecks = 'Submit A Resource tab title';
|
|
|
|
const element = await driver.findElement(By.linkText('Submit A Resource'));
|
|
|
|
//Get text, font, size, color, and background color
|
|
const elementText = await element.getText();
|
|
const elementFont = await element.getCssValue('font-family');
|
|
const elementSize = await element.getCssValue('font-size');
|
|
const elementColor = await element.getCssValue('color');
|
|
const elementBgColor = await element.getCssValue('background-color');
|
|
|
|
//Track all errors
|
|
const errors = [];
|
|
|
|
//element text
|
|
if (elementText === 'Submit A Resource') {
|
|
console.log('Passed: Submit A Resource tab title text matched as expected');
|
|
} else {
|
|
errors.push(`Expected: "Submit A Resource"; Actual: "${elementText}"`);
|
|
}
|
|
|
|
//element font
|
|
if (elementFont === 'Poppins, sans-serif') {
|
|
console.log('Passed: Submit A Resource tab title font-family matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Submit A Resource tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`);
|
|
}
|
|
|
|
//element size
|
|
if (elementSize === '15px') {
|
|
console.log('Passed: Submit A Resource tab title text font-size matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Submit A Resource tab title text font-size "15px"; Actual: "${elementSize}"`);
|
|
}
|
|
|
|
//element color
|
|
if (elementColor === 'rgba(182, 186, 181, 1)') {
|
|
console.log('Passed: Submit A Resource tab title text color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Submit A Resource tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`);
|
|
}
|
|
|
|
//element background color
|
|
if (elementBgColor === 'rgba(0, 0, 0, 0)') {
|
|
console.log('Passed: Submit A Resource tab title background color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Submit A Resource tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`);
|
|
}
|
|
|
|
//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'));
|
|
}
|
|
}
|
|
},
|
|
|
|
//Batch Upload tab
|
|
{
|
|
description: 'Batch Upload tab title text, size, color, and background color',
|
|
action: async () => {
|
|
const multipleChecks = 'Batch Upload tab title';
|
|
|
|
const element = await driver.findElement(By.linkText('Batch Upload'));
|
|
|
|
//Get text, font, size, color, and background color
|
|
const elementText = await element.getText();
|
|
const elementFont = await element.getCssValue('font-family');
|
|
const elementSize = await element.getCssValue('font-size');
|
|
const elementColor = await element.getCssValue('color');
|
|
const elementBgColor = await element.getCssValue('background-color');
|
|
|
|
//Track all errors
|
|
const errors = [];
|
|
|
|
//element text
|
|
if (elementText === 'Batch Upload') {
|
|
console.log('Passed: Batch Upload tab title text matched as expected');
|
|
} else {
|
|
errors.push(`Expected: "Batch Upload"; Actual: "${elementText}"`);
|
|
}
|
|
|
|
//element font
|
|
if (elementFont === 'Poppins, sans-serif') {
|
|
console.log('Passed: Batch Upload tab title font-family matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Batch Upload tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`);
|
|
}
|
|
|
|
//element size
|
|
if (elementSize === '15px') {
|
|
console.log('Passed: Batch Upload tab title text font-size matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Batch Upload tab title text font-size "15px"; Actual: "${elementSize}"`);
|
|
}
|
|
|
|
//element color
|
|
if (elementColor === 'rgba(255, 255, 255, 1)') {
|
|
console.log('Passed: Batch Upload tab title text color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Batch Upload tab title text color: "rgba(255, 255, 255, 1)"; Actual: "${elementColor}"`);
|
|
}
|
|
|
|
//element background color
|
|
if (elementBgColor === 'rgba(40, 39, 90, 1)') {
|
|
console.log('Passed: Batch Upload tab title background color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Batch Upload tab title background color: "rgba(40, 39, 90, 1)"; Actual: "${elementBgColor}"`);
|
|
}
|
|
|
|
//Throw summary if any validation failed
|
|
if (errors.length > 0) {
|
|
//Add summary line only when multiple checks failed
|
|
if (errors.length > 1) {
|
|
errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`);
|
|
}
|
|
|
|
//Throw collected messages — catch() will prefix with "FAILED:"
|
|
throw new Error(errors.join('\n'));
|
|
}
|
|
}
|
|
},
|
|
|
|
//Import Alignments tab
|
|
{
|
|
description: 'Import Alignments tab title text, size, color, and background color',
|
|
action: async () => {
|
|
const multipleChecks = 'Import Alignments tab title';
|
|
|
|
const element = await driver.findElement(By.linkText('Import Alignments'));
|
|
|
|
//Get text, font, size, color, and background color
|
|
const elementText = await element.getText();
|
|
const elementFont = await element.getCssValue('font-family');
|
|
const elementSize = await element.getCssValue('font-size');
|
|
const elementColor = await element.getCssValue('color');
|
|
const elementBgColor = await element.getCssValue('background-color');
|
|
|
|
//Track all errors
|
|
const errors = [];
|
|
|
|
//element text
|
|
if (elementText === 'Import Alignments') {
|
|
console.log('Passed: Import Alignments tab title text matched as expected');
|
|
} else {
|
|
errors.push(`Expected: "Import Alignments"; Actual: "${elementText}"`);
|
|
}
|
|
|
|
//element font
|
|
if (elementFont === 'Poppins, sans-serif') {
|
|
console.log('Passed: Import Alignments tab title font-family matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Import Alignments tab title font-family "Poppins, sans-serif"; Actual: ${elementFont}`);
|
|
}
|
|
|
|
//element size
|
|
if (elementSize === '15px') {
|
|
console.log('Passed: Import Alignments tab title text font-size matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Import Alignments tab title text font-size "15px"; Actual: "${elementSize}"`);
|
|
}
|
|
|
|
//element color
|
|
if (elementColor === 'rgba(182, 186, 181, 1)') {
|
|
console.log('Passed: Import Alignments tab title text color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Import Alignments tab title text color: "rgba(182, 186, 181, 1)"; Actual: "${elementColor}"`);
|
|
}
|
|
|
|
//element background color
|
|
if (elementBgColor === 'rgba(0, 0, 0, 0)') {
|
|
console.log('Passed: Import Alignments tab title background color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Import Alignments tab title background color: "rgba(0, 0, 0, 0)"; Actual: "${elementBgColor}"`);
|
|
}
|
|
|
|
//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'));
|
|
}
|
|
}
|
|
},
|
|
|
|
//Widget sub-title
|
|
{
|
|
description: 'Widget sub-title text, size, and color',
|
|
action: async () => {
|
|
const multipleChecks = 'Widget sub-title';
|
|
|
|
const element = await driver.findElement(By.css('.batch-section-title'));
|
|
|
|
//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 === 'Upload Status') {
|
|
console.log('Passed: Upload Status widget sub-title text matched as expected');
|
|
} else {
|
|
errors.push(`Expected: "Upload Status"; Actual: "${elementText}"`);
|
|
}
|
|
|
|
//font
|
|
if (elementFont === 'Poppins, sans-serif') {
|
|
console.log('Passed: Upload Status widget sub-title font-family matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Upload Status widget sub-title font-family "Poppins, sans-serif"; Actual: ${elementFont}`);
|
|
}
|
|
|
|
//size
|
|
if (elementSize === '18px') {
|
|
console.log('Passed: Upload Status widget sub-title text font-size matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Upload Status widget sub-title text font-size "18px"; Actual: "${elementSize}"`);
|
|
}
|
|
|
|
//color
|
|
if (elementColor === 'rgba(40, 39, 90, 1)') {
|
|
console.log('Passed: Upload Status widget sub-title text color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Upload Status widget sub-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'));
|
|
}
|
|
}
|
|
},
|
|
|
|
///Search textbox
|
|
{
|
|
description: 'Validate Search textbox placeholder text and icon',
|
|
action: async () => {
|
|
const multipleChecks = 'Search textbox';
|
|
|
|
const elementIcon = await driver.findElement(By.css('.search-icon > svg'));
|
|
const element = await driver.findElement(By.name('q'));
|
|
|
|
//Get text, font, size, and color
|
|
const elementText = await element.getAttribute('placeholder');
|
|
|
|
//Get placeholder styles via executeScript since it's a pseudo-element
|
|
const elementFont = await driver.executeScript(
|
|
`return window.getComputedStyle(arguments[0], '::placeholder').getPropertyValue('font-family')`,
|
|
element
|
|
);
|
|
|
|
const elementSize = await driver.executeScript(
|
|
`return window.getComputedStyle(arguments[0], '::placeholder').getPropertyValue('font-size')`,
|
|
element
|
|
);
|
|
|
|
const elementColor = await driver.executeScript(
|
|
`return window.getComputedStyle(arguments[0], '::placeholder').getPropertyValue('color')`,
|
|
element
|
|
);
|
|
|
|
//Track all errors
|
|
const errors = [];
|
|
|
|
//icon
|
|
if (elementIcon) {
|
|
console.log('Passed: Search textbox clear icon is present');
|
|
} else {
|
|
errors.push('Expected: Search textbox clear icon not found');
|
|
}
|
|
|
|
//text
|
|
if (elementText === 'Search') {
|
|
console.log('Passed: Search textbox placeholder text matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Search textbox placeholder to be: "Search"; Actual: "${elementText}"`);
|
|
}
|
|
|
|
//font-family
|
|
if (elementFont === "Poppins, sans-serif") {
|
|
console.log('Passed: Search textbox placeholder text font matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Search textbox placeholder text font "Poppins, sans-serif"; Actual: ${elementFont}`);
|
|
}
|
|
|
|
//font size
|
|
if (elementSize === '12.6px') {
|
|
console.log('Passed: Search textbox placeholder text font-size matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Search textbox placeholder text font-size "12.6px"; Actual: "${elementSize}"`);
|
|
}
|
|
|
|
//color
|
|
if (elementColor === 'rgb(221, 221, 221)') {
|
|
console.log('Passed: Search textbox placeholder text color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Search textbox placeholder text color: "rgb(221, 221, 221)"; 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'));
|
|
}
|
|
}
|
|
},
|
|
|
|
//New Upload button
|
|
{
|
|
description: 'New Upload button',
|
|
action: async () => {
|
|
const multipleChecks = 'New Upload button';
|
|
|
|
const element = await driver.findElement(By.linkText('+ New Upload'));
|
|
|
|
//Get button text, text font, text size, text color, and button color
|
|
const elementText = await element.getText('');
|
|
const elementTextFont = await element.getCssValue('font-family');
|
|
const elementTextSize = await element.getCssValue('font-size');
|
|
const elementTextColor = await element.getCssValue('color');
|
|
const elementButtonColor = await element.getCssValue('background-color');
|
|
|
|
//Track all errors
|
|
const errors = [];
|
|
|
|
//text
|
|
if (elementText === '+ New Upload') {
|
|
console.log('Passed: New Upload button text matched as expected');
|
|
} else {
|
|
errors.push(`Expected: "+ New Upload"; Actual: "${elementText}"`);
|
|
}
|
|
|
|
//font-family
|
|
if (elementTextFont === "Poppins, sans-serif") {
|
|
console.log('Passed: New Upload button text font matched as expected');
|
|
} else {
|
|
errors.push(`Expected: New Upload button text font "Poppins, sans-serif"; Actual: ${elementTextFont}`);
|
|
}
|
|
|
|
//font size
|
|
if (elementTextSize === '14px') {
|
|
console.log('Passed: New Upload button text font-size matched as expected');
|
|
} else {
|
|
errors.push(`Expected: New Upload button text font-size "14px"; Actual: "${elementTextSize}"`);
|
|
}
|
|
|
|
//color
|
|
if (elementTextColor === 'rgba(255, 255, 255, 1)') {
|
|
console.log('Passed: New Upload button text color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: New Upload button text color: "rgba(255, 255, 255, 1)"; Actual: "${elementTextColor}"`);
|
|
}
|
|
|
|
//button color
|
|
if (elementButtonColor === 'rgba(48, 200, 172, 1)') {
|
|
console.log('Passed: New Upload button background color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: New Upload button background color: "rgba(48, 200, 172, 1)"; Actual: "${elementButtonColor}"`);
|
|
}
|
|
|
|
//Throw summary if any validation failed
|
|
if (errors.length > 0) {
|
|
//Add summary line only when multiple checks failed
|
|
if (errors.length > 1) {
|
|
errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`);
|
|
}
|
|
|
|
//Throw collected messages — catch() will prefix with "FAILED:"
|
|
throw new Error(errors.join('\n'));
|
|
}
|
|
}
|
|
},
|
|
|
|
//COLUMN TITLE ROW
|
|
//Upload Name column title
|
|
{
|
|
description: 'Upload Name column title text, size, and color',
|
|
action: async () => {
|
|
const multipleChecks = 'Upload Name column title';
|
|
|
|
const element = await driver.findElement(By.css('.batch-table-clean th:nth-child(1)'));
|
|
|
|
//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 === 'Upload Name') {
|
|
console.log('Passed: Upload Name column title text matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Column title to be: "Upload Name"; Actual: "${elementText}"`);
|
|
}
|
|
|
|
//font
|
|
if (elementFont === 'Poppins, sans-serif') {
|
|
console.log('Passed: Upload Name column title font-family matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Upload Name column title font-family "Poppins, sans-serif"; Actual: ${elementFont}`);
|
|
}
|
|
|
|
//size
|
|
if (elementSize === '13px') {
|
|
console.log('Passed: Upload Name column title text font-size matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Upload Name column title text font-size "13px"; Actual: "${elementSize}"`);
|
|
}
|
|
|
|
//color
|
|
if (elementColor === 'rgba(40, 39, 90, 1)') {
|
|
console.log('Passed: Upload Name column title text color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Upload Name column 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'));
|
|
}
|
|
}
|
|
},
|
|
|
|
//Items column title
|
|
{
|
|
description: 'Items column title text, size, and color',
|
|
action: async () => {
|
|
const multipleChecks = 'Items column title';
|
|
|
|
const element = await driver.findElement(By.css('.batch-table-clean th:nth-child(2)'));
|
|
|
|
//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 === 'Items') {
|
|
console.log('Passed: Items column title text matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Column title to be: "Items"; Actual: "${elementText}"`);
|
|
}
|
|
|
|
//font
|
|
if (elementFont === 'Poppins, sans-serif') {
|
|
console.log('Passed: Items column title font-family matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Items column title font-family "Poppins, sans-serif"; Actual: ${elementFont}`);
|
|
}
|
|
|
|
//size
|
|
if (elementSize === '13px') {
|
|
console.log('Passed: Items column title text font-size matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Items column title text font-size "13px"; Actual: "${elementSize}"`);
|
|
}
|
|
|
|
//color
|
|
if (elementColor === 'rgba(40, 39, 90, 1)') {
|
|
console.log('Passed: Items column title text color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Items column 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'));
|
|
}
|
|
}
|
|
},
|
|
|
|
//Status column title
|
|
{
|
|
description: 'Status column title text, size, and color',
|
|
action: async () => {
|
|
const multipleChecks = 'Status column title';
|
|
|
|
const element = await driver.findElement(By.css('.batch-table-clean th:nth-child(3)'));
|
|
|
|
//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 === 'Status') {
|
|
console.log('Passed: Status column title text matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Column title to be: "Status"; Actual: "${elementText}"`);
|
|
}
|
|
|
|
//font
|
|
if (elementFont === 'Poppins, sans-serif') {
|
|
console.log('Passed: Status column title font-family matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Status column title font-family "Poppins, sans-serif"; Actual: ${elementFont}`);
|
|
}
|
|
|
|
//size
|
|
if (elementSize === '13px') {
|
|
console.log('Passed: Status column title text font-size matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Status column title text font-size "13px"; Actual: "${elementSize}"`);
|
|
}
|
|
|
|
//color
|
|
if (elementColor === 'rgba(40, 39, 90, 1)') {
|
|
console.log('Passed: Status column title text color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Status column 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'));
|
|
}
|
|
}
|
|
},
|
|
|
|
//Uploaded On column title
|
|
{
|
|
description: 'Uploaded On column title text, size, and color',
|
|
action: async () => {
|
|
const multipleChecks = 'Uploaded On column title';
|
|
|
|
const element = await driver.findElement(By.css('th:nth-child(4)'));
|
|
|
|
//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 === 'Uploaded On') {
|
|
console.log('Passed: Uploaded On column title text matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Column title to be: "Uploaded On"; Actual: "${elementText}"`);
|
|
}
|
|
|
|
//font
|
|
if (elementFont === 'Poppins, sans-serif') {
|
|
console.log('Passed: Uploaded On column title font-family matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Uploaded On column title font-family "Poppins, sans-serif"; Actual: ${elementFont}`);
|
|
}
|
|
|
|
//size
|
|
if (elementSize === '13px') {
|
|
console.log('Passed: Uploaded On column title text font-size matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Uploaded On column title text font-size "13px"; Actual: "${elementSize}"`);
|
|
}
|
|
|
|
//color
|
|
if (elementColor === 'rgba(40, 39, 90, 1)') {
|
|
console.log('Passed: Uploaded On column title text color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Uploaded On column 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'));
|
|
}
|
|
}
|
|
},
|
|
|
|
//Completed On column title
|
|
{
|
|
description: 'Completed On column title text, size, and color',
|
|
action: async () => {
|
|
const multipleChecks = 'Completed On column title';
|
|
|
|
const element = await driver.findElement(By.css('th:nth-child(5)'));
|
|
|
|
//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 === 'Completed On') {
|
|
console.log('Passed: Completed On column title text matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Column title to be: "Completed On"; Actual: "${elementText}"`);
|
|
}
|
|
|
|
//font
|
|
if (elementFont === 'Poppins, sans-serif') {
|
|
console.log('Passed: Completed On column title font-family matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Completed On column title font-family "Poppins, sans-serif"; Actual: ${elementFont}`);
|
|
}
|
|
|
|
//size
|
|
if (elementSize === '13px') {
|
|
console.log('Passed: Completed On column title text font-size matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Completed On column title text font-size "13px"; Actual: "${elementSize}"`);
|
|
}
|
|
|
|
//color
|
|
if (elementColor === 'rgba(40, 39, 90, 1)') {
|
|
console.log('Passed: Completed On column title text color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Completed On column 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'));
|
|
}
|
|
}
|
|
},
|
|
|
|
//Actions column title
|
|
{
|
|
description: 'Actions On column title text, size, and color',
|
|
action: async () => {
|
|
const multipleChecks = 'Actions On column title';
|
|
|
|
const element = await driver.findElement(By.css('th:nth-child(6)'));
|
|
|
|
//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 === 'Actions') {
|
|
console.log('Passed: Actions column title text matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Column title to be: "Actions"; Actual: "${elementText}"`);
|
|
}
|
|
|
|
//font
|
|
if (elementFont === 'Poppins, sans-serif') {
|
|
console.log('Passed: Actions column title font-family matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Actions column title font-family "Poppins, sans-serif"; Actual: ${elementFont}`);
|
|
}
|
|
|
|
//size
|
|
if (elementSize === '13px') {
|
|
console.log('Passed: Actions column title text font-size matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Actions column title text font-size "13px"; Actual: "${elementSize}"`);
|
|
}
|
|
|
|
//color
|
|
if (elementColor === 'rgba(40, 39, 90, 1)') {
|
|
console.log('Passed: Actions column title text color matched as expected');
|
|
} else {
|
|
errors.push(`Expected: Actions column 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'));
|
|
}
|
|
}
|
|
},
|
|
|
|
//UPLOAD FILE LIST
|
|
//Row count
|
|
{
|
|
description: 'Upload list row count',
|
|
action: async () => {
|
|
const rows = await driver.findElements(By.css('.batch-table-clean tbody tr'));
|
|
|
|
if (rows.length === expectedUploads.length) {
|
|
console.log(`Passed: Upload list row count matched as expected (${rows.length})`);
|
|
} else {
|
|
throw new Error(`Expected: Upload list to have ${expectedUploads.length} rows; Actual: ${rows.length}`);
|
|
}
|
|
}
|
|
},
|
|
|
|
//One step per expected row: Upload Name, Items, Status, Uploaded On, Completed On, and Actions
|
|
...expectedUploads.map((expected, index) => ({
|
|
description: `Upload list row ${index + 1} (${expected.uploadName}) values`,
|
|
action: async () => {
|
|
const multipleChecks = `Upload list row ${index + 1}`;
|
|
|
|
const row = await driver.findElement(By.css(`.batch-table-clean tbody tr:nth-child(${index + 1})`));
|
|
const cells = await row.findElements(By.css('td'));
|
|
|
|
//Track all errors
|
|
const errors = [];
|
|
|
|
//Text columns
|
|
const columns = [
|
|
{ name: 'Upload Name', expected: expected.uploadName, cell: cells[0] },
|
|
{ name: 'Items', expected: expected.items, cell: cells[1] },
|
|
{ name: 'Status', expected: expected.status, cell: cells[2] },
|
|
{ name: 'Uploaded On', expected: expected.uploadedOn, cell: cells[3] },
|
|
{ name: 'Completed On', expected: expected.completedOn, cell: cells[4] },
|
|
];
|
|
|
|
for (const column of columns) {
|
|
const actual = column.cell ? (await column.cell.getText()).trim() : '(cell missing)';
|
|
if (actual === column.expected) {
|
|
console.log(`Passed: ${multipleChecks} ${column.name} matched as expected`);
|
|
} else {
|
|
errors.push(`Expected: ${multipleChecks} ${column.name} to be: "${column.expected}"; Actual: "${actual}"`);
|
|
}
|
|
}
|
|
|
|
//Actions - kebab button displayed with aria-label "Actions"
|
|
const actionButtons = cells[5] ? await cells[5].findElements(By.css('.kebab-wrap .kebab-btn')) : [];
|
|
if (actionButtons.length > 0 && await actionButtons[0].isDisplayed()) {
|
|
const ariaLabel = await actionButtons[0].getAttribute('aria-label');
|
|
if (ariaLabel === 'Actions') {
|
|
console.log(`Passed: ${multipleChecks} Actions button was displayed as expected`);
|
|
} else {
|
|
errors.push(`Expected: ${multipleChecks} Actions button aria-label to be: "Actions"; Actual: "${ariaLabel}"`);
|
|
}
|
|
} else {
|
|
errors.push(`Expected: ${multipleChecks} Actions button was not displayed`);
|
|
}
|
|
|
|
//Throw summary if any validation failed
|
|
if (errors.length > 0) {
|
|
//Add summary line only when multiple checks failed
|
|
if (errors.length > 1) {
|
|
errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`);
|
|
}
|
|
|
|
//Throw collected messages — catch() will prefix with "FAILED:"
|
|
throw new Error(errors.join('\n'));
|
|
}
|
|
}
|
|
}
|
|
)
|
|
),
|
|
|
|
//FOOTER
|
|
//EdGate Copyright Logo
|
|
{
|
|
description: 'EdGate Copyright Logo',
|
|
action: async () => {
|
|
const multipleChecks = 'EdGate Copyright Logo';
|
|
|
|
const element = await driver.findElement(By.css('footer .pull-right > a'));
|
|
const elementLogo = await element.findElement(By.css('img'));
|
|
const expectedHref = 'https://www.edgate.com/';
|
|
|
|
//Track all errors
|
|
const errors = [];
|
|
|
|
//icon present
|
|
if (await elementLogo.isDisplayed()) {
|
|
console.log('Passed: EdGate Copyright Logo was displayed as expected');
|
|
} else {
|
|
errors.push('Expected: EdGate Copyright Logo was not displayed');
|
|
}
|
|
|
|
//href - browser resolves the link with a trailing slash, so remove it before comparing
|
|
const actualHref = await element.getAttribute('href');
|
|
if (actualHref && actualHref === expectedHref) {
|
|
console.log('Passed: EdGate Copyright Logo href matched as expected');
|
|
} else {
|
|
errors.push(`Expected: EdGate Copyright Logo href to be: "https://www.edgate.com/"; actual: "${actualHref}"`);
|
|
}
|
|
|
|
//Throw summary if any validation failed
|
|
if (errors.length > 0) {
|
|
//Add summary line only when multiple checks failed
|
|
if (errors.length > 1) {
|
|
errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`);
|
|
}
|
|
|
|
//Throw collected messages — catch() will prefix with "FAILED:"
|
|
throw new Error(errors.join('\n'));
|
|
}
|
|
}
|
|
},
|
|
|
|
//NEXT ACTION
|
|
{
|
|
description: 'Log Out',
|
|
action: async () => {
|
|
const multipleChecks = 'Log Out';
|
|
|
|
//Track all errors
|
|
const errors = [];
|
|
|
|
await driver.findElement(By.css('#navbarDropdown > span')).click();
|
|
await driver.sleep(2000);
|
|
await driver.findElement(By.linkText('Log Out')).click();
|
|
console.log('----->| NEXT ACTION: Clicked User Profile and Logged Out');
|
|
|
|
//Wait until the element exists in the DOM
|
|
const exactLogo = await driver.wait(
|
|
until.elementLocated(By.css('.logo')),
|
|
30000
|
|
);
|
|
|
|
//Wait until it becomes visible
|
|
await driver.wait(
|
|
until.elementIsVisible(exactLogo),
|
|
30000
|
|
);
|
|
|
|
//Wait for page to load completely
|
|
await driver.wait(async () => {
|
|
const readyState = await driver.executeScript('return document.readyState');
|
|
return readyState === 'complete';
|
|
}, 30000, 'ExACT Langing page did not fully load within 30 seconds');
|
|
console.log('Passed: ExACT Landing Page loaded successfully');
|
|
|
|
//Throw summary if any validation failed
|
|
if (errors.length > 0) {
|
|
//Add summary line only when multiple checks failed
|
|
if (errors.length > 1) {
|
|
errors.unshift(`${multipleChecks} - Multiple validation checks did not pass`);
|
|
}
|
|
|
|
//Throw collected messages — catch() will prefix with "FAILED:"
|
|
throw new Error(errors.join('\n'));
|
|
}
|
|
}
|
|
},
|
|
];
|
|
|
|
const logStep = (worksheet, stepDescription, status, stepIndex, timestamp, screenshotPath) => {
|
|
const json_data = XLSX.utils.sheet_to_json(worksheet, { header: 1 });
|
|
json_data.push([stepIndex, stepDescription, status, timestamp, screenshotPath]);
|
|
return XLSX.utils.aoa_to_sheet(json_data);
|
|
};
|
|
|
|
const takeScreenshot = async (driver, stepIndex, stepDescription) => {
|
|
const screenshot = await driver.takeScreenshot();
|
|
|
|
const dir = path.join('screenshots', 'uploadBatchUploadPage');
|
|
|
|
const screenshotFileName = `step_${stepIndex}_${stepDescription.replace(/\s+/g, '_')}.png`;
|
|
const screenshotPath = path.join(dir, screenshotFileName);
|
|
fs.writeFileSync(screenshotPath, screenshot, 'base64');
|
|
return screenshotPath;
|
|
};
|
|
|
|
const resultsFile = path.join('results', 'uploadBatchUploadPage.xlsx');
|
|
|
|
const clearOldResults = () => {
|
|
//Remove old screenshots
|
|
const screenshotDir = path.join('screenshots', 'uploadBatchUploadPage');
|
|
if (fs.existsSync(screenshotDir)) {
|
|
fs.rmSync(screenshotDir, { recursive: true, force: true });
|
|
}
|
|
fs.mkdirSync(screenshotDir, { recursive: true });
|
|
|
|
//Remove old Excel file
|
|
if (fs.existsSync(resultsFile)) {
|
|
fs.unlinkSync(resultsFile);
|
|
}
|
|
fs.mkdirSync('results', { recursive: true });
|
|
};
|
|
|
|
try {
|
|
//Initialize workbook and worksheet
|
|
clearOldResults();
|
|
|
|
//Initialize workbook and worksheet
|
|
workbook = XLSX.utils.book_new();
|
|
worksheet = XLSX.utils.aoa_to_sheet([
|
|
['Step Number', 'Step Description', 'Status', 'Timestamp', 'Screenshot']
|
|
]);
|
|
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
|
|
|
|
//Log test start time
|
|
worksheet = logStep(worksheet, 'Test Start', 'Started', '', startTime, '');
|
|
|
|
let allStepsPassed = true;
|
|
|
|
const failedSteps = []; //Track failed steps
|
|
|
|
for (const step of steps) {
|
|
const stepIndex = steps.indexOf(step) + 1;
|
|
const timestamp = new Date().toISOString();
|
|
|
|
try {
|
|
//Screenshot of failed step
|
|
await step.action();
|
|
|
|
//Log a successful step with no screenshot
|
|
worksheet = logStep(
|
|
worksheet,
|
|
step.description,
|
|
'Passed',
|
|
stepIndex,
|
|
timestamp,
|
|
null //No screenshot for passed steps
|
|
);
|
|
|
|
} catch (error) {
|
|
//Only take screenshot if the step fails
|
|
const screenshotPath = await takeScreenshot(
|
|
driver,
|
|
stepIndex,
|
|
`${step.description}_Failed`
|
|
);
|
|
|
|
worksheet = logStep(
|
|
worksheet,
|
|
step.description,
|
|
'Failed',
|
|
stepIndex,
|
|
timestamp,
|
|
screenshotPath
|
|
);
|
|
|
|
console.error(`Step ${stepIndex} FAILED: ${error.message}`);
|
|
failedSteps.push(`Step ${stepIndex}: ${step.description} - ${error.message}`); //Track failed step
|
|
testStatus = 'Failed';
|
|
allStepsPassed = false;
|
|
}
|
|
}
|
|
|
|
if (allStepsPassed) {
|
|
console.log('------------->| THE END |<-------------');
|
|
console.log('PASSED: Upload - Batch Upload Page(uploadBatchUploadPage); All test steps completed successfully');
|
|
testStatus = 'Passed';
|
|
} else {
|
|
console.log('------------->| THE END |<-------------');
|
|
console.log('FAILED: Upload - Batch Upload Page(uploadBatchUploadPage); One or more test steps failed');
|
|
console.log('FAILED STEPS:');
|
|
failedSteps.forEach(step => console.error(` ✗ ${step}`));
|
|
testStatus = 'Failed';
|
|
}
|
|
|
|
//Log test end time
|
|
const endTime = new Date().toISOString();
|
|
worksheet = logStep(worksheet, 'Test End', testStatus, '', endTime, '');
|
|
|
|
//Write the updated worksheet back to the workbook and save it
|
|
workbook.Sheets['Sheet1'] = worksheet;
|
|
XLSX.writeFile(workbook, resultsFile);
|
|
} finally {
|
|
await driver.quit();
|
|
}
|
|
})();
|
|
}
|
|
|
|
export default uploadBatchUploadPage;
|