Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
Cast promises, coming from wd to bluebird
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Tatarintsev authored and sipayRT committed Oct 6, 2016
1 parent 3d1f761 commit 92e9e37
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/browser/new-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ module.exports = class NewBrowser extends Browser {
}

_applyWdMethodInContext(method, context, args) {
return this._wd.currentContext()
return Promise.resolve(this._wd.currentContext())
.then((originalContext) => {
return this._wd.context(context)
return Promise.resolve(this._wd.context(context))
.then(() => this._applyWdMethod(method, args))
.finally(() => this._wd.context(originalContext));
});
}

_applyWdMethod(method, args) {
return this._wd[method].apply(this._wd, args);
return Promise.resolve(this._wd[method].apply(this._wd, args));
}

launch(calibrator) {
Expand Down Expand Up @@ -151,7 +151,7 @@ module.exports = class NewBrowser extends Browser {
return;
}

return this._wd.setWindowSize(size.width, size.height)
return Promise.resolve(this._wd.setWindowSize(size.width, size.height))
.catch((e) => {
// Its the only reliable way to detect not supported operation
// in legacy operadriver.
Expand All @@ -171,7 +171,7 @@ module.exports = class NewBrowser extends Browser {
_buildPolyfills() {
//polyfills are needed for older browsers, namely, IE8

return this._wd.eval('navigator.userAgent')
return Promise.resolve(this._wd.eval('navigator.userAgent'))
.then((ua) => {
return polyfillService.getPolyfillString({
uaString: ua,
Expand All @@ -198,7 +198,7 @@ module.exports = class NewBrowser extends Browser {
resetZoom: true
});

return this._wd.get(url)
return Promise.resolve(this._wd.get(url))
.then((url) => {
return params.resetZoom
? this._clientBridge.call('resetZoom').thenReturn(url)
Expand All @@ -207,11 +207,11 @@ module.exports = class NewBrowser extends Browser {
}

injectScript(script) {
return this._wd.execute(script);
return Promise.resolve(this._wd.execute(script));
}

evalScript(script) {
return this._wd.eval(script);
return Promise.resolve(this._wd.eval(script));
}

buildScripts() {
Expand Down Expand Up @@ -291,7 +291,7 @@ module.exports = class NewBrowser extends Browser {
}

_maximize() {
return this._wd.windowHandle()
return Promise.resolve(this._wd.windowHandle())
.then((handle) => this._wd.maximize(handle));
}

Expand All @@ -300,7 +300,7 @@ module.exports = class NewBrowser extends Browser {
}

_findElementWd(selector) {
return this._wd.elementByCssSelector(selector)
return Promise.resolve(this._wd.elementByCssSelector(selector))
.catch((error) => {
if (error.status === WdErrors.ELEMENT_NOT_FOUND) {
error.selector = selector;
Expand Down

0 comments on commit 92e9e37

Please sign in to comment.