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

JsonException when trying to read console from firefox #7792

Closed
surli opened this issue Nov 15, 2019 · 3 comments
Closed

JsonException when trying to read console from firefox #7792

surli opened this issue Nov 15, 2019 · 3 comments
Labels

Comments

@surli
Copy link

surli commented Nov 15, 2019

🐛 Bug Report

I cannot retrieve the firefox console logs, I get the following JsonException when I try to do so:

Exception in thread "main" org.openqa.selenium.json.JsonException: Unable to determine type from: H. Last 1 characters read: H
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'vivat', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '5.3.10-arch1-1', java.version: '1.8.0_232'
Driver info: driver.version: RemoteWebDriver
	at org.openqa.selenium.json.JsonInput.peek(JsonInput.java:122)
	at org.openqa.selenium.json.JsonTypeCoercer.lambda$null$6(JsonTypeCoercer.java:140)
	at org.openqa.selenium.json.JsonTypeCoercer.coerce(JsonTypeCoercer.java:126)
	at org.openqa.selenium.json.Json.toType(Json.java:69)
	at org.openqa.selenium.json.Json.toType(Json.java:55)
	at org.openqa.selenium.json.Json.toType(Json.java:50)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:87)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	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)

After debugging on W3CHttpResponseCode#decode, it seems that the exception is thrown because the content of the response is not a JSON but a text/plain that only contains "HTTP method not allowed".

When checking what request has been sent, it seems that the following POST request is performed:

POST /session/81a0b1fc-cc58-468e-9976-3d783c18f1db/log

So I guess there is two issues:

  • the command is wrong for Firefox
  • the error is not parsed correctly

I don't reproduce on Chrome, only on Firefox.

To Reproduce

Here's the Java method I'm using to reproduce:

// GeckoDriver v0.26.0
System.setProperty("webdriver.gecko.driver", "/home/urli/geckodriver/geckodriver");
FirefoxOptions firefoxOptions = new FirefoxOptions();
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);

firefoxOptions.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);

WebDriver driver = new FirefoxDriver(firefoxOptions);
driver.get("https://developer.mozilla.org/fr/docs/Web/API/console");
for (LogEntry logEntry : driver.manage().logs().get(LogType.BROWSER)) {
   System.out.println(String.format("[%s] [%s]", logEntry.getLevel(), logEntry.getMessage()));
}
driver.quit();

Detailed steps to reproduce the behavior:

Expected behavior

I expect to see the browser console logs.

Environment

OS: ArchLinux
Browser: Firefox
Browser version: 70.0.1
Browser Driver version: GeckoDriver 0.26.0
Language Bindings version: Java 3.141.59

@barancev
Copy link
Member

geckodriver does not support logging at the moment, please follow this issue: mozilla/geckodriver#284

But we'll try to improve the error message to make it more user-friendly.

@barancev
Copy link
Member

Fixed by 6a9c546

@lock
Copy link

lock bot commented Dec 17, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

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

No branches or pull requests

2 participants