add screenshots folder

main
saif 2025-01-01 12:45:16 +05:00
parent 9514304913
commit ec0f5bcb9b
1 changed files with 36 additions and 7 deletions

View File

@ -10,9 +10,10 @@ const dotenv = require("dotenv").config({ path: __dirname + "/.env" });
const utils = require("./utils");
(async function () {
console.log(`===========< STARTED ${luxon.DateTime.now()} >=========`);
const screenshotDirectory = path.join(__dirname, "screenshots");
/**
* loading config data
*/
@ -118,11 +119,23 @@ const utils = require("./utils");
if (element) {
await element.click();
console.log("Clicked on the Request Report btn");
await page.screenshot({ path: `${luxon.DateTime.now().toMillis()}.png` });
// take screenshot
let screenshotPath = path.join(
screenshotDirectory,
`${luxon.DateTime.now().toMillis()}.png`
);
await page.screenshot({ path: screenshotPath, fullPage: true });
// wait 10 secs
await new Promise((resolve) => setTimeout(resolve, 10 * 1000));
await page.screenshot({ path: `${luxon.DateTime.now().toMillis()}.png` });
// take screenshot
screenshotPath = path.join(
screenshotDirectory,
`${luxon.DateTime.now().toMillis()}.png`
);
await page.screenshot({ path: screenshotPath, fullPage: true });
const confirmBtnSelector = "div._3yOxLjm0._2pgGmJ7w._1eT_m6dA";
const confirmBtnElement = await page.$(confirmBtnSelector);
@ -134,7 +147,13 @@ const utils = require("./utils");
// wait for 3 seconds then reload page
await new Promise((resolve) => setTimeout(resolve, 3 * 1000));
await page.screenshot({ path: `${luxon.DateTime.now().toMillis()}.png` });
// take screenshot
screenshotPath = path.join(
screenshotDirectory,
`${luxon.DateTime.now().toMillis()}.png`
);
await page.screenshot({ path: screenshotPath, fullPage: true });
// wait for 3 mins for request to be processed
await new Promise((resolve) => setTimeout(resolve, 3 * 60 * 1000));
}
@ -142,7 +161,13 @@ const utils = require("./utils");
console.log(" Request Btn doest exists");
}
await page.screenshot({ path: `${luxon.DateTime.now().toMillis()}.png` });
// take screenshot
var screenshotPath = path.join(
screenshotDirectory,
`${luxon.DateTime.now().toMillis()}.png`
);
await page.screenshot({ path: screenshotPath, fullPage: true });
// download latest report
await page.waitForSelector("div._2zs6hel0");
@ -161,8 +186,12 @@ const utils = require("./utils");
generateTheDownloadPath(page, downloadFolderPath);
console.log("Clicking On download Button");
await new Promise((resolve) => setTimeout(resolve, 10 * 1000));
await page.screenshot({ path: `${luxon.DateTime.now().toMillis()}.png` });
// take screenshot
var screenshotPath = path.join(
screenshotDirectory,
`${luxon.DateTime.now().toMillis()}.png`
);
await page.screenshot({ path: screenshotPath, fullPage: true });
await divs[0].click();
}