I'm trying to get browser console logs using selenium webdriver - java. But code is getting "java.lang.IllegalArgumentException" error. How to clear this error?
This is my code
public class RandomDemo {
static WebDriver driver = null;
public static void main(String[] args) throws InterruptedException {
String projectPath = System.getProperty("user.dir");
DesiredCapabilities cap = DesiredCapabilities.chrome();
LoggingPreferences logPref = new LoggingPreferences();
logPref.enable(LogType.BROWSER, Level.ALL);
cap.setCapability(CapabilityType.LOGGING_PREFS, logPref);
System.setProperty("webdriver.chrome.driver", projectPath+ "/drivers/chromedriver.exe");
driver = new ChromeDriver(cap);
driver.get("https://www.flipkart.com/");
driver.manage().window().maximize();
extractLog();
}
public static void extractLog() {
LogEntries logEntries = driver.manage().logs().get(LogType.BROWSER);
for(LogEntry entry : logEntries){
System.out.println(new Date(entry.getTimestamp() + " " + entry.getLevel() + " " + entry.getMessage()));
}
}
}
Error which I'm getting is
Exception in thread "main" java.lang.IllegalArgumentException at java.util.Date.parse(Unknown Source) at java.util.Date.(Unknown Source) at StudentTestScreen.RandomDemo.extractLog(RandomDemo.java:41) at StudentTestScreen.RandomDemo.main(RandomDemo.java:34)