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

Cannot Get Console Error Logs from Firefox #330

Closed
JasonSmiley208 opened this issue Nov 10, 2016 · 17 comments
Closed

Cannot Get Console Error Logs from Firefox #330

JasonSmiley208 opened this issue Nov 10, 2016 · 17 comments

Comments

@JasonSmiley208
Copy link

JasonSmiley208 commented Nov 10, 2016

Tested using Gecko driver v0.11.1
Firefox Browser version 49.0.2
Selenium version 3.0.1
Mac OS: 10.11.6

Code:

//Setup
System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir") + getFirefoxPathForOs());

                    capabilities = DesiredCapabilities.firefox();
                    capabilities.setCapability(CapabilityType.LOGGING_PREFS, loggingPrefs);   //Setup Logging
                    capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);

                    driver = new FirefoxDriver(capabilities);

//Test Code runs here

//Teardown
 private void lookForJSErrors(Scenario scenario) {
  LogEntries logEntries = driver.manage().logs().get(LogType.BROWSER); //Fails Here
        List<LogEntry> severeErrors = logEntries.filter(Level.SEVERE);

        if(!severeErrors.isEmpty()) {
            scenario.write("Severe Javascript errors:\n");
            int count = 1;

            for (LogEntry entry : severeErrors) {
                scenario.write(count + ") " + entry.getTimestamp() + " " + entry.getLevel() + " " + entry.getMessage() + "\n");
                count++;
            }
        }
  }

Stack trace:

org.openqa.selenium.UnsupportedCommandException: POST /session/01a58591-d09f-584d-b004-b3bd19d66cd2/log did not match a known command
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'MacBook-Pro-7.local', ip: '10.0.21.70', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, firefoxOptions={args=[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Mv7cuxX5F2IMzUabE9o0bAUzW9De6PWd4vAbtSiZsUOmCzUiYvTQew1m+lnY7c0fdM3/V5zcp0bhhzt5E0gjLqiaWDMsKoGnK+8Br7+0ivc56fSvnD+ESaETBGzmdExuWX/7XaNbKzSx2Htyw6LvebrMr5BMcX+LqRK7NOyqoM6MR73XMcX/0YL6dgIpMFFsiPiIi2fDg4w2u0+aVdFYuPGObP87IRClT7afmfYrSX/A1BLBwhBnVeOvQMAAOcMAABQSwECFAAUAAgICAAiZ2pJQZ1Xjr0DAADnDAAABwAAAAAAAAAAAAAAAAAAAAAAdXNlci5qc1BLBQYAAAAAAQABADUAAADyAwAAAAA=}, loggingPrefs={browser=ALL}, appBuildId=20161019084923, version=, platform=MAC, ensureCleanSession=true, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=15889, browserVersion=49.0.2, platformVersion=15.6.0, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=darwin, device=desktop}]
Session ID: 01a58591-d09f-584d-b004-b3bd19d66cd2
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:127)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:35)
at org.openqa.selenium.remote.RemoteLogs.getRemoteEntries(RemoteLogs.java:81)
at org.openqa.selenium.remote.RemoteLogs.get(RemoteLogs.java:77)
at web.support.hooks.SeleniumSetupAndTeardown.lookForJSErrors(SeleniumSetupAndTeardown.java:70)
at web.support.hooks.SeleniumSetupAndTeardown.teardown(SeleniumSetupAndTeardown.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at cucumber.runtime.Utils$1.call(Utils.java:37)
at cucumber.runtime.Timeout.timeout(Timeout.java:13)
at cucumber.runtime.Utils.invoke(Utils.java:31)
at cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:60)
at cucumber.runtime.Runtime.runHookIfTagsMatch(Runtime.java:223)
at cucumber.runtime.Runtime.runHooks(Runtime.java:211)
at cucumber.runtime.Runtime.runAfterHooks(Runtime.java:205)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:46)
at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)
at cucumber.runtime.Runtime.run(Runtime.java:121)
at cucumber.api.cli.Main.run(Main.java:36)
at cucumber.api.cli.Main.main(Main.java:18)

@andreastt
Copy link
Contributor

geckodriver is an implementation of W3C WebDriver which doesn’t specify a log interface at the moment, so this is expected behaviour.

@JasonSmiley208
Copy link
Author

JasonSmiley208 commented Nov 10, 2016

Ok thanks! I will look for it in the next release (whenever that is)

@andreastt
Copy link
Contributor

This won’t be fixed in a future release until the working group decides to add it to the specification.

@stocarul
Copy link

Thanks so much for the geckodriver. @andreastt: Have you got any update regarding this matter? Such a feature would definitely improve the quality of our tests.

@andreastt
Copy link
Contributor

Well, we need to come to agreement with the other browser vendors about a sensible API. I don’t think the polling nature of the Selenium API is particularly sensible, but it may be the only option given the restrictions of having an HTTP protocol.

The tracking issue on the WebDriver standard is w3c/webdriver#406, but as we are just finishing up “level 1” for Candidate Recommendation, it is unlikely to be worked on in the near future.

@stocarul
Copy link

Thanks for letting us know.

@monolithed
Copy link

@andreastt, is there any active proposal or plan how to implement the log interface?

@andreastt
Copy link
Contributor

There isn’t an active proposal, but at F2F in Cambridge a few years ago we discussed using the Selenium log API as a template. You can see the meeting minutes from all the working group’s meetings at https://sny.no/bttmin.

That basically works by polling an endpoint for a certain log type. The driver will have cached N log entries internally in memory and returns these as an array.

This is a terrible design for many reasons, but I’m having a hard time seeing how it can be improved within the boundaries of the current protocol. If WebDriver was a duplex protocol, where the client could listen or subscribe to events from the server, this would be a much simpler task.

d-fence added a commit to odoo-dev/odoo that referenced this issue Dec 13, 2017
Firefox webdriver does not yet support browser console logs fetching:
mozilla/geckodriver#330
d-fence added a commit to odoo-dev/odoo that referenced this issue Jan 10, 2018
Firefox webdriver does not yet support browser console logs fetching:
mozilla/geckodriver#330
d-fence added a commit to odoo-dev/odoo that referenced this issue Feb 27, 2018
Firefox webdriver does not yet support browser console logs fetching:
mozilla/geckodriver#330
@simplyviks
Copy link

is there any other way i can get the logs? getting the same error
" POST /session/bd187703-8a6b-4b24-932e-c0f291ab0d91/log did not match a known command
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'ddc43231ad8a', ip: '172.19.0.12', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_151'
Driver info: driver.version: unknown
Command duration or timeout: 27 milliseconds
Build info: version: '2.52.0', revision: '4c2593cfc3689a7fcd7be52549167e5ccc93ad28', time: '2016-02-11 11:22:43'
System info: host: 'host-30-1-1-104', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-47-generic', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities [{moz:profile=/tmp/rust_mozprofile.LglkNJrTXaRn, rotatable=false, timeouts={implicit=0, pageLoad=300000, script=30000}, pageLoadStrategy=normal, moz:headless=false, platform=ANY, moz:accessibilityChecks=false, acceptInsecureCerts=true, browserVersion=58.0, platformVersion=4.4.0-47-generic, moz:processID=2043, browserName=firefox, platformName=linux, moz:webdriverClick=true}]
Session ID: bd187703-8a6b-4b24-932e-c0f291ab0d91
"

@andreastt
Copy link
Contributor

@simplyviks No, there is no log interface in geckodriver yet.

@simplyviks
Copy link

@andreastt thanks for confirming that.

@AndyGee
Copy link

AndyGee commented Sep 12, 2018

geckodriver is an implementation of W3C WebDriver which doesn’t specify a log interface at the moment, so this is expected behaviour.

It's this kind of response that is killing Firefox - If we (devs) can't test it using things like wdio and selenium out of the box then we simply stop using it - Very frustrated today after finding various breaking issues of Firefox (alone) - Logging, Keys and Actions to mention the one's that really are essential - I just can't believe these aren't on the 'Must fix today' list at Mozilla!

@andreastt
Copy link
Contributor

I’m not pointing fingers, but if anything you should channel your frustrations to the vendors who are implementing and shipping non-standards conforming implementations. If you consult https://wpt.fyi/results/webdriver/tests?label=experimental, you will find that geckodriver conforms closest to the standard that these vendors support and have said they are committed to.

@rsingh-03

This comment has been minimized.

@simplyviks

This comment has been minimized.

@whimboo
Copy link
Collaborator

whimboo commented Feb 11, 2019

Starting with Firefox 65 you are able to at least route any logging through the Console API to the geckodriver log. Here the entry from our geckodriver 0.24.0 release notes:

When using the preference devtools.console.stdout.content set to
true logging of console API calls like info(), warn(), and
error() can be routed to stdout.

@lock
Copy link

lock bot commented Aug 16, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have run into an issue you think is related, please open a new issue.

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

No branches or pull requests

8 participants