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

Commit

Permalink
fix(ElementFinder): ElementFinder should allow null as success handler.
Browse files Browse the repository at this point in the history
Passes the value to the next in the chain.
  • Loading branch information
Ferengee authored and hankduan committed Oct 1, 2014
1 parent 2fbaf52 commit 9db5327
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/protractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,9 @@ var buildElementHelper = function(ptor) {
*/
ElementFinder.prototype.then = function(fn, errorFn) {
return this.elementArrayFinder_.then(function(actionResults) {
if (!fn) {
return actionResults[0];
}
return fn(actionResults[0]);
}, errorFn);
};
Expand Down
13 changes: 13 additions & 0 deletions spec/basic/elements_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,19 @@ describe('ElementFinder', function() {
expect(finalResult.getText()).toEqual('Hiya');
});
});

it('should allow null as success handler', function() {
browser.get('index.html#/form');

var usernameInput = element(by.model('username'));
var name = element(by.binding('username'));

expect(name.getText()).toEqual('Anon');
expect(
name.getText().then(null, function(){})
).toEqual('Anon');

});
});

describe('ElementArrayFinder', function() {
Expand Down

0 comments on commit 9db5327

Please sign in to comment.