Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
Allow to set chromedriverCustomPath during onPrepare (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Mar 22, 2022
1 parent d005eec commit 71bf0e3
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 108 deletions.
11 changes: 9 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@ export declare interface ChromedriverServiceOptions {
}

export declare class ChromedriverServiceLauncher {
public chromedriverCustomPath: string;
public options: Pick<ChromedriverServiceOptions, 'protocol' | 'hostname' | 'port' | 'path'>;
public outputDir: string;
public logFileName: string;
public capabilities: Capabilities.Capabilities;
public args: string[];

constructor(
options: ChromedriverServiceOptions,
capabilities: Capabilities.Capabilities,
config: Omit<Options.Testrunner, "capabilities">
);

onComplete(): void;
onPrepare(): void;
onComplete(...args: any[]): void;
onPrepare(...args: any[]): void;
}

export default class ChromeDriverService {}
Expand Down
6 changes: 4 additions & 2 deletions src/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class ChromeDriverLauncher {
this.logFileName = options.logFileName || DEFAULT_LOG_FILENAME
this.capabilities = capabilities
this.args = options.args || []
this.chromedriverCustomPath = options.chromedriverCustomPath ? path.resolve(options.chromedriverCustomPath) : this._getChromedriverPath()
this.chromedriverCustomPath = options.chromedriverCustomPath
}

async onPrepare() {
Expand All @@ -59,6 +59,8 @@ export default class ChromeDriverLauncher {
this._mapCapabilities()

let command = this.chromedriverCustomPath
? path.resolve(this.chromedriverCustomPath)
: this._getChromedriverPath()
log.info(`Start Chromedriver (${command}) with args ${this.args.join(' ')}`)
if (!fs.existsSync(command)) {
log.warn('Could not find chromedriver in default path: ', command)
Expand Down Expand Up @@ -138,7 +140,7 @@ export default class ChromeDriverLauncher {
return require('chromedriver').path
} catch (e) {
log.error('Can\'t load chromedriver, please define "chromedriverCustomPath" property or install dependency via "npm install chromedriver --save-dev"')
throw e
throw new SevereServiceError(e.message)
}
}
}
Loading

0 comments on commit 71bf0e3

Please sign in to comment.