Last active
September 24, 2017 17:52
-
-
Save 4M01/785e4ffa485d9d5e44700604f3be60a4 to your computer and use it in GitHub Desktop.
Capture JavaScript console error using Selenium WebDriver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Logs logs = driver.manage().logs(); | |
LogEntries logEntries = logs.get(LogType.BROWSER); | |
for(LogEntry logEntry :logEntries) | |
{ | |
if (logEntry.getMessage().toLowerCase().contains("error")) { | |
System.out.println("Error Message in Console:"+logEntry.getMessage()); | |
} else if (logEntry.getMessage().toLowerCase().contains("warning")){ | |
System.out.println("Warning Message in Console:"+logEntry.getMessage()); | |
}else{ | |
System.out.println("Information Message in Console:"+logEntry.getMessage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment