It can be done with pure phantomjs like this:
var page = require('webpage').create();
var address = 'http://google.com/';
page.open(address, function(status) {
if (status !== 'success') {
console.log('FAIL to load the address');
} else {
console.log('SUCCESS');
}
phantom.exit();
});
but I'd like it to support casperjs test
command. The best I came up with is:
casper.test.begin("Hello, Test!", 1, function(test) {
var page = require('webpage').create();
var address = 'http://google_doesnotexist.com/';
page.open(address, function(status) {
test.assert(status == 'success');
//phantom.exit();
test.done();
});
});
it works fine if page really opens, but the script does not stop at all if the page does not open.