Skip to content

Commit cbf7d4b

Browse files
committed
refactored as per review
1 parent 6fcdd91 commit cbf7d4b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/lib/screenshot.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async function captureScreenshotsForConfig(
2121
let beforeSnapshotScript = execute?.beforeSnapshot;
2222
let waitUntilEvent = pageEvent || process.env.SMARTUI_PAGE_WAIT_UNTIL_EVENT || 'load';
2323

24-
let pageOptions = { waitUntil: waitUntilEvent, timeout: ctx.config.waitForPageRender || constants.DEFAULT_PAGE_LOAD_TIMEOUT , userAgent : ctx.config.userAgent};
24+
let pageOptions = { waitUntil: waitUntilEvent, timeout: ctx.config.waitForPageRender || constants.DEFAULT_PAGE_LOAD_TIMEOUT};
2525
ctx.log.debug(`url: ${url} pageOptions: ${JSON.stringify(pageOptions)}`);
2626
let ssId = name.toLowerCase().replace(/\s/g, '_');
2727
let context: BrowserContext;
@@ -31,10 +31,10 @@ async function captureScreenshotsForConfig(
3131
else if (browserName == constants.FIREFOX) contextOptions.userAgent = constants.FIREFOX_USER_AGENT;
3232
else if (browserName == constants.SAFARI) contextOptions.userAgent = constants.SAFARI_USER_AGENT;
3333
else if (browserName == constants.EDGE) contextOptions.userAgent = constants.EDGE_USER_AGENT;
34-
else {
35-
contextOptions.userAgent = pageOptions.userAgent;
36-
if(pageOptions.userAgent === null) {
37-
contextOptions.userAgent = userAgent;
34+
else if (ctx.config.userAgent || urlConfig.userAgent) {
35+
contextOptions.userAgent = ctx.config.userAgent;
36+
if (urlConfig.userAgent !== null) {
37+
contextOptions.userAgent = urlConfig.userAgent;
3838
}
3939
}
4040

0 commit comments

Comments
 (0)