Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firefox: logs().get( "browser" ) doesn't show console errors? #1161

Closed
axelssonHakan opened this issue Oct 15, 2015 · 14 comments
Closed

Firefox: logs().get( "browser" ) doesn't show console errors? #1161

axelssonHakan opened this issue Oct 15, 2015 · 14 comments

Comments

@axelssonHakan
Copy link

I'm trying to save the console logs after each test but having some problems with Firefox.
With a test like:

describe("protractor/webdriver", function() {
    it("should be able to get browser logs", function() {
        browser.get("https://angularjs.org");

        browser.executeScript("console.log('Nothing to see here - move along.')");
        browser.executeScript("console.warn('This is your first warning!')");
        browser.executeScript("console.error('This is serious!!!')");

        browser.driver.manage().logs().get( "browser" ).then(function( logsEntries ) {
            logsEntries.forEach( (item) => {
                console.log( "LOG LEVEL:", item.level.name, item.message );
            });
        });
    });
});

For Chrome I get the result nicely:

[chrome #1] LOG LEVEL: WARNING console-api 240:41 This is your first warning!
[chrome #1] LOG LEVEL: SEVERE console-api 240:41 This is serious!!!

But Firefox only returns "Internal" warnings (CSS parse):

[firefox #2] LOG LEVEL: WARNING Unknown property 'zoom'.  Declaration dropped.
[firefox #2] LOG LEVEL: WARNING Unknown property 'user-select'.  Declaration dropped.
[firefox #2] LOG LEVEL: WARNING Unknown property 'zoom'.  Declaration dropped.
[firefox #2] LOG LEVEL: WARNING Error in parsing value for 'background-image'.  Declaration dropped.
[firefox #2] LOG LEVEL: WARNING Error in parsing value for 'background-image'.  Declaration dropped.
[firefox #2] LOG LEVEL: WARNING Expected media feature name but found '-webkit-min-device-pixel-ratio'.
@jleyba
Copy link
Contributor

jleyba commented Oct 15, 2015

The FirefoxDriver is not configured to capture JS console output.

@Unnumbered
Copy link

This issue can be resolved partially by installation of JSErrorCollector addon, but as far as I know it can catch only errors (not warnings).

I hope to see this functional in future version of Selenium. 😃

@axelssonHakan
Copy link
Author

Sounds interesting :)
Where can I find this add-on?

@Unnumbered
Copy link

@axelssonHakan first search result on Google and GitHub.
https://github.com/mguillem/JSErrorCollector

@svetlin-mladenov
Copy link

I am experiencing the same issue. My environment is Ubuntu 14.04 LTS, Firefox 42, Selenium Version 2.48.0.

Here is my test html page:

<!DOCTYPE HTML>
<html>
<head>
        <script> console.log('console log'); </script>
</head>
<body></body>
</html>

and my test python script

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import time

d = DesiredCapabilities.FIREFOX
d['loggingPrefs'] = { 'browser':'ALL' }
driver = webdriver.Firefox(capabilities=d)

# chrome
# d = DesiredCapabilities.CHROME
# d['loggingPrefs'] = { 'browser':'ALL' }
# driver = webdriver.Chrome(desired_capabilities=d)

driver.get('http://localhost:8000/consolelog.html')
time.sleep(2) # time for page to load
logs = driver.get_log('browser')
messages = map(lambda l: l['message'], logs)
has_console_logs = any(map(lambda m: m.find('console log') >= 0, messages))
print('Success' if has_console_logs else 'Failure')
driver.quit()

When the chrome driver is used the console log message is found in the list of browser messages (has_console_log is True). When Firefox driver is used driver.get_log('browser') returns a lot of stuff mostly browser debugging info. However the console log message is not found.

@dcoraboeuf
Copy link

Same issue in my case, with the same versions. Still looking for a solution, even a workaround, since having the console after the tests have run is very precious for analysis of failures. I'm using Firefox because I have to support different OS and this was the easiest to support.

@shaharmor
Copy link

Any update on this?

@malafeev01
Copy link

Is there any update regarding to this issue?

@sundeep-gupta
Copy link

I am having the same issue with selenium 2.53.1 and firefox 45.3ESR

@nickrnet
Copy link

+1 for this.

@iszlailorand
Copy link

can somehow outpass this?... any chance with using geckodriver?

@kestasjas
Copy link

Same problem with GeckoDriver 0.16.1, FF-53.0.3, Selenium 3.4.0
WebDriver.Manage().Logs.GetLog(LogType.Browser) Exception:

System.NullReferenceException: Object reference not set to an instance of an object.
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteLogs.GetLog(String logKind)

@barancev
Copy link
Member

@tttower Geckodriver does not support logging API yet, follow mozilla/geckodriver#284 to track status of this feature.

@barancev
Copy link
Member

Development of XPI-based Firefox driver has been discontinued and this issue will never be fixed in it.

For the new geckodriver-based implementation follow mozilla/geckodriver#284

@lock lock bot locked and limited conversation to collaborators Aug 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests