The stack trace of an exception in a log file is a sign that something went wrong. Even if nobody complains it is wise to take a bit time and investigate it before it really hurts.
Tester’s friendly application and injected error handler
in every page of your application (see for instance this post).
This allows you to retrieve the captured errors with
This is a simple solution but it has different drawbacks. First you need to add this code at the beginning of all your HTML pages. If you’re in the ideal situation to be both developer and tester of the application it’s “just” one Ctrl+C and a lot of Ctrl+V. If you need to convince your colleagues or your management that the web pages should be modified for testability, it will be more difficult. From my experience it is not always easy to make such a requirement accepted.
To overcome this problem we could imagine injecting the handler while running the test:
executeScript statement is reached.
Add support within the FirefoxDriver
WebDriver on its side allows to add custom extensions to run in a
FirefoxDriver. If you simply add this errors capturing extension to the
Ideally the API should be provided natively by WebDriver, let’s see what will be the interest in my JSErrorCollector (follow issue 148 to stay informed).
JSErrorCollector is open source therefore patches are welcome. If you can’t/don’t want to contribute directly, I’m available to work on it on a contract base.