Reputation: 2791
after some research I've found that can I make some assertions using 'console.log' (in Chrome) when testing a three.js page. for example:
console.log(scene)
console.log(camera)
when running those commands I'm getting a JSON array and can check the parameters.
my question is - can I do this through protractor? meaning running the commands and check the response?
EDIT: I know that I can use console.log for logging the test. but - I can for example going to browser console (chrome for example) and enter:
console.log(window)
when doing that, I get:
{top: Window, window: Window, location: Location, external: Object, chrome: Object…}Infinity: Infinity$: function (a,b){return new e.fn.init(a,b,h)}AnalyserNode: ...
and so on.
I can also enter
console.log(document.URL)
and get
http://stackoverflow.com/posts/28690960/edit
when trying to put the same line in protractor:
console.log(window);
I'm getting this error:
ReferenceError: window is not defined
thanks!
Upvotes: 1
Views: 1188
Reputation: 6034
If your question is whether you can use console.log in protractor to log simple objects/variables, then yes, protractor is just javascript.
If your question is how to use console.log properly for promises (i.e. element(by.xyz).getText(), just keep in mind that everything protractor returns are promises, so you'll need to resolve the promise before doing console.log (see Protractor console log)
EDIT: okay, so you want to log objects from your browser. Protractors runs in a different process from your browser, so you would need to retrieve it first before doing console.log
browser.driver.executeScript(function() {
return window;
}).then(function(result) {
console.log('result is: ', result);
});
Upvotes: 1