Is there a way to get the browser's console output from a test?

1,794 views
Skip to first unread message

kepp...@networkoptix.com

unread,
May 18, 2018, 1:43:32 PM5/18/18
to robotframework-users
I',m having an issue where for a specific instance of our software, the page just doesn't load when I run headless.  It works on others but not there.  As it is headless I can't check the console to see if it's upset by something there.  Is there a way to get the browser's console output?

Tatu Aalto

unread,
May 18, 2018, 5:30:02 PM5/18/18
to Kyle Epperson, robotframework-users
Ugh

Currently there is not a out of the box keyword in the SeleniumLibrary, but the good news is that one can do by extending SeleniumLibrary. In the Python Selenium API, there is a get_log [1] method, which allows one to collect the logs from many sources. The bad news is that not all browsers has support for the method, but last time I did try Chrome had the best support. There is documentation [2] for extending the SeleniumLibrary and user guide [3] contains lots of good information about libraries and extending other libraries.

-Tatu
Send from my mobile
[1] selenium.webdriver.remote.webdriver.WebDriver.get_log
[2] https://github.com/robotframework/SeleniumLibrary/blob/master/docs/extending/EXTENDING_SELENIUMLIBRARY.rst
On Fri, 18 May 2018, 20:43 , <kepp...@networkoptix.com> wrote:
I',m having an issue where for a specific instance of our software, the page just doesn't load when I run headless.  It works on others but not there.  As it is headless I can't check the console to see if it's upset by something there.  Is there a way to get the browser's console output?

--
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-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

kepp...@networkoptix.com

unread,
May 21, 2018, 12:39:59 PM5/21/18
to robotframework-users
I tried using your suggestion but I'm having an issue.  The documentation claims I should only need one argument "browser" but first of all it claims to want the webdriver instance.  When I feed it the webdriver it then wants a second argument.  Am I mistaken or is the documentation unclear?


On Friday, May 18, 2018 at 2:30:02 PM UTC-7, Tatu Aalto wrote:
Ugh

Currently there is not a out of the box keyword in the SeleniumLibrary, but the good news is that one can do by extending SeleniumLibrary. In the Python Selenium API, there is a get_log [1] method, which allows one to collect the logs from many sources. The bad news is that not all browsers has support for the method, but last time I did try Chrome had the best support. There is documentation [2] for extending the SeleniumLibrary and user guide [3] contains lots of good information about libraries and extending other libraries.

-Tatu
Send from my mobile
[1] selenium.webdriver.remote.webdriver.WebDriver.get_log
[2] https://github.com/robotframework/SeleniumLibrary/blob/master/docs/extending/EXTENDING_SELENIUMLIBRARY.rst
On Fri, 18 May 2018, 20:43 , <kepp...@networkoptix.com> wrote:
I',m having an issue where for a specific instance of our software, the page just doesn't load when I run headless.  It works on others but not there.  As it is headless I can't check the console to see if it's upset by something there.  Is there a way to get the browser's console output?

--
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.

Tatu Aalto

unread,
May 21, 2018, 2:31:54 PM5/21/18
to Kyle Epperson, robotframework-users
Ugh

There might be bug in your implementation. Would it be possible to see your code and perhaps we can correct the code?


-Tatu
Send from my mobile
On Mon, 21 May 2018, 19:40 , <kepp...@networkoptix.com> wrote:
I tried using your suggestion but I'm having an issue.  The documentation claims I should only need one argument "browser" but first of all it claims to want the webdriver instance.  When I feed it the webdriver it then wants a second argument.  Am I mistaken or is the documentation unclear?

On Friday, May 18, 2018 at 2:30:02 PM UTC-7, Tatu Aalto wrote:
Ugh

Currently there is not a out of the box keyword in the SeleniumLibrary, but the good news is that one can do by extending SeleniumLibrary. In the Python Selenium API, there is a get_log [1] method, which allows one to collect the logs from many sources. The bad news is that not all browsers has support for the method, but last time I did try Chrome had the best support. There is documentation [2] for extending the SeleniumLibrary and user guide [3] contains lots of good information about libraries and extending other libraries.

-Tatu
Send from my mobile
[1] selenium.webdriver.remote.webdriver.WebDriver.get_log
[2] https://github.com/robotframework/SeleniumLibrary/blob/master/docs/extending/EXTENDING_SELENIUMLIBRARY.rst
On Fri, 18 May 2018, 20:43 , <kepp...@networkoptix.com> wrote:
I',m having an issue where for a specific instance of our software, the page just doesn't load when I run headless.  It works on others but not there.  As it is headless I can't check the console to see if it's upset by something there.  Is there a way to get the browser's console output?

--
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-u...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
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-u...@googlegroups.com.

kepp...@networkoptix.com

unread,
May 21, 2018, 2:45:30 PM5/21/18
to robotframe...@googlegroups.com
I have my own custom library and I've tried putting this in both my library and seleniumlibrary.  I feel like there has to be something wrong with my implementation.
    def get_browser_log(self):
        return webdriver.remote.webdriver.WebDriver.get_log('browser')

Calling the keyword:
    ${console log}    get browser log
    log    ${console log}

Running my test with this gives this error:
TypeError: unbound method get_log() must be called with WebDriver instance as first argument (got str instance instead)

I have been able to satisfy the requirements:
def get_browser_log(self):
        return webdriver.remote.webdriver.WebDriver.get_log(webdriver.Chrome('<path to> chromedriver.exe'), 'browser')
But this gives me an output that is not useful:



On Monday, May 21, 2018 at 11:31:54 AM UTC-7, Tatu Aalto wrote:
Ugh

There might be bug in your implementation. Would it be possible to see your code and perhaps we can correct the code?

-Tatu
Send from my mobile

On Mon, 21 May 2018, 19:40 , <kepp...@networkoptix.com> wrote:
I tried using your suggestion but I'm having an issue.  The documentation claims I should only need one argument "browser" but first of all it claims to want the webdriver instance.  When I feed it the webdriver it then wants a second argument.  Am I mistaken or is the documentation unclear?

On Friday, May 18, 2018 at 2:30:02 PM UTC-7, Tatu Aalto wrote:
Ugh

Currently there is not a out of the box keyword in the SeleniumLibrary, but the good news is that one can do by extending SeleniumLibrary. In the Python Selenium API, there is a get_log [1] method, which allows one to collect the logs from many sources. The bad news is that not all browsers has support for the method, but last time I did try Chrome had the best support. There is documentation [2] for extending the SeleniumLibrary and user guide [3] contains lots of good information about libraries and extending other libraries.

-Tatu
Send from my mobile
[1] selenium.webdriver.remote.webdriver.WebDriver.get_log
[2] https://github.com/robotframework/SeleniumLibrary/blob/master/docs/extending/EXTENDING_SELENIUMLIBRARY.rst
On Fri, 18 May 2018, 20:43 , <kepp...@networkoptix.com> wrote:
I',m having an issue where for a specific instance of our software, the page just doesn't load when I run headless.  It works on others but not there.  As it is headless I can't check the console to see if it's upset by something there.  Is there a way to get the browser's console output?

--
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 robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
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.

Tatu Aalto

unread,
May 21, 2018, 3:49:19 PM5/21/18
to Kyle Epperson, robotframework-users
Ugh

Your code as is not correct and I am bit surprised that it doesn't raise an exception. Before you wonder deeper into the Python, it would be good to read some basic concepts [1][2]. But in any case, your code has a reference to a Python object, in this case it happens to be a class. The reference does not not know what instances have been created out of that that object, in other words, reference is not a cache. If you use SeleniumLibrary, then this should work fine:


def get_log(log):
    sl = BuiltIn().get_library_instance('SeleniumLibrary')
    return sl.driver.get_log(log)

The second line gets the active SeleniumLibrary instance from the Robot Framework. The third line uses SeleniumLibrary public API, to get the currently active WebDriver instance and uses the get_log method to return the log.

-Tatu
Send from my mobile
On Mon, 21 May 2018, 21:45 , <kepp...@networkoptix.com> wrote:
I have my own custom library and I've tried putting this in both my library and seleniumlibrary.  I feel like there has to be something wrong with my implementation.
    def get_browser_log(self):
        return webdriver.remote.webdriver.WebDriver.get_log('browser')

Calling the keyword:
    ${console log}    get browser log
    log    ${console log}

Running my test with this gives this error:
TypeError: unbound method get_log() must be called with WebDriver instance as first argument (got str instance instead)

I have been able to satisfy the requirements:
(webdriver.Chrome('<path to>chromedriver.exe'), 'browser')

But this gives me an output that is not useful:


On Monday, May 21, 2018 at 11:31:54 AM UTC-7, Tatu Aalto wrote:
Ugh

There might be bug in your implementation. Would it be possible to see your code and perhaps we can correct the code?

-Tatu
Send from my mobile

On Mon, 21 May 2018, 19:40 , <kepp...@networkoptix.com> wrote:
I tried using your suggestion but I'm having an issue.  The documentation claims I should only need one argument "browser" but first of all it claims to want the webdriver instance.  When I feed it the webdriver it then wants a second argument.  Am I mistaken or is the documentation unclear?

On Friday, May 18, 2018 at 2:30:02 PM UTC-7, Tatu Aalto wrote:
Ugh

Currently there is not a out of the box keyword in the SeleniumLibrary, but the good news is that one can do by extending SeleniumLibrary. In the Python Selenium API, there is a get_log [1] method, which allows one to collect the logs from many sources. The bad news is that not all browsers has support for the method, but last time I did try Chrome had the best support. There is documentation [2] for extending the SeleniumLibrary and user guide [3] contains lots of good information about libraries and extending other libraries.

-Tatu
Send from my mobile
[1] selenium.webdriver.remote.webdriver.WebDriver.get_log
[2] https://github.com/robotframework/SeleniumLibrary/blob/master/docs/extending/EXTENDING_SELENIUMLIBRARY.rst
On Fri, 18 May 2018, 20:43 , <kepp...@networkoptix.com> wrote:
I',m having an issue where for a specific instance of our software, the page just doesn't load when I run headless.  It works on others but not there.  As it is headless I can't check the console to see if it's upset by something there.  Is there a way to get the browser's console output?

--
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-u...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
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-u...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
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-u...@googlegroups.com.

kepp...@networkoptix.com

unread,
May 21, 2018, 3:55:51 PM5/21/18
to robotframework-users
My custom library has a class containing the keywords I made.  I didn't think all that would be necessary to provide.

And what you provided makes it make sense.  I had tried putting the "get_library_instance" into the get_log parameters but for some reason I didn't think of calling get_log on that instance.

Thanks.
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 robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
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 robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
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.
Message has been deleted

Tatu Aalto

unread,
May 22, 2018, 1:35:35 AM5/22/18
to Kyle Epperson, robotframework-users
Ugh


Does someone else have a better idea?


-Tatu
Send from my mobile

On Tue, 22 May 2018, 01:53 , <kepp...@networkoptix.com> wrote:
So, it all is working now, thank you.  However, it hasn't solved the problem of why I needed the console log.  Is there a way to get the network tab logs?

Kyle Epperson

unread,
May 22, 2018, 1:37:38 AM5/22/18
to robotframe...@googlegroups.com, aalto...@gmail.com
I ended up just using the remote debugging tool on our site and I get the same results so I think it has something to do with having a self signed certs so...  A whole new rabbit hole to go down.

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 robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
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 robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
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 robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
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.
Reply all
Reply to author
Forward
0 new messages