hook for creating a driver
Closed this issue · 5 comments
Hi,
Love the wrapper. Thank you for it.
What I need is to be able to control the driver configuration (browsers, resolutions, and local, versus remote).
Do you have or plan to have a hook or configuration option for driver construction?
-Lee
Hi @leggebroten, thank you for contributing!
A config file is a good idea, can you give me an example/snippet of the settings you'd like to see? Internally, the browser setup looks like this
Hi John,
My initial plan would be to look for a well-known JSON config file in the node working directory and merge that with a "config" object at the top of your index.js file.
Then, use the values from that merged object as defaults for the options statements when constructing the program instance.
This could easily be extended to define arbitrary driver construction functors or pass additional to cucumber command line
let config = {
"dir": {
"step_def": "./step-definitions",
"page_obj": "./page-objects",
"shared_obj": "./shared-objects",
"reports": "./reports",
},
"browser": {
"allowed": "^(chrome|firefox|phantomjs)$",
"default": "chrome"
},
"timeout": 10000
};
let configFileName = path.resolve(process.cwd(), 'selenium-cucumber-js.json');
var fs = require('fs');
if (fs.existsSync(configFileName)) {
console.log("Reading config from " + configFileName);
Object.assign(config, require(configFileName));
console.log('Config is: ' + JSON.stringify(config));
}
// end Added
program
.version(pjson.version)
.description(pjson.description)
.option('-s, --steps ', 'path to step definitions. defaults to ' + config.dir.step_def, config.dir.step_def)
I have a better solution and will submit a pull request for your review.
Tried to add the two branches for pull requests ... no joy.
Merged, thanks @leggebroten