Anyone know how I can find out the cause of this error in casperjs? The test script I am trying to run when getting this is:
var errors = [];
casper.on("page.error", function(msg, trace) {
this.echo("Error: " + msg, "ERROR");
this.echo("file: " + trace[0].file, "WARNING");
this.echo("line: " + trace[0].line, "WARNING");
this.echo("function: " + trace[0]["function"], "WARNING");
errors.push(msg);
});
casper.on('resource.received', function(resource) {
var status = resource.status;
if(status >= 400) {
casper.log('Resource ' + resource.url + ' failed to load (' + status + ')', 'error');
errors.push({
url: resource.url,
status: resource.status
});
}
});
casper.test.begin('Are we online?', 3, function suite(test) {
casper.start("http://www.google.com/", function() {
test.assertTitle("Google", "Connected to google, internet connection probably ok");
});
casper.thenOpen("https://mysite", function() {
test.assertTitle("Log On", "Connected to mysite, server is up");
this.fill('form#logonForm', {
'Name': 'user',
'Password': 'pass',
}, true);
});
casper.thenOpen("https://mysite/somepage", function() {
casper.test.assert(errors.length==0,'No js errors'); //THIS LINE SEEMS TO BE CAUSING THIS ERROR, NOT SURE WHY?
});
casper.run(function () {
test.done();
});
});
The full, complete error message is:
Details for 1 failed test: In connect-to-production.js: 1968 (there is no such line, my js file has only the lines I pasted above in it, nowhere near 2000 lines)
Are we online? (my test name) uncaughtError: TypeError: Attempted to Assign to readOnly property.
Above this it does not behave like a normal error and says NO STACK TRACE.
page.error
callback and what line and so on from the page. – Artjom B. Mar 19 '15 at 20:33console.log()
debugging would at least reveal around which line this error was thrown. There is simply not enough information to help you here. It is not even clear whether the error comes from CasperJS code or the page (If it comes from the page, then your output should start withError:
, but it doesn't. If it comes from CasperJS code then it should contain a reference to casper.js, but it doesn't. This is very contradictory!). – Artjom B. Mar 19 '15 at 22:02