Skip to content

Commit

Permalink
feat(cli): add --chrome-path option (dequelabs#700)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinedied committed Apr 3, 2023
1 parent 50989f3 commit a327bb0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
11 changes: 11 additions & 0 deletions packages/cli/src/bin/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,4 +384,15 @@ describe('cli', () => {
);
});
});

describe('--chrome-path', () => {
it('should throw error if path does not exist', async () => {
const result = await runCLI(
`file://${SIMPLE_HTML_FILE}`,
'--chrome-path="someinvalidpath"',
'--show-errors'
);
assert.include(result.stderr, 'no chrome binary at');
});
});
});
4 changes: 4 additions & 0 deletions packages/cli/src/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ program
'--chromedriver-path <path>',
'Absolute path to the desired chromedriver executable'
)
.option(
'--chrome-path <path>',
'Absolute path to the desired chrome executable'
)
.action(cli);

program.parse(process.argv);
6 changes: 4 additions & 2 deletions packages/cli/src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ const cli = async (
rules,
disable,
loadDelay,
chromedriverPath
chromedriverPath,
chromePath
} = args;

const showErrors = args.showErrors === true;
Expand Down Expand Up @@ -67,7 +68,8 @@ const cli = async (
browser: args.browser,
timeout,
chromeOptions,
chromedriverPath
chromedriverPath,
chromePath
};

args.driver = startDriver(driverConfigs);
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/lib/webdriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const startDriver = async (
}, options);
}

if (config.chromePath) {
options.setChromeBinaryPath(config.chromePath);
}

builder = new Builder()
.forBrowser('chrome')
.setChromeOptions(options)
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface WebdriverConfigParams {
browser: string;
timeout: number;
chromedriverPath?: string;
chromePath?: string;
path?: string;
chromeOptions?: string[];
builder?: Builder;
Expand Down

0 comments on commit a327bb0

Please sign in to comment.