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

Commit 9db5327

Browse files
Ferengeehankduan
authored andcommitted
fix(ElementFinder): ElementFinder should allow null as success handler.
Passes the value to the next in the chain.
1 parent 2fbaf52 commit 9db5327

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/protractor.js

+3
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,9 @@ var buildElementHelper = function(ptor) {
762762
*/
763763
ElementFinder.prototype.then = function(fn, errorFn) {
764764
return this.elementArrayFinder_.then(function(actionResults) {
765+
if (!fn) {
766+
return actionResults[0];
767+
}
765768
return fn(actionResults[0]);
766769
}, errorFn);
767770
};

spec/basic/elements_spec.js

+13
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,19 @@ describe('ElementFinder', function() {
185185
expect(finalResult.getText()).toEqual('Hiya');
186186
});
187187
});
188+
189+
it('should allow null as success handler', function() {
190+
browser.get('index.html#/form');
191+
192+
var usernameInput = element(by.model('username'));
193+
var name = element(by.binding('username'));
194+
195+
expect(name.getText()).toEqual('Anon');
196+
expect(
197+
name.getText().then(null, function(){})
198+
).toEqual('Anon');
199+
200+
});
188201
});
189202

190203
describe('ElementArrayFinder', function() {

0 commit comments

Comments
 (0)