Updated script to only take screenshots on failed steps

This commit is contained in:
2025-10-03 12:44:12 -07:00
parent 87e99cb78a
commit 32d4994eb0
14 changed files with 511 additions and 175 deletions

View File

@@ -3044,13 +3044,37 @@ try {
const stepIndex = steps.indexOf(step) + 1;
const timestamp = new Date().toISOString();
try {
try {
//Screenshot of failed step
await step.action();
const screenshotPath = await takeScreenshot(driver, stepIndex, step.description);
worksheet = logStep(worksheet, step.description, 'Passed', stepIndex, timestamp, screenshotPath);
//Log a successful step with no screenshot
worksheet = logStep(
worksheet,
step.description,
'Passed',
stepIndex,
timestamp,
null //No screenshot for passed steps
);
} catch (error) {
const screenshotPath = await takeScreenshot(driver, stepIndex, `${step.description}_Failed`);
worksheet = logStep(worksheet, step.description, 'Failed', stepIndex, timestamp, screenshotPath);
//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}`);
testStatus = 'Failed';
allStepsPassed = false;
@@ -3068,11 +3092,11 @@ try {
testStatus = 'Failed';
}
// Log test end time
//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
//Write the updated worksheet back to the workbook and save it
workbook.Sheets['Sheet1'] = worksheet;
XLSX.writeFile(workbook, 'frameworkPublishFrameworkDIVResults.xlsx');
} finally {