21

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?

Community
  • 1
  • 1
Alpha
  • 13,320
  • 27
  • 96
  • 163
  • I got console logs using same code you referred i.e http://stackoverflow.com/questions/18261338/get-chromes-console-log/18283831#18283831. Make sure whatever website you looking at has a console errors otherwise it will just give you empty array list and nothing will be printed in eclipse console. – Swapnil Kotwal Jul 07 '14 at 05:50
  • Hier ist the solution for c#: [How to get browser console error messages using Selenium WebDriver + C#](https://stackoverflow.com/questions/70351421/how-to-get-browser-console-error-messages-using-selenium-webdriver-c-sharp/70351422#70351422) – Majdi Barrat Dec 14 '21 at 15:38

1 Answers1

12

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); 
deepak
  • 3,074
  • 2
  • 20
  • 29
  • Thank you Deepak, for answer and most importantly pointing to JsErrorCollector git repo!!! – Alpha Dec 01 '14 at 11:36
  • @deepak I am getting error for this package import and whereever JavaScriptError is used in my code, I've added jar file to my project as well import net.jsourcerer.webdriver.jserrorcollector.JavaScriptError; – Hassan Jun 23 '16 at 13:44