Skip to content

Commit

Permalink
feat: add option 'sessionQuitTimeout'
Browse files Browse the repository at this point in the history
  • Loading branch information
eGavr committed Nov 29, 2016
1 parent ece8b88 commit acc93f6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/browser.js
Expand Up @@ -35,8 +35,15 @@ module.exports = class Browser {
return q();
}

const optionsOnEnd = {
connectionRetryTimeout: this._config.sessionQuitTimeout || this._config.httpTimeout,
screenshotOnReject: false
};

// Не работает без then в виду особенностей реализации в webdriverio.js
return this._session.then(this._session.end)
return this._session
.then(() => this._session.extendOptions(optionsOnEnd))
.then(() => this._session.end())
.catch((e) => logger.warn(`WARNING: Can not close session: ${e.message}`));
}

Expand Down Expand Up @@ -72,6 +79,7 @@ module.exports = class Browser {
});

this._addMetaAccessCommands(session);
this._addExtendOptionsMethod(session);
this._decorateUrlMethod(session);

if (this._config.prepareBrowser) {
Expand All @@ -86,6 +94,12 @@ module.exports = class Browser {
session.addCommand('getMeta', (key) => this._meta[key]);
}

_addExtendOptionsMethod(session) {
session.addCommand('extendOptions', (opts) => {
_.extend(session.requestHandler.defaultOptions, opts);
});
}

_decorateUrlMethod(session) {
const baseUrlFn = session.url.bind(session);

Expand Down
2 changes: 2 additions & 0 deletions lib/config/browser-options.js
Expand Up @@ -69,6 +69,8 @@ function buildBrowserOptions(defaultFactory, extra) {

httpTimeout: options.nonNegativeInteger('httpTimeout'),

sessionQuitTimeout: options.optionalNonNegativeInterger('sessionQuitTimeout'),

waitTimeout: options.positiveInteger('waitTimeout'),

prepareBrowser: options.optionalFunction('prepareBrowser'),
Expand Down
1 change: 1 addition & 0 deletions lib/config/defaults.js
Expand Up @@ -12,6 +12,7 @@ module.exports = {
specs: null,
waitTimeout: 1000,
httpTimeout: 90000,
sessionQuitTimeout: null,
reporters: ['flat'],
debug: false,
sessionsPerBrowser: 1,
Expand Down

0 comments on commit acc93f6

Please sign in to comment.