protractor icon indicating copy to clipboard operation
protractor copied to clipboard

Is it possible to read the console?

Open Douwe92 opened this issue 13 years ago • 4 comments

Is it possible for protractor to read the console of Chrome?

Like for an example I got a function that sents a email to me with something in it, but it logs in the console if it went alright. So could I assert that the console returns ok?

Douwe92 avatar Oct 07 '13 08:10 Douwe92

don't know if protractor/webdriver can do sth. like this, but you can redefine console.log inside your test with a spy and check the arguments what it was called with.

marcorinck avatar Oct 10 '13 07:10 marcorinck

Can you show me an example?

Douwe92 avatar Oct 10 '13 10:10 Douwe92

jasmine:

console.log = jasmine.createSpy("console log") 

And then use usual jasmine matchers on that spy.

or do it yourself (untested, out of my head):

var consoleArgs, _log = console.log;
console.log = function() {
    consoleArgs = arguments;
    _log.apply(this, arguments);
}

marcorinck avatar Oct 10 '13 10:10 marcorinck

I think this is obsolete? closing.

juliemr avatar Nov 08 '13 00:11 juliemr