Added Framework Management Script

This commit is contained in:
2025-04-04 15:08:31 -07:00
parent 5338ce0a1e
commit 371bb2024b
3 changed files with 396 additions and 0 deletions

Binary file not shown.

View File

@@ -12,6 +12,8 @@ import ExACT_alignContentPage from './tests/ExACT_alignContentPage.js';
import ExACT_alignStandardsPage from './tests/ExACT_alignStandardsPage.js';
import ExACT_editItemAddConcept from './tests/ExACT_editItemAddConcept.js';
import ExACT_alignConceptsPage from './tests/ExACT_alignConceptsPage.js';
//Framework
import ExACT_frameworkManagementPage from './tests/ExACT_frameworkManagementPage.js';
const app = express();
@@ -43,6 +45,9 @@ app.get('/', (req, res) => {
<br><div style="padding:3px;"><strong><a href='/ExACT_editItemAddConcept' target='_blank'>Align - Add Concepts/Correlate</a></strong></div>
<br><div style="padding:3px;"><strong><a href='/ExACT_alignConceptsPage' target='_blank'>Align Concepts</a></strong></div>
<h1 style="text-align:center; color:#055a8c; font-size:20px; ">FRAMEWORKS</h1>
<div style="padding:3px;"><strong><a href='/ExACT_frameworkManagementPage' target='_blank'>Framework Management Page</a></strong></div>
<br>
</div>
`);
@@ -64,6 +69,8 @@ app.get('/ExACT_contentPage', ExACT_contentPage);
app.get('/ExACT_alignStandardsPage', ExACT_alignStandardsPage);
app.get('/ExACT_editItemAddConcept', ExACT_editItemAddConcept);
app.get('/ExACT_alignConceptsPage', ExACT_alignConceptsPage);
//Framework
app.get('/ExACT_frameworkManagementPage', ExACT_frameworkManagementPage);
app.listen(8000, () => {
console.log('Server is running on port 8000');

View File

@@ -0,0 +1,389 @@
import { Builder, By, Key, until } from 'selenium-webdriver';
import fs from 'fs';
import XLSX from 'xlsx';
import path from 'path';
const ExACT_frameworkManagementPage = (req, res) => {
res.send('<h2>ExACT Automated Test Script - Framework Management 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 Framework Management page
{ description: 'Click Frameworks navigation link', action: async () => await driver.findElement(By.linkText('Frameworks')).click() },
//Wait for page to load - Correlation Coverages View Details button
{
description: 'Wait for page to load',
action: async () => {
return await driver.wait(until.elementLocated(By.css('h2')), 10000).catch(() => false);
}
},
//Framework Management page title
{
description: 'Validate Framework Management page title',
action: async () => {
const elementText = await driver.findElement(By.css('h2')).getText();
if (elementText !== 'Framework Management') {
throw new Error(`Expected: "Framework Management"; Actual: "${elementText}"`);
}
console.log('Passed: Framework Management page title matched as expected');
}
},
//Framework Management page title text color -dark blue
{
description: 'Validate Framework Management 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(`Framework Management page title text color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Framework Management page title text color matched as expected');
}
},
//Framework Management page title text font
{
description: 'Validate Framework Management page title text font size',
action: async () => {
const elementStyle = await driver.findElement(By.css('h2')).getCssValue('font-size');
if (elementStyle !== '32px') {
throw new Error(`Framework Management page title text font-size did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Framework Management page title text font-size matched as expected');
}
},
//Publishing button icon
{
description: 'Verify Publishing buttion icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('.btn > .fa-cloud-upload')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('Publishing button icon not found');
}
console.log('Passed: Publishing button icon present');
}
},
//Publishing button text
{
description: 'Validate Publishing button text',
action: async () => {
const elementText = await driver.findElement(By.linkText('Publishing')).getText();
if (elementText !== 'Publishing') {
throw new Error(`Expected: "Publishing" button text; Actual: "${elementText}"`);
}
console.log('Passed: Publsining button text matched as expected');
}
},
//Publishing button color -green
{
description: 'Validate Publishing button color',
action: async () => {
const elementStyle = await driver.findElement(By.linkText('Publishing')).getCssValue('background-color');
if (elementStyle !== 'rgba(48, 200, 172, 1)') {
throw new Error(`Publishing button color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Publishing button color matched as expected');
}
},
//Import Framework button icon
{
description: 'Verify Import Framework buttion icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('.fa-upload')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('Import Framework button icon not found');
}
console.log('Passed: Import Framework button icon present');
}
},
//Import Framework button text
{
description: 'Validate Import Framework button text',
action: async () => {
const elementText = await driver.findElement(By.linkText('Import Framework')).getText();
if (elementText !== 'Import Framework') {
throw new Error(`Expected: "Import Framework" button text; Actual: "${elementText}"`);
}
console.log('Passed: Import Framework button text matched as expected');
}
},
//Import Framework button color -green
{
description: 'Validate Import Framework button color',
action: async () => {
const elementStyle = await driver.findElement(By.linkText('Import Framework')).getCssValue('background-color');
if (elementStyle !== 'rgba(48, 200, 172, 1)') {
throw new Error(`Import Framework button color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Import Framework button color matched as expected');
}
},
//Create button icon
{
description: 'Verify Create buttion icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('.fa-plus-circle')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('Create button icon not found');
}
console.log('Passed: Create button icon present');
}
},
//Create button text
{
description: 'Validate Create button text',
action: async () => {
const elementText = await driver.findElement(By.linkText('Create')).getText();
if (elementText !== 'Create') {
throw new Error(`Expected: "Create" button text; Actual: "${elementText}"`);
}
console.log('Passed: Create button text matched as expected');
}
},
//Create button color -green
{
description: 'Validate Create button color',
action: async () => {
const elementStyle = await driver.findElement(By.linkText('Create')).getCssValue('background-color');
if (elementStyle !== 'rgba(48, 200, 172, 1)') {
throw new Error(`Create button color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Create button color matched as expected');
}
},
//Search textbox
{
description: 'Verify Search textbox is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('#FilterOrganization')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('Search textbox not found');
}
console.log('Passed: Search textbox present');
}
},
//Search textbox icon
{
description: 'Verify Search textbox icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('.fa-times')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('Search textbox icon not found');
}
console.log('Passed: Search textbox icon present');
}
},
//Advanced Search button icon
{
description: 'Verify Advanced Search buttion icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('.fa-plus-circle')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('Advanced Search button icon not found');
}
console.log('Passed: Advanced Search button icon present');
}
},
//Advanced Search button text
{
description: 'Validate Advanced Search button text',
action: async () => {
const elementText = await driver.findElement(By.css('.bg-green')).getText();
if (elementText !== 'Advanced Search') {
throw new Error(`Expected: "Advanced Search" button text; Actual: "${elementText}"`);
}
console.log('Passed: Advanced Search button text matched as expected');
}
},
//Advanced Search button color -green (slightly different green color)
{
description: 'Validate Advanced Search button color',
action: async () => {
const elementStyle = await driver.findElement(By.css('.bg-green')).getCssValue('background-color');
if (elementStyle !== 'rgba(26, 187, 156, 1)') {
throw new Error(`Advanced Search button color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Advanced Search button color matched as expected');
}
},
//LOG OUT
//NEXT ACTION - Log out
{ description: 'Click Username dropdown', action: async () => await driver.findElement(By.css('#navbarDropdown > span')).click() },
{ description: 'Wait action to complete', action: async () => await driver.sleep(2000) },
//Log Out icon
{
description: 'Verify Log Out icon is present',
action: async () =>
{ const expectedIcon = await driver.wait(until.elementLocated(By.css('.fa-sign-out')), 5000).catch(() => false);
if (!expectedIcon) {
throw new Error('Log Out icon not found');
}
console.log('Passed: Log Out icon present');
}
},
{ description: 'Click Log Out link', action: async () => await driver.findElement(By.linkText('Log Out')).click() },
//Wait for login screen to load
{
description: 'Wait for log out process to complete',
action: async () => {
return await driver.wait(until.elementLocated(By.css('.login')), 10000).catch(() => false);
}
},
];
const logStep = (worksheet, stepDescription, status, stepIndex, timestamp, screenshotPath) => {
const json_data = XLSX.utils.sheet_to_json(worksheet, { header: 1 });
json_data.push([stepIndex, stepDescription, status, timestamp, screenshotPath]);
return XLSX.utils.aoa_to_sheet(json_data);
};
const takeScreenshot = async (driver, stepIndex, stepDescription) => {
const screenshot = await driver.takeScreenshot();
const dir = path.join('screenshots', 'frameworkManagementPage');
const screenshotFileName = `step_${stepIndex}_${stepDescription.replace(/\s+/g, '_')}.png`;
const screenshotPath = path.join(dir, screenshotFileName);
fs.writeFileSync(screenshotPath, screenshot, 'base64');
return screenshotPath;
};
const clearOldResults = () => {
// Remove old screenshots
const screenshotDir = path.join('screenshots', 'frameworkManagementPage');
if (fs.existsSync(screenshotDir)) {
fs.rmSync(screenshotDir, { recursive: true, force: true });
}
fs.mkdirSync(screenshotDir, { recursive: true });
// Remove old Excel file
if (fs.existsSync('frameworkManagementPageResults.xlsx')) {
fs.unlinkSync('frameworkManagementPageResults.xlsx');
}
};
try {
// Initialize workbook and worksheet
clearOldResults();
// Initialize workbook and worksheet
workbook = XLSX.utils.book_new();
worksheet = XLSX.utils.aoa_to_sheet([
['Step Number', 'Step Description', 'Status', 'Timestamp', 'Screenshot']
]);
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Log test start time
worksheet = logStep(worksheet, 'Test Start', 'Started', '', startTime, '');
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 loginButton = await driver.wait(until.elementLocated(By.css('.login')), 5000).catch(() => false);
if (loginButton) {
console.log('COMPLETED Script: frameworkManagementPage');
testStatus = 'Passed';
} else {
console.log('FAILED: Unable to complete frameworkManagementPage script');
testStatus = 'Failed';
}
// Log test end time
const endTime = new Date().toISOString();
worksheet = logStep(worksheet, 'Test End', testStatus, '', endTime, '');
// Write the updated worksheet back to the workbook and save it
workbook.Sheets['Sheet1'] = worksheet;
XLSX.writeFile(workbook, 'frameworkManagementPageResults.xlsx');
} finally {
await driver.quit();
}
})();
}
export default ExACT_frameworkManagementPage;