From ffbd312f29651b4e0821ffcdd2ee5b02b6673b6b Mon Sep 17 00:00:00 2001 From: robert-cardillo <1337570+robert-cardillo@users.noreply.github.com> Date: Wed, 23 Oct 2024 12:51:16 +0300 Subject: [PATCH] Browser Engine waits for the selector specified in Friendly Name wrapped with brackets, if specified --- .../monitor-types/real-browser-monitor-type.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/server/monitor-types/real-browser-monitor-type.js b/server/monitor-types/real-browser-monitor-type.js index f1219af1..39a72821 100644 --- a/server/monitor-types/real-browser-monitor-type.js +++ b/server/monitor-types/real-browser-monitor-type.js @@ -240,10 +240,19 @@ class RealBrowserMonitorType extends MonitorType { const context = await browser.newContext(); const page = await context.newPage(); - const res = await page.goto(monitor.url, { - waitUntil: "networkidle", - timeout: monitor.interval * 1000 * 0.8, - }); + 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", + timeout: monitor.interval * 1000 * 0.8, + }); + } let filename = jwt.sign(monitor.id, server.jwtSecret) + ".png";