fix: wait for monitor web readiness in screenshots
This commit is contained in:
@@ -1979,7 +1979,7 @@ for (let attempt = 1; attempt <= maxNavigationAttempts; attempt += 1) {
|
||||
try {
|
||||
const response = await page.goto(url, { timeout: perAttemptTimeout, waitUntil: "domcontentloaded" });
|
||||
httpStatus = response?.status() ?? null;
|
||||
await page.waitForLoadState("networkidle", { timeout: Math.min(5000, perAttemptTimeout) }).catch(() => {});
|
||||
await page.waitForLoadState("networkidle", { timeout: Math.min(10000, perAttemptTimeout) }).catch(() => {});
|
||||
await page.waitForFunction(() => {
|
||||
const root = document.querySelector("#monitor-web-root");
|
||||
if (!root) return false;
|
||||
@@ -1988,10 +1988,10 @@ for (let attempt = 1; attempt <= maxNavigationAttempts; attempt += 1) {
|
||||
const runs = document.querySelectorAll(".run-list .run-row").length;
|
||||
const trend = document.querySelector("[data-monitor-trend-curve]");
|
||||
return ready && (error || runs > 0 || trend);
|
||||
}, null, { timeout: Math.min(5000, perAttemptTimeout) }).catch(() => {});
|
||||
}, null, { timeout: Math.min(15000, perAttemptTimeout) }).catch(() => {});
|
||||
await page.waitForTimeout(500);
|
||||
const shellReady = await page.evaluate(() => Boolean(document.querySelector("#monitor-web-root"))).catch(() => false);
|
||||
if (shellReady || attempt === maxNavigationAttempts) break;
|
||||
const appReady = await page.evaluate(() => document.querySelector("#monitor-web-root")?.getAttribute("data-monitor-ready") === "true").catch(() => false);
|
||||
if (appReady || attempt === maxNavigationAttempts) break;
|
||||
} catch (error) {
|
||||
navigationError = String(error?.message || error).slice(0, 500);
|
||||
if (attempt === maxNavigationAttempts) break;
|
||||
|
||||
Reference in New Issue
Block a user