Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

fix(direct): Use config's geckoDriver when specified #4554

Merged
merged 2 commits into from
Dec 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions lib/driverProviders/direct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,26 @@ export class Direct extends DriverProvider {
break;
case 'firefox':
let geckoDriverFile: string;
try {
let updateJson = path.resolve(SeleniumConfig.getSeleniumDir(), 'update-config.json');
let updateConfig = JSON.parse(fs.readFileSync(updateJson).toString());
geckoDriverFile = updateConfig.gecko.last;
} catch (e) {
if (this.config_.geckoDriver) {
geckoDriverFile = this.config_.geckoDriver;
} else {
try {
let updateJson = path.resolve(SeleniumConfig.getSeleniumDir(), 'update-config.json');
let updateConfig = JSON.parse(fs.readFileSync(updateJson).toString());
geckoDriverFile = updateConfig.gecko.last;
} catch (e) {
throw new BrowserError(
logger,
'Could not find update-config.json. ' +
'Run \'webdriver-manager update\' to download binaries.');
}
}

if (!fs.existsSync(geckoDriverFile)) {
throw new BrowserError(
logger,
'Could not find update-config.json. ' +
'Run \'webdriver-manager update\' to download binaries.');
'Could not find geckodriver at ' + geckoDriverFile +
'. Run \'webdriver-manager update\' to download binaries.');
}

// TODO (mgiambalvo): Turn this into an import when the selenium typings are updated.
Expand Down