Reputation: 2560
How to check the outgoing http requests with CasperJS ?
I mean not only checking the http status of the answer of a request, but also I what if I want to test that the last POST request was sent on url X and with a body Y. (Regardless if the http request failed or not).
Upvotes: 1
Views: 536
Reputation: 1527
I think you must look at casper event "page.resource.requested"
For exemple :
casper.on('page.resource.requested', function(requestData, request) {
if (requestData.url.indexOf('http://urltotest') === 0) {
casper.test.pass("Correct url requested");
} else {
casper.test.fail("Wrong url");
}
});
It's an exemple, i need a more specific behavior to give you a more accurate answer.
Documentation is available here : http://docs.casperjs.org/en/latest/events-filters.html
Upvotes: 1