Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 -

Console log

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

like image 406
Alpha Avatar asked Jul 06 '14 08:07

Alpha


1 Answers

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); 
like image 93
deepak Avatar answered Sep 18 '22 12:09

deepak