Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/rachna86/nightwatch
Browse files Browse the repository at this point in the history
  • Loading branch information
beatfactor committed Dec 8, 2015
2 parents 42064fe + f867645 commit 2acf562
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/api/element-commands/_waitForElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ WaitForElement.prototype.isVisible = function() {
return self.elementVisible(result, now);
}

if (result.status === -1 && result.errorStatus === 10) {
return self.checkElement();
}

return self.elementNotVisible(result, now);
});
};
Expand Down
34 changes: 34 additions & 0 deletions tests/src/commands/testWaitForElementVisible.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,40 @@ module.exports = {
});
},

testStaleElementReference : function(test) {
var assertion = [];
this.client.assertion = function(result, actual, expected, msg, abortObFailure) {
Array.prototype.unshift.apply(assertion, arguments);
};

MockServer.addMock({ url : '/wd/hub/session/1352110219202/elements',
method:'POST',
response : JSON.stringify({
status: 0,
state: 'success',
value: [ { ELEMENT: '0' } ]
})
},
{
url : '/wd/hub/session/1352110219202/element/0/displayed',
method:'GET',
response : JSON.stringify({
sessionId: '1352110219202',
state: 'stale element reference',
status:10
})
});

this.client.api.waitForElementVisible('#weblogin', 110, 50, function callback(result, instance) {
test.equal(assertion[0], false);
test.equal(assertion[1], 'not visible');
test.equal(assertion[3], 'Timed out while waiting for element <#weblogin> to be visible for 110 milliseconds.');
test.equal(assertion[4], true);

test.done();
});
},

'test not visible with global timeout default': function(test) {
var assertion = [];
this.client.assertion = function(result, actual, expected, msg, abortObFailure) {
Expand Down

0 comments on commit 2acf562

Please sign in to comment.