diff --git a/package.json b/package.json index 1e064d5..d238c69 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lambdatest/smartui-cli", - "version": "4.1.42", + "version": "4.1.43", "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest", "files": [ "dist/**/*" diff --git a/src/commander/commander.ts b/src/commander/commander.ts index 5daf935..fb85fb0 100644 --- a/src/commander/commander.ts +++ b/src/commander/commander.ts @@ -23,6 +23,8 @@ program .option('--baselineBranch ', 'Mark this build baseline') .option('--baselineBuild ', 'Mark this build baseline') .option('--githubURL ', 'GitHub URL including commitId') + .option('--userName ', 'Specify the LT username') + .option('--accessKey ', 'Specify the LT accesskey') .addCommand(exec) .addCommand(capture) .addCommand(configWeb) diff --git a/src/commander/exec.ts b/src/commander/exec.ts index 8807616..8d94ab0 100644 --- a/src/commander/exec.ts +++ b/src/commander/exec.ts @@ -24,8 +24,6 @@ command .option('--fetch-results [filename]', 'Fetch results and optionally specify an output file, e.g., .json') .option('--buildName ', 'Specify the build name') .option('--scheduled ', 'Specify the schedule ID') - .option('--userName ', 'Specify the LT username') - .option('--accessKey ', 'Specify the LT accesskey') .option('--show-render-errors', 'Show render errors from SmartUI build') .action(async function(execCommand, _, command) { const options = command.optsWithGlobals(); diff --git a/src/lib/env.ts b/src/lib/env.ts index 1402aa7..4901f49 100644 --- a/src/lib/env.ts +++ b/src/lib/env.ts @@ -26,7 +26,8 @@ export default (): Env => { SHOW_RENDER_ERRORS, SMARTUI_SSE_URL='https://server-events.lambdatest.com', LT_SDK_SKIP_EXECUTION_LOGS, - MAX_CONCURRENT_PROCESSING + MAX_CONCURRENT_PROCESSING, + DO_NOT_USE_USER_AGENT, } = process.env return { @@ -55,5 +56,6 @@ export default (): Env => { SMARTUI_SSE_URL, LT_SDK_SKIP_EXECUTION_LOGS: LT_SDK_SKIP_EXECUTION_LOGS === 'true', MAX_CONCURRENT_PROCESSING: MAX_CONCURRENT_PROCESSING ? parseInt(MAX_CONCURRENT_PROCESSING, 10) : 0, + DO_NOT_USE_USER_AGENT: DO_NOT_USE_USER_AGENT === 'true', } } diff --git a/src/lib/processSnapshot.ts b/src/lib/processSnapshot.ts index f8af069..a157717 100644 --- a/src/lib/processSnapshot.ts +++ b/src/lib/processSnapshot.ts @@ -237,8 +237,11 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context): } let contextOptions: Record = { javaScriptEnabled: ctx.config.cliEnableJavaScript, - userAgent: constants.CHROME_USER_AGENT, - ignoreHTTPSErrors : ctx.config.ignoreHTTPSErrors + ignoreHTTPSErrors: ctx.config.ignoreHTTPSErrors, + }; + + if (!ctx.env.DO_NOT_USE_USER_AGENT) { + contextOptions.userAgent = constants.CHROME_USER_AGENT; } if (!ctx.browser?.isConnected()) { if (ctx.env.HTTP_PROXY || ctx.env.HTTPS_PROXY) launchOptions.proxy = { server: ctx.env.HTTP_PROXY || ctx.env.HTTPS_PROXY }; diff --git a/src/types.ts b/src/types.ts index 196c60c..2a735b3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -137,6 +137,7 @@ export interface Env { SMARTUI_SSE_URL: string; LT_SDK_SKIP_EXECUTION_LOGS: boolean; MAX_CONCURRENT_PROCESSING: number; + DO_NOT_USE_USER_AGENT: boolean; } export interface Snapshot {