Reading from browser log during testing?

692 views
Skip to first unread message

Curtis Matthews

unread,
Jul 30, 2014, 4:15:05 PM7/30/14
to robotframe...@googlegroups.com
So I've recently been trying to chase an intermittent issue with one of our sites where we intermittently get a 502 response from the server where we're getting our CSS. The way we've been diagnosing this manually is to simply refresh certain pages and look for them in the Console log. Then I discovered the need to script some basic QC on CMS site implementations to look for broken links to images & other content (which the implementation team has been doing the same way, by looking for 404s in the Console). 

 In Webdriver you can grab the browser log by calling driver.get_log('browser'), at which point you could just string-search anything you felt like looking for. Not sure how I'd achieve that in RF though, and it'd be really elegant to have some way of maybe tying a search for errors in the console log to a test teardown keyword & log any found issues to the RF console. 

Before I started going down the road of writing my own library to do this, thought I'd see if someone else had a better idea or solution?

Kevin O.

unread,
Jul 31, 2014, 10:37:22 AM7/31/14
to robotframe...@googlegroups.com
That functionality is in beta status. For me, IE threw error as it does not handle that method, Chrome returned an empty log, but Firefox worked. I don't have the latest packages though.
If you want to do a string search, you should use Convert To String first or similar, as get_log returns a list of dict.
Here is how you can get the log from a user keyword. If you want to do it in Python, there are examples of similar code in older posts.

Browser Log
    Open Browser    https://www.google.com    ff
    ${s2l}=    Get Library Instance    Selenium2Library
    ${log}=    Call Method    ${s2l._current_browser()}    get_log    browser
    Log List    ${log}
    [Teardown]    Close Browser

Cheers,
Kevin

gabor.s...@gmail.com

unread,
Jan 13, 2018, 6:44:19 AM1/13/18
to robotframework-users
Hi,

Browser Log
    Open Browser    https://www.google.com    ff
    ${sl}=    Get Library Instance    SeleniumLibrary
    ${log}=    Call Method    ${sl._current_browser()}    get_log    browser
    Log List    ${log}
    [Teardown]    Close Browser

As I understand this Browser Log test case does not work anymore because :

Calling method 'get_log' failed: WebDriverException: Message: POST /session/.../log did not match a known command

and

From here: https://github.com/SeleniumHQ/selenium/issues/2972
"
This is not implemented in GeckoDriver b/c it is not part of the WebDriver spec."

Is there any workaround to get somehow the "Browser Console" Log in Firefox?

There is some interesting discussion about it here :
https://github.com/robotframework/SeleniumLibrary/issues/574

Where Pekka Klärk suggests some solution:
https://github.com/robotframework/SeleniumLibrary/issues/574#issuecomment-346700294

But I get the same error message If I use it.

Is there any solution to get browser console log to use them in robot tests?

Kind regards,
Gabor

Tatu Aalto

unread,
Jan 16, 2018, 8:40:41 AM1/16/18
to gabor.s...@gmail.com, robotframework-users
Ugh

If the method is not implement in the downstream projects, like geckodriver, then the upstream project, like SeleniumLibrary, does not have any means to get it. If you want browser logs, using Chrome is a realistic option. Also please vote for the issue in the geckodriver issue that it gets implemented at some point.

-Tatu
Send from my mobile

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.

For more options, visit https://groups.google.com/d/optout.

gabor.s...@gmail.com

unread,
Jan 16, 2018, 1:20:08 PM1/16/18
to robotframe...@googlegroups.com
HI Tatu,

Thanks for your comment.

>If the method is not implement in the downstream projects, like geckodriver, then the upstream project, like SeleniumLibrary does not have any means to get it
I understand it so I just wanted to get some workaround or ideas.


>Also please vote for the issue in the geckodriver issue that it gets implemented at some point.
It does not make sense. GeckoDriver developer wrote that the standard does not contain "get_log" so they do not support it.

Anyway I do not need it anymore because I realized that javascript:window.dump() appears in geckodriver.log so I can use it.

Kind regards,
Gabor
To post to this group, send email to robotframe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages