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'.
The FirefoxDriver is not configured to capture JS console output.
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. :smiley:
Sounds interesting :)
Where can I find this add-on?
@axelssonHakan first search result on Google and GitHub.
https://github.com/mguillem/JSErrorCollector
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.
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.
Any update on this?
Is there any update regarding to this issue?
I am having the same issue with selenium 2.53.1 and firefox 45.3ESR
+1 for this.
can somehow outpass this?... any chance with using geckodriver?
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)
@tttower Geckodriver does not support logging API yet, follow https://github.com/mozilla/geckodriver/issues/284 to track status of this feature.
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 https://github.com/mozilla/geckodriver/issues/284
Most helpful comment
I am having the same issue with selenium 2.53.1 and firefox 45.3ESR