I'm trying to get logs from the browser while running my test with selenium webdriver.
driver.manage().logs().get("browser").forEach(l -> System.out.println(l));
I want to print a message to the console if i get "severe" error.
Here is a workaround to your problem...
LogEntries logEntries = driver.manage().logs().get(LogType.BROWSER);
for (LogEntry entry : logEntries) {
System.out.println(new Date(entry.getTimestamp()) + " " + entry.getLevel() + " " + entry.getMessage());
}
If this doesn't work, put a lag Thread.sleep(1000)
before getting logs like below
Thread.sleep(1000);
LogEntries logEntries = driver.manage().logs().get(LogType.BROWSER);
for (LogEntry entry : logEntries) {
System.out.println(new Date(entry.getTimestamp()) + " " + entry.getLevel() + " " + entry.getMessage());
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.