I have been using mocha-casperjs for a while now and I noticed that for some reason, sometimes code like:
casper.click(x("//a[normalize-space(text())='login']"));
or
casper.waitForSelector(x("//a[normalize-space(text())='login']")
don't work immediately, but it fails saying: xpath selector: //a[normalize-space(text())='login']" still did not exist 5000ms
After some attempts, it just works, but than it doesn't anymore again.
It is not an asynchronous problem, because I use code like:
if(casper.exists(x("//a[normalize-space(text())='login']"))){
console.log('I am here');
}
to test its presence and this always returns "I am here".
Any idea ?