I run my e2e tests against a mocked API using angular service $httpBackend in protractor.
I already have the debug log of the selenium browser:
afterEach(function() {
browser.manage().logs().get('browser').then(function(browserLog){
if(browserLog.length) {
for (var i = 0; i < browserLog.length; i++) {
if( typeof browserLog[i] !== 'undefined') {
console.log(
JSON
.parse(browserLog[i].message).message.parameters[0].value
);
}
};
}
});
});
I'd like to print URL and headers of each request inside my httpBackend module (eg for users resourse) :
$httpBackend
.whenGET(/^\/api\/users.*$/)
.respond(function(method, url, data, headers) {
var users = mockUserService.getData();
console.log(url);
console.log(headers);
return [200, users, {}];
});
But nothing is logged anywhere inside the httpBackend module. It works fine when I use it in my app but not when I use it with protractor.
Is there any way to print it anywhere? Even in an output text file?
console.log()
statements are ignored by WebDriver.
You can use console.info()
, console.warn()
or console.error()
as described here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With