Skip to content

Commit fee0c39

Browse files
Lee EggebrotenJohn Doherty
authored andcommitted
Allow the user to provide a file path for creating a browser driver
1 parent 8000592 commit fee0c39

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

runtime/world.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var cucumberJunit = require('cucumber-junit');
2424
*/
2525
function getDriverInstance() {
2626

27+
var driver;
2728
switch (browserName || '') {
2829

2930
case 'firefox': {
@@ -48,8 +49,7 @@ function getDriverInstance() {
4849

4950
} break;
5051

51-
// default to chrome
52-
default: {
52+
case 'chrome': {
5353

5454
driver = new selenium.Builder().withCapabilities({
5555
browserName: 'chrome',
@@ -60,6 +60,15 @@ function getDriverInstance() {
6060
},
6161
path: chromedriver.path
6262
}).build();
63+
} break;
64+
65+
// try to load from file
66+
default: {
67+
var driverFileName = path.resolve(process.cwd(), browserName);
68+
if (!fs.isFileSync(driverFileName)) {
69+
throw "Could not find driver file: " + driverFileName;
70+
}
71+
driver = require(driverFileName)();
6372
}
6473
}
6574

0 commit comments

Comments
 (0)