Browser Engine waits for the selector specified in Friendly Name wrapped with brackets, if specified

This commit is contained in:
robert-cardillo 2024-10-23 12:51:16 +03:00
parent 79a26180af
commit ffbd312f29
1 changed files with 13 additions and 4 deletions

View File

@ -240,10 +240,19 @@ class RealBrowserMonitorType extends MonitorType {
const context = await browser.newContext(); const context = await browser.newContext();
const page = await context.newPage(); const page = await context.newPage();
const res = await page.goto(monitor.url, { let res;
const matches = monitor.name.match(/\[(.*?)\]/);
if (matches) {
res = await page.goto(monitor.url, {
timeout: monitor.interval * 1000 * 0.8,
});
await page.waitForSelector(matches[1], { timeout: monitor.interval * 1000 * 0.8 });
} else {
res = await page.goto(monitor.url, {
waitUntil: "networkidle", waitUntil: "networkidle",
timeout: monitor.interval * 1000 * 0.8, timeout: monitor.interval * 1000 * 0.8,
}); });
}
let filename = jwt.sign(monitor.id, server.jwtSecret) + ".png"; let filename = jwt.sign(monitor.id, server.jwtSecret) + ".png";