testerra icon indicating copy to clipboard operation
testerra copied to clipboard

Always log Browser's console messages/errors on failed test

Open mreiche opened this issue 3 years ago • 1 comments

Implement reading console log messages that comes from the browser when a test failed.

Proposal

public List<String> getJavaScriptLog() {
    List<String> list = new LinkedList<>();
    LogEntries logEntries = this.getWebDriver().manage().logs().get(LogType.BROWSER);
    for (LogEntry entry : logEntries) {
        list.add(new Date(entry.getTimestamp()) + " " + entry.getLevel() + " " + entry.getMessage());
    }
    return list;
} 

mreiche avatar Jan 24 '22 10:01 mreiche

With Selenium 4 we get native support of Chrome DevTools: https://www.selenium.dev/documentation/webdriver/bidirectional/chrome_devtools/.

martingrossmann avatar Jan 24 '22 11:01 martingrossmann