Skip to content

Instantly share code, notes, and snippets.

@ebrehault
Created October 10, 2013 20:29
Show Gist options
  • Save ebrehault/6925103 to your computer and use it in GitHub Desktop.
Save ebrehault/6925103 to your computer and use it in GitHub Desktop.
casperjs error traceback
TEST
-----
// googletesting.js
casper.test.begin('Google search retrieves 10 or more results', 5, function suite(test) {
casper.start("http://www.google.fr/", function() {
test.assertTitle("Google", "google homepage title is the one expected");
test.assertExists('form[action="/yahoo"]', "main form is found");
this.fill('form[action="/search"]', {
q: "casperjs"
}, true);
});
casper.then(function() {
test.assertTitle("casperjs - Recherche Google", "google title is ok");
test.assertUrlMatch(/q=casperjs/, "search term has been submitted");
test.assertEval(function() {
return __utils__.findAll("h3.r").length >= 10;
}, "google search for \"casperjs\" retrieves 10 or more results");
});
casper.run(function() {
test.done();
});
});
RESULT
--------
~ casperjs test google.js
Test file: google.js
# Google search retrieves 10 or more results
PASS google homepage title is the one expected
FAIL main form is found
# type: assertExists
# file: google.js:5
# code: test.assertExists('form[action="/yahoo"]', "main form is found");
# subject: false
# selector: "form[action=\"/yahoo\"]"
⚠  looks like you did not use begin(), which is mandatory since 1.1
FAIL AssertionError: main form is found
# type: error
# file: google.js
# subject: false
# error: {"message":"main form is found","name":"AssertionError","result":{"success":false,"type":"assertExists","standard":"Found an element matching: form[action=\"/yahoo\"]","message":"main form is found","file":"google.js","doThrow":true,"values":{"subject":false,"selector":"form[action=\"/yahoo\"]"},"line":5,"lineContents":"test.assertExists('form[action=\"/yahoo\"]', \"main form is found\");","suite":"Google search retrieves 10 or more results","time":1},"line":301,"sourceId":139995371313280,"sourceURL":"/home/ebr/bin/casperjs/modules/tester.js","stack":"AssertionError: main form is found\n at assert (/home/ebr/bin/casperjs/modules/tester.js:301)\n at assertExists (/home/ebr/bin/casperjs/modules/tester.js:493)\n at google.js:5\n at runStep (/home/ebr/bin/casperjs/modules/casper.js:1525)\n at checkStep (/home/ebr/bin/casperjs/modules/casper.js:368)","stackArray":[{"function":"assert","sourceURL":"/home/ebr/bin/casperjs/modules/tester.js","line":301},{"function":"assertExists","sourceURL":"/home/ebr/bin/casperjs/modules/tester.js","line":493},{"sourceURL":"google.js","line":5},{"function":"runStep","sourceURL":"/home/ebr/bin/casperjs/modules/casper.js","line":1525},{"function":"checkStep","sourceURL":"/home/ebr/bin/casperjs/modules/casper.js","line":368}]}
FAIL 3 tests executed in 1.344s, 1 passed, 2 failed, 0 dubious, 0 skipped.
Details for the 2 failed tests:
In google.js:5
Google search retrieves 10 or more results
assertExists: main form is found
In google.js
Google search retrieves 10 or more results
error: AssertionError: main form is found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment