Capturing browser logs with Selenium WebDriver using Java

后端 未结 9 2032
闹比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:32

    In a more concise way, you can do:

    LogEntries logs = driver.manage().logs().get(LogType.BROWSER);
    

    For me it worked wonderfully for catching JS errors in console. Then you can add some verification for its size. For example, if it is > 0, add some error output.

提交回复
热议问题