Updated scripts

This commit is contained in:
2024-10-18 18:20:57 -07:00
parent 1272b1fdf9
commit b5c8c560d0
3 changed files with 261 additions and 156 deletions

View File

@@ -2,7 +2,6 @@ import { Builder, By, Key, until } from 'selenium-webdriver';
import fs from 'fs';
import XLSX from 'xlsx';
import path from 'path';
import { assert } from 'console';
const ExACT_dashboardMyContent = (req, res) => {
res.send('<h2>ExACT Automated Test Script - Dashboard - My Content: Initiated</h2>');
@@ -15,41 +14,28 @@ const ExACT_dashboardMyContent = (req, res) => {
//Page title
const expectedDashboardTitle = 'Correlation Dashboard';
const expectedDashboardTitleColor = 'rgba(40, 39, 90, 1)'; //navy blue
const expectedDashboardTitleFont = '32px';
//My Content widget
const expectedMyContentWidgetTitle = 'My Content';
const expectedWidgetTitleColor = 'rgba(40, 39, 90, 1)'; //navy blue
const expectedWidgetTitleFont = '18px';
//Ellipsis
const expectedEllipsisIconColor = 'rgba(40, 39, 90, 1)'; //navy blue
//Create Content
const expectedCreateContentSetIconColor = 'rgba(33, 37, 41, 1)'; //navy blue (different?)
const expectedCreateContentSetLinkText = 'Create Content Set';
const expectedCreateContentSetLinkTextColor = 'rgba(33, 37, 41, 1)'; //navy blue (different?)
//Export Content
const expectedExportContentSetIconColor = 'rgba(33, 37, 41, 1)'; //navy blue (different?)
const expectedExportContentSetLinkText = 'Export Content Set';
const expectedExportContentSetLinkTextColor = 'rgba(33, 37, 41, 1)'; //navy blue (different?)
//Filter
const expectedSearchIconColor = 'rgba(40, 39, 90, 1)'; //navy blue
const expectedFilterPlaceholder = 'filter...';
//Sort
const expectedSortLabel = 'Sort:';
const expectedSortDropDown = 'count';
//Content
const expectedBiologyQA = 'Biology - QA';
const expectedBiologyQACount = '1046';
//Edit Content Set
const expectedEditDIVTitle = 'Edit Content Set';
const expectedBiologyQALink = 'Biology - QA';
const expectedBiologyQACountLink = '1046';
//Edit Content Set DIV
const expectedEditDIVLabel = 'Content Set Name';
const expectedEditDIVTextbox = 'Biology - QA';
const expectedCreatedDIVTextbox = 'Automated Content Set - To be deleted'
const expectedEditDIVDeleteBtn = 'Delete';
const expectedEditDIVDeleteBtnColor = 'rgba(220, 53, 69, 1)'; //red
const expectedEditDIVSaveBtn = 'Save';
const expectedEditDIVSaveBtnColor = 'rgba(48, 200, 172, 1)'; //gren
const expectedEditDIVCloseBtn = 'Close';
const expectedEditDIVCloseBtnColor = 'rgba(0, 0, 0, 0)'; //white
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
@@ -73,13 +59,13 @@ const steps = [
}
},
//Dashboard title text color
//Dashboard title text color -navy blue
{
description: 'Validate dashboard title text color',
action: async () => {
const elementStyle = await driver.findElement(By.css('.e-heading')).getCssValue('color');
if (elementStyle !== expectedDashboardTitleColor) {
throw new Error(`Dashboard title text color Expected: "${expectedDashboardTitleColor}"; Actual: "${elementStyle}"`);
if (elementStyle !== 'rgba(40, 39, 90, 1)') {
throw new Error(`Dashboard title text color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Dashboard title text color matched as expected');
}
@@ -90,8 +76,8 @@ const steps = [
description: 'Validate dashboard title text font size',
action: async () => {
const elementStyle = await driver.findElement(By.css('.e-heading')).getCssValue('font-size');
if (elementStyle !== expectedDashboardTitleFont) {
throw new Error(`Expected: "${expectedDashboardTitleFont}"; Actual: "${elementStyle}"`);
if (elementStyle !== '32px') {
throw new Error(`Dashboard title text fond-size did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Dashboard title text font-size matched as expected');
}
@@ -109,13 +95,13 @@ const steps = [
}
},
//Widget title text color
//Widget title text color -navy blue
{
description: 'Validate widget title text color',
action: async () => {
const elementStyle = await driver.findElement(By.css('.h-100 h2:nth-child(2)')).getCssValue('color');
if (elementStyle !== expectedWidgetTitleColor) {
throw new Error(`Widget title text color Expected: "${expectedWidgetTitleColor}"; Actual: "${elementStyle}"`);
if (elementStyle !== 'rgba(40, 39, 90, 1)') {
throw new Error(`Widget title text color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Widget title text color matched as expected');
}
@@ -126,32 +112,32 @@ const steps = [
description: 'Validate widget title text font size',
action: async () => {
const elementStyle = await driver.findElement(By.css('.h-100 h2:nth-child(2)')).getCssValue('font-size');
if (elementStyle !== expectedWidgetTitleFont) {
throw new Error(`Expected: "${expectedWidgetTitleFont}"; Actual: "${elementStyle}"`);
if (elementStyle !== '18px') {
throw new Error(`Widget title text font-size did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Widget title text font-size matched as expected');
}
},
//Ellipsis icon color
//Ellipsis icon color -navy blue
{
description: 'Validate ellipsis icon color',
action: async () => {
const elementStyle = await driver.findElement(By.css('.fa-ellipsis-h')).getCssValue('color');
if (elementStyle !== expectedEllipsisIconColor) {
throw new Error(`Ellipsis icon color Expected: "${expectedEllipsisIconColor}"; Actual: "${elementStyle}"`);
if (elementStyle !== 'rgba(40, 39, 90, 1)') {
throw new Error(`Ellipsis icon color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Ellipsis icon color matched as expected');
}
},
//Search icon color
//Search icon color -dark blue
{
description: 'Validate search icon color',
action: async () => {
const elementStyle = await driver.findElement(By.css('.col-12 > .fa')).getCssValue('color');
if (elementStyle !== expectedSearchIconColor) {
throw new Error(`Search icon color Expected: "${expectedSearchIconColor}"; Actual: "${elementStyle}"`);
if (elementStyle !== 'rgba(40, 39, 90, 1)') {
throw new Error(`Search icon color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Search icon color matched as expected');
}
@@ -198,8 +184,8 @@ const steps = [
description: 'Validate Biology-QA title',
action: async () => {
const elementText = await driver.findElement(By.linkText('Biology - QA')).getText();
if (elementText !== expectedBiologyQA) {
throw new Error(`Expected: "${expectedBiologyQA}"; Actual: "${elementText}"`);
if (elementText !== expectedBiologyQALink) {
throw new Error(`Expected: "${expectedBiologyQALink}"; Actual: "${elementText}"`);
}
console.log('Passed: Biology-QA title matched as expected');
}
@@ -222,8 +208,8 @@ const steps = [
description: 'Validate Biology-QA count',
action: async () => {
const elementText = await driver.findElement(By.css('#mycontentlist > #content-org-list > .content-org .badge')).getText();
if (elementText !== expectedBiologyQACount) {
throw new Error(`Expected: "${expectedBiologyQACount}"; Actual: "${elementText}"`);
if (elementText !== expectedBiologyQACountLink) {
throw new Error(`Expected: "${expectedBiologyQACountLink}"; Actual: "${elementText}"`);
}
console.log('Passed: Biology-QA count matched as expected');
}
@@ -231,15 +217,22 @@ const steps = [
//Add Content Set
{ description: 'Click Biology-QA edit icon', action: async () => await driver.findElement(By.css('#mycontentlist > #content-org-list > .content-org .fa')).click() },
{ description: 'Driver sleep', action: async () => await driver.sleep(2000) },
//Wait for DIV
{
description: 'Wait for DIV to open',
action: async () => {
return await driver.wait(until.elementLocated(By.css('.modal-content .modal-title')), 50000).catch(() => false);
}
},
//Edit Content Set DIV
{
description: 'Validate edit DIV title',
action: async () => {
const elementText = await driver.findElement(By.css('.modal-title')).getText();
if (elementText !== expectedEditDIVTitle) {
throw new Error(`Expected: "${expectedEditDIVTitle}"; Actual: "${elementText}"`);
const elementText = await driver.findElement(By.css('.modal-content .modal-title')).getText();
if (elementText !== 'Edit Content Set') {
throw new Error(`Edit DIV title did not match; Actual: "${elementText}"`);
}
console.log('Passed: Edit DIV title matched as expected');
}
@@ -281,13 +274,13 @@ const steps = [
}
},
//Edit Content Set DIV - Delete button color
//Edit Content Set DIV - Delete button color -red
{
description: 'Validate edit DIV delete button color',
action: async () => {
const elementStyle = await driver.findElement(By.css('#orgdelete')).getCssValue('background-color');
if (elementStyle !== expectedEditDIVDeleteBtnColor) {
throw new Error(`Edit DIV delete button color Expected: "${expectedEditDIVDeleteBtnColor}"; Actual: "${elementStyle}"`);
if (elementStyle !== 'rgba(220, 53, 69, 1)') {
throw new Error(`Edit DIV delete button color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Edit DIV delete button color matched as expected');
}
@@ -305,13 +298,13 @@ const steps = [
}
},
//Edit Content Set DIV - Save button color
//Edit Content Set DIV - Save button color -green
{
description: 'Validate edit DIV save button color',
action: async () => {
const elementStyle = await driver.findElement(By.css('#modalop')).getCssValue('background-color');
if (elementStyle !== expectedEditDIVSaveBtnColor) {
throw new Error(`Edit DIV save button color Expected: "${expectedEditDIVSaveBtnColor}"; Actual: "${elementStyle}"`);
if (elementStyle !== 'rgba(48, 200, 172, 1)') {
throw new Error(`Edit DIV save button color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Edit DIV save button color matched as expected');
}
@@ -329,13 +322,13 @@ const steps = [
}
},
//Edit Content Set DIV - Close button color
//Edit Content Set DIV - Close button color -white
{
description: 'Validate edit DIV close button color',
action: async () => {
const elementStyle = await driver.findElement(By.css('#modalclose')).getCssValue('background-color');
if (elementStyle !== expectedEditDIVCloseBtnColor) {
throw new Error(`Edit DIV close button color Expected: "${expectedEditDIVCloseBtnColor}"; Actual: "${elementStyle}"`);
if (elementStyle !== 'rgba(0, 0, 0, 0)') {
throw new Error(`Edit DIV close button color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Edit DIV close button color matched as expected');
}
@@ -348,13 +341,13 @@ const steps = [
{ description: 'Click ellipsis icon', action: async () => await driver.findElement(By.css('.fa-ellipsis-h')).click() },
{ description: 'Driver sleep', action: async () => await driver.sleep(2000) },
//Create Content Set icon color
//Create Content Set icon color -dark blue
{
description: 'Validate create content set icon color',
action: async () => {
const elementStyle = await driver.findElement(By.css('.fa-plus')).getCssValue('color');
if (elementStyle !== expectedCreateContentSetIconColor) {
throw new Error(`Create Content Set icon color Expected: "${expectedCreateContentSetIconColor}"; Actual: "${elementStyle}"`);
if (elementStyle !== 'rgba(33, 37, 41, 1)') {
throw new Error(`Create Content Set icon color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Create Content Set icon color matched as expected');
}
@@ -372,25 +365,25 @@ const steps = [
}
},
//Create Content Set link text color
//Create Content Set link text color -dark blue
{
description: 'Validate create content set link text color',
action: async () => {
const elementStyle = await driver.findElement(By.linkText('Create Content Set')).getCssValue('color');
if (elementStyle !== expectedCreateContentSetLinkTextColor) {
throw new Error(`Create Content Set link text color Expected: "${expectedCreateContentSetLinkTextColor}"; Actual: "${elementStyle}"`);
if (elementStyle !== 'rgba(33, 37, 41, 1)') {
throw new Error(`Create Content Set link text color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Create Content Set link text color matched as expected');
}
},
//Export Content Set icon color
//Export Content Set icon color -dark blue
{
description: 'Validate export content set icon color',
action: async () => {
const elementStyle = await driver.findElement(By.css('.fa-download')).getCssValue('color');
if (elementStyle !== expectedExportContentSetIconColor) {
throw new Error(`Export Content icon color Expected: "${expectedExportContentSetIconColor}"; Actual: "${elementStyle}"`);
if (elementStyle !== 'rgba(33, 37, 41, 1)') {
throw new Error(`Export Content icon color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Export Content icon color matched as expected');
}
@@ -408,17 +401,155 @@ const steps = [
}
},
//Export Content Set link text color
//Export Content Set link text color -dark blue
{
description: 'Validate export content set link text color',
action: async () => {
const elementStyle = await driver.findElement(By.linkText('Export Content Set')).getCssValue('color');
if (elementStyle !== expectedExportContentSetLinkTextColor) {
throw new Error(`Export Content Set icon color Expected: "${expectedExportContentSetLinkTextColor}"; Actual: "${elementStyle}"`);
if (elementStyle !== 'rgba(33, 37, 41, 1)') {
throw new Error(`Export Content Set icon color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Export Content Set icon color matched as expected');
}
},
//Create Content Set
{ description: 'Click ellipsis icon', action: async () => await driver.findElement(By.linkText('Create Content Set')).click() },
//Wait for DIV
{
description: 'Wait for DIV to open',
action: async () => {
return await driver.wait(until.elementLocated(By.css('.modal-content .modal-title')), 50000).catch(() => false);
}
},
//Create Content Set DIV
{
description: 'Validate create content set DIV title',
action: async () => {
const elementText = await driver.findElement(By.css('.modal-content .modal-title')).getText();
if (elementText !== 'Create Content Set') {
throw new Error(`Content set DIV title did not match; Actual: "${elementText}"`);
}
console.log('Passed: Create content set DIV title matched as expected');
}
},
//Create Content Set DIV - label
{
description: 'Validate create DIV label',
action: async () => {
const elementText = await driver.findElement(By.css('.form-label')).getText();
if (elementText !== expectedEditDIVLabel) {
throw new Error(`Expected: "${expectedEditDIVLabel}"; Actual: "${elementText}"`);
}
console.log('Passed: Create DIV label matched as expected');
}
},
//Enter Content Set Name
{ description: 'Enter content set name', action: async () => await driver.findElement(By.css('#orgname')).sendKeys('Automated Content Set - To be deleted') },
{ description: 'Click create button', action: async () => await driver.findElement(By.css('#modalop')).click() },
//{ description: 'Driver sleep', action: async () => await driver.sleep(5000) },
//Wait for confirmation message
{
description: 'Wait for DIV to open',
action: async () => {
return await driver.wait(until.elementLocated(By.css('strong:nth-child(1)')), 50000).catch(() => false);
}
},
//Validate confirmation message
{
description: 'Validate confirmation message',
action: async () => {
const elementText = await driver.findElement(By.css('strong:nth-child(1)')).getText();
if (elementText !== 'The content set was successfuly created') {
throw new Error(`Expected confirmation message did not match; Actual: "${elementText}"`);
}
console.log('Passed: Confirmation message displayed as expected');
}
},
//Validate confirmation message background color -green
{
description: 'Validate confirmation message background color',
action: async () => {
const elementStyle = await driver.findElement(By.css('#statalert')).getCssValue('background-color');
if (elementStyle !== 'rgba(40, 167, 69, 1)') {
throw new Error(`Confirmation message background color did not match; Actual: "${elementStyle}"`);
}
console.log('Passed: Confirmation background color matched as expected');
}
},
//Validate created content set
{
description: 'Verify created automated content set',
action: async () => {
const expectedCreatedContentSet = await driver.wait(until.elementLocated(By.linkText('Automated Content Set - To be deleted')), 5000).catch(() => false);
if (!expectedCreatedContentSet) {
throw new Error('Automated created content set not found');
}
console.log('Passed: Automated content set present');
}
},
//Click created content set
{ description: 'Click created content set edit icon', action: async () => await driver.findElement(By.css('#content-org-list > #content-org-list > #content-org-list > #content-org-list > #content-org-list > #content-org-list > #content-org-list > #content-org-list > #content-org-list > #content-org-list > #content-org-list > #content-org-list > #content-org-list > #content-org-list .fa')).click() },
//Wait for DIV
{
description: 'Wait for DIV to open',
action: async () => {
return await driver.wait(until.elementLocated(By.css('.modal-content .modal-title')), 50000).catch(() => false);
}
},
//Edit Content Set DIV
{
description: 'Validate edit DIV title',
action: async () => {
const elementText = await driver.findElement(By.css('.modal-content .modal-title')).getText();
if (elementText !== 'Edit Content Set') {
throw new Error(`Edit DIV title did not match; Actual: "${elementText}"`);
}
console.log('Passed: Edit DIV title matched as expected');
}
},
//Edit Content Set DIV - label
{
description: 'Validate edit DIV label',
action: async () => {
const elementText = await driver.findElement(By.css('.form-label')).getText();
if (elementText !== expectedEditDIVLabel) {
throw new Error(`Expected: "${expectedEditDIVLabel}"; Actual: "${elementText}"`);
}
console.log('Passed: Edit DIV label matched as expected');
}
},
//Edit Content Set DIV - textbox
{
description: 'Validate edit DIV textbox',
action: async () => {
const elementValue = await driver.findElement(By.css('#orgname')).getAttribute('value');
if (elementValue !== expectedCreatedDIVTextbox) {
throw new Error(`Edit DIV textbox Expected: "${expectedCreatedDIVTextbox}"; Actual: "${elementValue}"`);
}
console.log('Passed: Edit DIV textbox matched as expected');
}
},
//Delete created content set
{ description: 'Click delete button', action: async () => await driver.findElement(By.css('#orgdelete')).click() },
{ description: 'Driver sleep', action: async () => await driver.sleep(2000) },
];
const logStep = (worksheet, stepDescription, status, stepIndex, timestamp, screenshotPath) => {
@@ -477,7 +608,7 @@ try {
} 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}`);
console.error(`Step ${stepIndex} FAILED: ${error.message}`);
testStatus = 'Failed';
}
}