Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit d15d35a

Browse files
committed
fix issue where ElementFinder.then does not return a promise
See #1152
1 parent 316961c commit d15d35a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/protractor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ var buildElementHelper = function(ptor) {
744744
if (this.opt_actionResult_) {
745745
return this.opt_actionResult_.then(fn, errorFn);
746746
} else {
747-
return fn(this);
747+
return webdriver.promise.fulfilled(fn(this));
748748
}
749749
};
750750

spec/basic/elements_spec.js

+6
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,12 @@ describe('ElementFinder', function() {
305305
});
306306
expect(successful).toEqual(false);
307307
});
308+
309+
it('should always return a promise when calling then', function() {
310+
browser.get('index.html#/form');
311+
var e1 = element(by.tagName('body')).then(function(){});
312+
expect(e1 instanceof protractor.promise.Promise).toBe(true);
313+
});
308314
});
309315

310316
describe('evaluating statements', function() {

0 commit comments

Comments
 (0)