Reputation: 31
I need to add the console log after each test step to the allure report. I use selenium, testng, cucumber, spring boot
I tried to get logs from driver with code:
Allure.addAttachment("Console log: ", String.valueOf(webDriverActions.getDriver().manage().logs().get(LogType.BROWSER).getAll()));
but it show empty mass []
Upvotes: 3
Views: 11425
Reputation: 4349
With reference to your code you will need to read the LogEntries
LogEntries logEntries = webDriverActions.getDriver().manage().logs().get(LogType.BROWSER);
StringBuilder logs = new StringBuilder();
for (org.openqa.selenium.logging.LogEntry entry : logEntries) {
logs.append(new Date(entry.getTimestamp()) + " "
+ entry.getLevel() + " " + entry.getMessage());
logs.append(System.lineSeparator());
}
System.out.println(logs);
Allure.addAttachment("Console log: ", logs);
Upvotes: 2