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?

2

1 Answer 1

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); 
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you Deepak, for answer and most importantly pointing to JsErrorCollector git repo!!!
@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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.