I need to do some node require commands in a webdriverJS test script, because these dont get entered into the webdriverJS command queue, I am wrapping them in .then()
functions (to deal with the asyncrony)
e.g.
var webdriver = require('selenium-webdriver');
// create webdriver instance so promise chain can be setup
var promise_builder = new webdriver.Builder().withCapabilities(webdriver.Capabilities.chrome()).
build();
// wrap all functions in webdriver promises so they get managed by webdrivers
// command queue
promise_builder.sleep(0).then(function() {
// Run "non-command-queue" commands
var tests = require('./test_commands');
tests(helpers, setup, webdriver, driver);
}).then(function(){
// more non-webdriver commands
});
The problem here (other than the fact its inelegant) is that a browser instance is launched - just to achieve promise chaining.
Is there a better way to create the initial promise, e.g. a static method within the webdriver api for creating promises?