I'm writing selenium tests which are launch on the firefox (gecko) driver.
If a test fails, I want to retrieve the log present on the firefox js console.
In order to do that, I have added the following into my code:
On the "Before" statement:
LoggingPreferences logs = new LoggingPreferences();
logs.enable(LogType.BROWSER, Level.ALL);
logs.enable(LogType.DRIVER, Level.ALL);
logs.enable(LogType.CLIENT, Level.ALL);
logs.enable(LogType.PERFORMANCE, Level.ALL);
logs.enable(LogType.PROFILER, Level.ALL);
logs.enable(LogType.SERVER, Level.ALL);
options.setCapability(CapabilityType.LOGGING_PREFS, logs);
driver = new FirefoxDriver(options);
On the "After" statement:
try {
FileOutputStream out = new FileOutputStream("target/surefire-reports/consoleLog-" + fileName + ".log");
List<LogEntry> myLogs = driver.manage().logs().get(LogType.BROWSER).getAll();
for (int i = 0; i < myLogs.size(); i++){
out.write(myLogs.get(i).toString().getBytes());
}
out.close();
}
However, when this is run, I got the following error:
org.openqa.selenium.UnsupportedCommandException: POST /session/a6064f0a-713c-4f55-9a17-f6d80f4c457d/log did not match a known command
After doing some research, it turns out that The Selenium log API is not (yet?) supported by geckodriver. (source: link 1, link 2)
Question:
So, is there some other way around to accomplish what I want to accomplish? (using Chrome instead of Firefox is not a solution).