Capturing browser logs with Selenium WebDriver using Java

后端 未结 9 2004
闹比i
闹比i 2020-11-28 03:01

Is there a way to capture browser logs while running automated test cases with Selenium? I found an article on how to capture JavaScript errors in Selenium. But that is just

9条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 03:25

    Driver manager logs can be used to get console logs from browser and it will help to identify errors appears in console.

       import org.openqa.selenium.logging.LogEntries;
       import org.openqa.selenium.logging.LogEntry;
    
        public List getBrowserConsoleLogs()
        {
        LogEntries log= driver.manage().logs().get("browser")
        List logs=log.getAll();
        return logs;
        }
    

提交回复
热议问题