Print request in mBackend API module in Protractor

I run my e2e tests against the mocking API using the angular $ httpBackend service in the protractor.

I already have a selenium browser debug log:

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 would like to print the URL and headers of each request in my httpBackend module (e.g. for users):

 $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 written anywhere inside the httpBackend module. It works great when I use it in my application, but not when I use it with a protractor.

Is there any way to print it anywhere? Even in the output text file?

+6
source share
1 answer
Operators

console.log() ignored using WebDriver. You can use console.info() , console.warn() or console.error() as described here .

+10
source

Source: https://habr.com/ru/post/985212/


All Articles