This code is not working:
casper.waitFor(function check(){
//Wait for new line to appear in the table and the input box to be emptied
console.log("In waitFor:");
console.log(casper.evaluate(function(){return $("table.packagesListing tr td:contains('some text')").length;}) );
console.log(casper.evaluate(function(){return $("table.packagesListing tr td:contains('some text')").length;}) == 1 );
return
casper.evaluate(function(){return $("table.packagesListing tr td:contains('some text')").length;}) == 1
//&&
//(casper.evaluate(function(){return $('input#addNewPackage').val();}) == "")
;
},function then(){},
function onTimeout(){
this.capture("screenshots/"+label+".failed_timeout_waiting_for_package_add.png");
});
When I run it what I see is:
In waitFor:
1
true
In waitFor:
1
true
...
In waitFor:
1
true
In waitFor:
1
true
And then I get the timeout! I must be missing something really obvious, because I am using casper.waitFor() elsewhere in this script, with no problems!