Skip to content

Commit 59ea3dc

Browse files
committed
add pageEvent in capture urls
1 parent 1c563c8 commit 59ea3dc

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/lib/schemaValidation.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ const WebStaticConfigSchema: JSONSchemaType<WebStaticConfig> = {
222222
}
223223
}
224224
},
225+
pageEvent: {
226+
type: "string",
227+
errorMessage: "pageEvent can be load, domcontentloaded"
228+
},
225229
},
226230
required: ["name", "url"],
227231
additionalProperties: false

src/lib/screenshot.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ async function captureScreenshotsForConfig(
1616
): Promise<void> {
1717
ctx.log.debug(`*** urlConfig ${JSON.stringify(urlConfig)}`);
1818

19-
let {name, url, waitForTimeout, execute} = urlConfig;
19+
let {name, url, waitForTimeout, execute, pageEvent} = urlConfig;
2020
let afterNavigationScript = execute?.afterNavigation;
2121
let beforeSnapshotScript = execute?.beforeSnapshot;
22+
let waitUntilEvent = pageEvent || process.env.SMARTUI_PAGE_WAIT_UNTIL_EVENT || 'load';
2223

23-
let pageOptions = { waitUntil: process.env.SMARTUI_PAGE_WAIT_UNTIL_EVENT || 'load', timeout: ctx.config.waitForPageRender || constants.DEFAULT_PAGE_LOAD_TIMEOUT };
24+
let pageOptions = { waitUntil: waitUntilEvent, timeout: ctx.config.waitForPageRender || constants.DEFAULT_PAGE_LOAD_TIMEOUT };
2425
let ssId = name.toLowerCase().replace(/\s/g, '_');
2526
let context: BrowserContext;
2627
let contextOptions: Record<string, any> = {};

0 commit comments

Comments
 (0)