Skip to content

Easy access to console logs #259

Closed
daleharvey opened this Issue Feb 21, 2014 · 11 comments

3 participants

@daleharvey

When debugging having an easy way to dump anything that get sent to the console would be great, so far the only way I have seen is to hack around sending firefox stdout somewhere which is specific and nasty

@sebv
Collaborator
sebv commented Feb 22, 2014

There is a logging api in jsonwire, but its recent and support is not great yet (not sure actually how bad it is).

@daleharvey

yeh I have been meaning to look into it but its fairly hard to figure out between the browser implementation / selenium implementation / client where is the right place to look for things

@sebv sebv closed this Mar 4, 2014
@daleharvey

Why was this closed, I would still very much like this, the support issue seems like it should be clarified

@sebv sebv reopened this Mar 5, 2014
@sebv
Collaborator
sebv commented Mar 5, 2014

I can leave it open, but this is more something to report on specific Selenium Driver projects, the logging logic is implemented in this package.

@sebv
Collaborator
sebv commented Apr 18, 2014

I am closing, because it is not a wd issue. Either check the log methods directly on the server side, or override console.log.

@sebv sebv closed this Apr 18, 2014
@binarykitchen

@sebv Really? Show an example please. Thanks!

@sebv
Collaborator
sebv commented Apr 19, 2014

Something like this will be portable across browsers:

driver.execute('window.MSG=""; window.console.log = function(msg) {window.MSG +=  msg;}')
...
// test something
...
driver.eval('window.MSG;')

Can also check those: https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/log,
but I think it gets the browser log rather than the console log.

@binarykitchen

Yeah, would work but is a "too hackish" approach, so no thanks, sorry.

This worked for me, but I do not like it either:

        this.browser.get(baseUrl + "/thispagedoesnotexist/thispagedoesnotexist")
            .waitForElementByTagName('h2', 2000)
            .log('browser')
            .then(done, done);

.log('browser'); gives me the browser's console output at this stage.

But what I really want is to REDIRECT the browser's console to stdout during the grunt task which runs my local e2e test. As if it were a stream, pipe the browser's console to the command console.

Like that:

        this.browser.stdout.pipe(process.stdout) // could repeat the same line for stderr
            .get(baseUrl + "/thispagedoesnotexist/thispagedoesnotexist")
            .waitForElementByTagName('h2', 2000)
            .then(done, done);

That would be awesome! The huge advantage is that I do not need to call .log('browser') between the lines to regularly check for problems within the browser.

@sebv
Collaborator
sebv commented Apr 21, 2014

Yeah but we don't write jsonwire spec here.

@binarykitchen

Huh, sorry, I cannot follow you. What do you mean jsonwire spec?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.