Skip to content

Commit e968feb

Browse files
Merge pull request #254 from sushobhit-lt/DOT-4801
add pageEvent in capture urls
2 parents 6dde393 + 6a8e5c9 commit e968feb

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/lib/schemaValidation.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ const WebStaticConfigSchema: JSONSchemaType<WebStaticConfig> = {
222222
}
223223
}
224224
},
225+
pageEvent: {
226+
type: "string",
227+
enum: ['load', 'domcontentloaded'],
228+
errorMessage: "pageEvent can be load, domcontentloaded"
229+
},
225230
},
226231
required: ["name", "url"],
227232
additionalProperties: false

src/lib/screenshot.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ 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 };
25+
ctx.log.debug(`url: ${url} pageOptions: ${JSON.stringify(pageOptions)}`);
2426
let ssId = name.toLowerCase().replace(/\s/g, '_');
2527
let context: BrowserContext;
2628
let contextOptions: Record<string, any> = {};

0 commit comments

Comments
 (0)