简体   繁体   中英

How to get browser console error messages using Selenium WebDriver + Java?

After tests are run, I want to collect all console error messages displayed in the console(Open Firebug -> Click on Console -> Click on Errors) using Selenium WebDriver + Java.

I tried the answer mentioned here , but it only displays messages for 'Warnings', 'Info' but not for 'Errors'

I want only Console errors like -

控制台日志

Can someone please help me how to get those Console log?

Use JSErrorCollector , to collect javascript errors (those coming up in the console) from firefox through java.

it gets as simple as this,

final List<JavaScriptError> jsErrors = JavaScriptError.readErrors(driver); 

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM