I want to capture log for any js event trigger or error Using selenium and java.Any type of help or suggestion will be appreciated? I tried this code but it's not working properly
public void HomePageConsole () throws InterruptedException {
driver.findElement(By.id("drop-down")).click();
driver.findElement(By.xpath(".//*[@id='js-top-currency']/li[4]/a")).click();
LogEntries logEntries = driver.manage().logs().get(LogType.BROWSER);
for (LogEntry entry : logEntries) {
// System.out.println(new Date(entry.getTimestamp()) + " " + entry.getLevel() + " " + entry.getMessage());
//System.out.println("Checking ExitUnit: 5th Line will be true ");
Thread.sleep(10000);
System.out.println("Exit Unit Open : "+entry.getMessage().contains("has been triggered!"));
}}
public void analyzeLog() {
LogEntries logEntries = driver.manage().logs().get(LogType.BROWSER);
for (LogEntry entry : logEntries) {
System.out.println(new Date(entry.getTimestamp()) + " " + entry.getLevel() + " " + entry.getMessage());
//do something useful with the data
}
}
A bit more efficient way to print the LogEntry by it's own toString override:
LogEntries logEntries = driver.manage().logs().get(LogType.BROWSER);
for (LogEntry entry : logEntries) {
System.out.println(entry.toString());
}
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.