WebDriver: capture JS errors while running tests

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.

Exactly the same applies to JavaScript errors in a web application. I believe that each JavaScript error should be considered as a bug and they should all be fixed before delivering, no matter if they directly impact the user experience or not.

Many great tools (JavaScript Console, Firebug, WebDeveloper Toolbar, …) allow to see the JavaScript errors while developing with Firefox as well as with other browsers and a wisely used error handler can report JavaScript errors to the server in production.

Sadly the support is not good while running automated tests. HtmlUnit provides a great help for that (see for instance this) but often integration tests should run in “real” browsers and not in HtmlUnit (for some good and many bad reasons). I don’t know currently any browser automation tool providing access to the JavaScript errors and to other information available in browsers like Firefox or Chrome that can be helpful for developers conscientious of the quality of their work

WebDriver is here not better than its concurrents and the issue “API for checking for JavaScript errors on the page” is opened since 2 1/2 years without any sign of life from the project’s members. The Selenium 1 issues SEL-522 and SEL-613 are equally asleep. Luckily WebDriver provides the possibility to configure additional extensions when using the FirefoxDriver, what allows to improve the situation.

Tester’s friendly application and injected error handler

The simpliest way to catch JavaScript errors for later retrieval is to add something like that

<script type="text/javascript">
window.jsErrors = [];
window.onerror = function(errorMessage) {
  window.jsErrors[window.jsErrors.length] = errorMessage;

in every page of your application (see for instance this post).

This allows you to retrieve the captured errors with

((JavascriptExecutor) driver).executeScript("return window.jsErrors");

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:

String script = "window.collectedErrors = [];"
  + "window.onerror = function(errorMessage) { "
  + "window.collectedErrors[window.collectedErrors.length] = errorMessage;"
  + "}";
((JavascriptExecutor) driver).executeScript(script);

but besides the fact that it has to be done on every page, we can’t do it early enough: a lot of JavaScript may already have been executed in the page when our executeScript statement is reached.

The second problem of an error handler per window is the difficult access to the captured errors. The JavaScript errors won’t necessarily occur in the currently focused window forcing you to iterate through all (i)frames and windows to check for errors. This can still be seen as a minor issue but the real problem is that captured errors get lost when a new document is loaded. At the end this solution allows to capture some JavaScript errors but not all JavaScript errors.

Add support within the FirefoxDriver

Firefox allows extensions to get notified of JavaScript errors, no matter where they occur.
This mechanism is used for instance by Chris Pederick’s famous Web Developer Toolbar to display a warn/error icon when an error has occurred on a page. Once you’ve succeeded in overcoming the sandbox mechanism separating extensions and loaded pages, it is quite easy to write a new Firefox extension that captures the JavaScript errors and makes them available in each content window.
WebDriver on its side allows to add custom extensions to run in a FirefoxDriver. If you simply add this errors capturing extension to the FirefoxProfile you’ll have access to all JavaScript errors from within your tests. Luckily you don’t need to write it again and you can simply use my JSErrorCollector (Apache 2 Licence). It allows to write following:

import net.jsourcerer.webdriver.jserrorcollector.JavaScriptError;
final FirefoxProfile profile = new FirefoxProfile();
final WebDriver driver = new FirefoxDriver(profile);
// ...
// navigate to some pages
// ...
List jsErrors = JavaScriptError.readErrors(driver);
assertThat(jsErrors, is(empty())

The JavaScriptError class holds the message, source name and line number of a JavaScript error just like what you can see in Firefox’s JavaScript console.

Next steps

Other browsers

It would be nice to have a simple access to JavaScript errors as well in the other browsers supported by WebDriver. For HtmlUnit it is a no-brainer. For Chrome it should be quite simple as an extension can register a global error listener. No idea what concerns IE and Opera.


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).
Retrieving the JavaScript errors is a first step on which different interesting features could be based. Verifying the absence of JavaScript errors after each test (using for instance JUnit’s @After) works fine but is tedious. One interesting feature would be to let the tests directly fail on the first JavaScript error (I’ll address wrapping drivers in a future post). Alternatively a precise dedicated reporting would have great benefits too. Some filtering features to ignore errors in third party libraries would be a nice feature as well.

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.


  1. Aaron Broad said,

    October 11, 2011 at 3:35 pm

    How difficult would it be to use your Firefox Extension in Ruby?

    I’ll be experimenting to find out this afternoon…

    • Marc Guillemot said,

      October 11, 2011 at 5:52 pm

      I don’t know WebDriver’s Ruby binding but according to http://http://code.google.com/p/selenium/wiki/RubyBindings#Firefox you can add an extension to the Firefox profile and according to
      http://code.google.com/p/selenium/wiki/RubyBindings#API_Example you can execute JavaScript code as well. It will therefore be possible to use the extension from Ruby as well.

      • Aaron Broad said,

        October 11, 2011 at 5:54 pm

        Thanks.. I”ll get it working and make a github fork with a ruby example. This is a lifesaver on my current project if I get it working. Thanks for your efforts!

    • Gabe Kopley said,

      November 17, 2011 at 12:27 am

      Here’s how I am using it with Rails+Capybara+Cucumber:

      # in features/support/env.rb
      require 'selenium/webdriver'
      # we need a firefox extension to start intercepting javascript errors before the page
      # scripts load
      Capybara.register_driver :selenium do |app|
      profile = Selenium::WebDriver::Firefox::Profile.new
      # see https://github.com/mguillem/JSErrorCollector
      profile.add_extension File.join(Rails.root, "features/support/extensions/JSErrorCollector.xpi")
      Capybara::Selenium::Driver.new app, :profile => profile
      After do |scenario|
      if page.driver.to_s.match("Selenium")
      errors = page.execute_script("return window.JSErrorCollector_errors.pump()")
      if errors.any?
      puts '————————————————————-'
      puts "Found #{errors.length} javascript #{pluralize(errors.length, 'error')}"
      puts '————————————————————-'
      errors.each do |error|
      puts " #{error["errorMessage"]} (#{error["sourceName"]}:#{error["lineNumber"]})"
      raise "Javascript #{pluralize(errors.length, 'error')} detected, see above"

      view raw
      hosted with ❤ by GitHub

  2. Yaci said,

    November 7, 2011 at 11:43 am

    I am using different extension that I found somewhere on the web. It captures the content of Firefox error console and saves it to a file.

    Quite easy way of checking for JS errors is setting XRE_CONSOLE_LOG environmental variable, which will cause Firefox to automatically log all sort of errors. However in this case a log is produced after closing the browser, so there’s no way of relating an error with a page on which it occured.

    Nice post btw, thanks for sharing. 🙂

  3. Gibeden said,

    November 30, 2011 at 7:13 am


    Is it possible to use your Firefox Extension in C#?

    • Marc Guillemot said,

      November 30, 2011 at 7:28 am

      Sure. The extension itself (the .xpi file) has nothing to do with Java. Just have a look in the code to see how errors are retrieved and you can do the same in C# (you can look at the Java code or at Gabe Kopley’s Ruby code). Feel free to send me a push request for your C# integration if you find it could be useful for other users.

  4. Gibeden said,

    December 15, 2011 at 3:12 pm


    How to clear all JS errors catched by JSErrorCollector?

    I just want get all JS errors after some action (click e.g.), not all JS errors from start of my test case.

    • Marc Guillemot said,

      December 15, 2011 at 3:34 pm

      Just call for captured errors before the action and discard the result.

      • Gibeden said,

        December 15, 2011 at 7:24 pm

        I’m sorry, but i think i didn’t understand you =(

        could you please explain more?

      • Gibeden said,

        December 16, 2011 at 11:41 am

        if you don’t mind i allowed myself to make some changes in your overlay.js on line 17:

        this.list = [];

        now it works exactly what i need.

  5. March 14, 2012 at 7:41 pm

    […] WebDriver: capture JS errors while running tests is a JS way of capturing JS errors on a page […]

  6. Yong said,

    March 16, 2012 at 5:35 am

    If this can be used for RemoteWebDriver?

    • Marc Guillemot said,

      March 19, 2012 at 8:16 am

      No idea. It depends wether a Firefox extension can be deployed to a RemoteWebDriver instance or not.

  7. Alper said,

    March 16, 2012 at 11:07 pm

    Does not work for me. I use selenium-java 2.20 and Firefox 11. The browser displays “JSErrorCollector: 0” in the addon bar. But if an error occurs, the counter is still zero and “JavaScriptError.readErrors(webDriver)” returns an empty list. Any ideas?

    • Marc Guillemot said,

      March 19, 2012 at 8:11 am

      Surprising. Is the JavaScript error visible in Firefox JavaScript console?

      • Alper said,

        March 19, 2012 at 9:59 am

        No it is not showing in the console.

      • Marc Guillemot said,

        March 19, 2012 at 10:25 am

        If FF console doesn’t show any error then it means… that there is no (un-catched) JS error and therefore no error can be captured 😉

      • Alper said,

        March 19, 2012 at 10:51 am

        Makes sense. Nevertheless, Selenium/Webdriver says:

        org.openqa.selenium.WebDriverException: null (WARNING: The server did not provide any stacktrace information)
        Command duration or timeout: 24 milliseconds
        Build info: version: ‘2.20.0’, revision: ‘16008’, time: ‘2012-02-28 15:00:40’
        System info: os.name: ‘Linux’, os.arch: ‘amd64’, os.version: ‘2.6.35-32-generic’, java.version: ‘1.6.0_20’
        Driver info: driver.version: RemoteWebDriver

      • Marc Guillemot said,

        March 23, 2012 at 7:37 am

        Hmm, this looks like an internal WebDriver error, not like a JS error on the tested page 😦

      • Alper said,

        March 23, 2012 at 9:19 am

        I am sure that these are JavaScript errors. Because if everything works fine and I execute invalid js code, the error above is thrown.

  8. yishai said,

    March 20, 2012 at 3:52 pm

    I’m using Chrome, so I don’t have the benefit of FF profiles.
    Instead, my test inserts the code you suggested at the beginning of your post.
    Unfortunately, when an error is triggered, all I get in window.collectedErrors is “Script error.”, instead of the full error description with source and line number.
    I’ve found a StackOverflow thread that this may be due to chrome’s same-origin policy.

    Has anyone run into this?

    Thanks for your work and the great post

  9. March 22, 2012 at 5:08 pm

    There are plans for adding ways of opting in on the JavaScript console in the WebDriver. That said, not much work has so far been done on specifying this in the forthcoming WebDriver specification

    You can have a look at the work in progress here: http://dvcs.w3.org/hg/webdriver/raw-file/tip/webdriver-spec.html

    If you have time and energy to submit for a patch for it, please feel free to.

    Opera already has a console-logger Scope service which allows you to tap in to one or more of the ecmascript, java, m2, network, xml, html, css, xslt, svg, bittorent, voice, widget or selftest logs during runtime. This has however not been exposed in OperaDriver yet, but my plan is to do so once we’ve established a good API for it.

    • Marc Guillemot said,

      March 26, 2012 at 3:31 pm

      You’re right, the OperaDriver features have some advance in this area compared to other drivers. Congratulations for it!
      Sadly my feeling is that the persons involved in other drivers are not particularly interested in such a feature. The resonance to the opened issue was really limited.

  10. Jan Kester said,

    March 23, 2012 at 11:55 am

    Is this JSErrorCollector also available from maven repository?

    • Marc Guillemot said,

      March 23, 2012 at 12:02 pm

      No, it isn’t. I have some other “WebDriver goodies” I’d like to pack together before publishing them to the Maven repository but I haven’t found time to continue working on it.

  11. Sumit said,

    May 9, 2012 at 4:49 pm

    Hi Marc

    Can you please help me out for the same java script error for Internet Explorer webdriver in selenium.

    It will be really great help

    • Marc Guillemot said,

      May 10, 2012 at 5:58 am

      Hi Summit,

      as written above, I have no idea how something similar could be done with IE 😦

      • Vullnet said,

        July 6, 2016 at 8:12 am

        Well regarding IE there is no way at all… IEDriver hasn’t implement the logging at all.. so there is no proper way(so far, clean way) to retrieve all console logs from IE..

  12. May 10, 2012 at 10:03 pm

    Hello Marc,

    Thanks for the brilliant effort. It helped me. Works on FF#12 and Selenium 2.21. Keep up the good work.

  13. sai said,

    July 12, 2012 at 12:05 pm

    Hi mark

    unable to get jserror.
    i have tried the following code, putting some java script error on the page load.

    import java.io.File;
    import java.io.IOException;
    import java.net.*;
    import java.util.List;

    import net.jsourcerer.webdriver.jserrorcollector.JavaScriptError;

    import org.junit.*;
    import org.junit.runner.RunWith;
    import org.junit.runners.BlockJUnit4ClassRunner;
    import org.openqa.selenium.*;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.chrome.ChromeDriverService;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.firefox.FirefoxProfile;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;

    public class selOneGrid {

    static WebDriver driver;

    public static void main(String []args) throws Exception{
    FirefoxProfile ffProfile = new FirefoxProfile();
    final WebDriver driver = new FirefoxDriver(ffProfile);


    List jsErrors = JavaScriptError.readErrors(driver);
    System.out.println(“Js errors….”+jsErrors.isEmpty());
    //assertTrue(jsErrors.toString(), jsErrors.isEmpty());


    • sai said,

      July 12, 2012 at 12:08 pm

      getting exception Exception in thread “main” org.openqa.selenium.UnhandledAlertException: Modal dialog present
      iam using selenium-standalone-server-2.19.jar and firefox 13

      • Marc Guillemot said,

        July 13, 2012 at 8:14 am

        Just read the name of the exception class, it says everything 😉

    • Arun said,

      March 20, 2013 at 5:43 pm

      Hi Mr Sai.

      i am new to selenium and i get the same exception
      org.openqa.selenium.UnhandledAlertException: Modal dialog present

      as you get.
      did you over come this problem?

      can you please give me a sample example.

      I appreciate you help


  14. Jan Kester said,

    July 19, 2012 at 11:41 am

    I don’t get it working. I see the eror collector gets installed (in lower right corner of firefox browser, it says errorcollector 0 items).
    Then I try to invoke a js error with:
    String statement = “addsdsd();”
    JavascriptExecutor js = (JavascriptExecutor) driver;

    I get a failure on selenium client side:
    Exception thrown: null (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 41 milliseconds
    Build info: version: ‘2.24.1’, revision: ‘17205’, time: ‘2012-06-19 15:28:49’
    System info: os.name: ‘Windows 7’, os.arch: ‘x86’, os.version: ‘6.1’, java.version: ‘1.6.0_25’
    Driver info: driver.version: RemoteWebDriver
    Session ID: 3d3635cd-f06e-40d8-aa31-0dc8658e6690

    So no information on JS error (function not defined I was expecting). Afterwards my JSErrorCollector is empty :-(. It also does not show me the error.

    I am using selenium java driver 2.24.1, and firefox 13.0.1.

    Regards, Jan Kester.

  15. skhanam said,

    August 7, 2012 at 10:21 am

    Hi There,

    Would someone let me know how to use it with C# pls.
    Am on WebDrover C# bindings 2.25.1 & FF14


  16. skhanam said,

    August 7, 2012 at 1:15 pm

    Hi There,i’ve got it highlighting JSError has 1 issue
    How do i grab that jsError message ..
    i want to grab is how

  17. Bryan said,

    August 14, 2012 at 11:31 pm

    A really useful addition would be to clear the errors, not just read them. Would help when you have multiple tests running and you want to more easily isolate where the errors happened.

    • Marc Guillemot said,

      August 16, 2012 at 3:25 pm

      This is already the case: each call to read the errors resets the captured errors list.

      • Bryan said,

        August 16, 2012 at 4:18 pm

        Well that was easy! Awesome tool!

  18. Benjamin Söltenfuß said,

    August 30, 2012 at 7:35 am

    first of all I want to thank you for this great Tool!

    I have a topic which is simliar to this and as you are the only one which i know, who has solved to communicate between selenium webdriver and a firefox plugin, i ask you 😉 .

    I want to call a js function from a plugin called wave (https://addons.mozilla.org/de/firefox/addon/wave-toolbar/) . Namely the “wave_viewIcons()”-js-function.

    So similiar to your JS_Error_collector, i tried it with:

    ((JavascriptExecutor) selenium).executeScript(“window.wave_viewIcons()”);

    (also some other calls which neither work)

    to call this function via Javascript (The Addon is already running in the Firefox profile from the webdriver and i can see it in the toolbar). Sadly this is not working. So my question:

    How can you communicate with a Firefox-Plugin? Do you have an Idea how to communicate and call a js-function from wave?

    Thanks a lot for your help!

    • Marc Guillemot said,

      August 30, 2012 at 11:47 am

      I suppose that this is a problem of scope.

      JavascriptExecutor.executeScript executes the provided script in the scope of the current window and therefore can only see objects/functions defined in this scope. For this reason, the JSErrorCollector places a reference to the object containing the collected errors as “JSErrorCollector_errors” in each window.

      • Benjamin Söltenfuß said,

        August 30, 2012 at 12:17 pm

        Sadly i am not so into JS, can you explain how to place such a reference in each window? You would help me very much!

  19. promdesign said,

    September 26, 2012 at 9:54 am

    Is it possible to use with Google chrome?
    If yes – how?

  20. September 28, 2012 at 4:28 pm

    Could you please add a software license to this? I would like to use it at work but cannnot without a clear license.

  21. maria said,

    December 3, 2012 at 4:36 pm

    Hi ,
    I’m glad that i found this article . I am having a problem . I’ve used the first ,method and injected the js code into a VerifyedLoading function and tested manually and seems to work.
    The thing is that when using webdriver to click on an element (a js error should occure) and it doesn’t appear any error in the console .
    There are some differnces between user click and webdriver click ?
    Or it could be something eles?


  22. December 13, 2012 at 8:34 am

    I am using jsErrorCollector and getting following error while running a test on Win 7 machine with Firefox 16:

    window.JSErrorCollector_errors.pump is not a function

    Same code works well on my Win XP with Firefox 16.

    • December 13, 2012 at 9:28 am

      Oops. That was because of Firefox 17 (not 16) on the other machine.

      Fixed by downloading latest jar (JSErrorCollector-0.4.jar)


      • Michael said,

        September 9, 2013 at 5:43 pm

        I am getting the same thing with version 0.4 and 0.5. I am running with FireFox v19.xx.

        Actually, with these two more recent versions the error message just says:

        window.JSErrorCollector_errors is undefined

  23. December 19, 2012 at 11:51 am

    […] checking for JavaScript errors on page load. There’s a couple of approaches out there, one involves copying and pasting a small snippet of JavaScript into each page. Since our application we […]

  24. Sandy said,

    January 28, 2013 at 3:03 pm

    I am using JUnit webdriver to test my pages. I am trying to use your amazing extension in my firefox profile. You have given an example how to use it in Ruby. Can you please give a snippet how to do it in Java Junit? I mean I can add the extension using driver.addExtension(.xpi file). But how should I catch the errors? Shall I call the method window.JSErrorCollector_errors.pump() on each page load? shall I call it after testcase? I am bit confused here. Kindly help

    • Marc Guillemot said,

      January 29, 2013 at 6:57 am

      Sandy, if you look at https://github.com/mguillem/JSErrorCollector, you’ll see that the code example is in Java.

      How often you call JavaScriptError.readErrors(driver); is up to you. I would call it at least once at the end of each test.

      • Sandy said,

        January 31, 2013 at 9:19 am

        Thanks Mark.

  25. Simeon said,

    February 14, 2013 at 6:46 am

    Dear Marc.

    Please tell me, how to make it work with Google Chrome?

    • John said,

      February 15, 2013 at 10:41 am

      I have the same question!

      • Marc Guillemot said,

        February 15, 2013 at 12:31 pm

        As mentioned above I think that it should be possible to write an extension for Chrome doing the same thing but I don’t know such an extension.

  26. Peter said,

    February 15, 2013 at 2:21 pm

    I’m testing JSErrorCollector, with Selenium 2.29 and FF 18 and don’t work ….. the extesion is installed in FF correctly, is ther any problem with these versions?

    • Simeon said,

      February 15, 2013 at 2:24 pm

      I’m testing with the same configuration: FF 18.0.2, WD – works perfect.

      • Peter said,

        February 15, 2013 at 2:39 pm

        If I execute window.JSErrorCollector_errors.pump() it’s return nothing []… I insure that the web is loaded completely, any help

      • Peter said,

        February 18, 2013 at 10:33 am


        It is necessary install other extension, firebug?, Simeon could you tell me witch extensions have installed? thanks

  27. Peter said,

    February 18, 2013 at 10:32 am


    It is necessary install other extension, firebug?, Simeon could you tell me witch extensions have installed? thanks

    • Simeon said,

      February 18, 2013 at 10:49 am

      Hello Peter. It works properly with firebug installed and without. Checked myself.

      • Peter said,

        February 18, 2013 at 12:30 pm

        My code is, could you help me please, I don’t Know what is incorrect

        FirefoxProfile profile = new FirefoxProfile();
        profile.addExtension(JavaScriptError.class, “c:\\JSErrorCollector.xpi”);
        profile.setPreference(“javascript.enabled”, true);
        FirefoxBinary binary= new FirefoxBinary(new File(“C:\\Archivos de programa\\Mozilla Firefox\\firefox.exe”));
        driver = new FirefoxDriver(binary,profile);
        System.out.println(“Result document.readyState: “+ ((JavascriptExecutor)driver).executeScript(“return document.readyState”));

        The docuemnt is completed

        System.out.println(“Result JSError: “+ ((JavascriptExecutor) driver).executeScript(“return window.JSErrorCollector_errors.pump()”));
        System.out.println(“Result JSError: “+ ((JavascriptExecutor) driver).executeScript(“return window.JSErrorCollector_errors.list”));

        Nothing is written

        jsErrors = JavaScriptError.readErrors(driver);

        System.out.println(“###start displaying size errors: “+ jsErrors.size());
        for(int i = 0; i < jsErrors.size(); i++) {
        System.out.println("###start displaying errors");


        Nothing is written


  28. Skip Huffman said,

    March 6, 2013 at 4:13 pm

    Excellent tool. Thank you.

  29. Brad said,

    April 26, 2013 at 1:36 am

    Thanks for your post..that was handy..

    At the moment i’m facing an issue when I executed this script, it displays the output in the browser which is correct but the script did not complete its execution and browser keep on running infinitely which displays “connecting..” on top of browser.
    It requires me to close the browser manually which throws another exception connecting to remote browser. But my question is why the test script did not complete execution and why the browser keep on running once it has rendered the output. I’m using Selenium Webdriver (selenium-2.31.0) and I’m using Java as my programming language. If anyone can help me to address this one that’ll be helpful

    driver – new FirefoxDriver();
    htmlString =”return document.write (‘Print the Test values in html format’);”;
    ((JavascriptExecutor) driver).executeScript(htmlString);

    Any help on this will be helpful as i’m struck on this.

    • Marc Guillemot said,

      April 26, 2013 at 4:26 am

      This has nothing to do with capturing JS errors, isn’t it? I think that this is rather a question for WebDriver’s mailing list… or that you should simply NOT use document.write.

  30. Brad said,

    April 26, 2013 at 4:49 am

    Yep..i think this is more relevant to Webdriver’s mailing list.. sorry if I’m at the right place.. but if you have any updates on this.. Pls let me know..

  31. Simeon said,

    August 13, 2013 at 8:43 am

    Now we have the same plug-in for Chrome. It’s here – https://github.com/dharrya/ChromeJSErrorCollector

    It is very similar to JSErrorCollector.

  32. Jeff said,

    August 27, 2013 at 3:21 pm

    Use JSErrorCollector.xpi and Chris Pederick’s Web Developer Toolbar (web_developer_1_2_5_sm_fx.xpi) together. JSErrorCollector will catch the error inside Web Developer Toolbar:

    {u’sourceName’: u’http://cdn2.chrispederick.net/javascript/6.1/fancy-box.fancy-box_work.installed.js’, u’errorMessage’: u’TypeError: $.browser is undefined’, u’console’: u’Error extracting content of Firebug console: Firebug.currentContext.getPanel(…) is null’, u’__fxdriver_unwrapped’: True, u’lineNumber’: 12}

    • Benno said,

      January 2, 2014 at 9:28 pm

      This is a great tool! I used it when I took over a project from someone else. I wasn’t sure about the javascript code quality, so I placed JSErrorCollector into existing Webdriver tests. And so it gave me a heads up on which pages had errors.

      Again great work!

  33. January 24, 2014 at 7:12 am

    […] (sort of) cross browser javascript error collector functionality for debugging with Selenium. Have buttons to inject the javascript error collection […]

  34. pooja said,

    February 21, 2014 at 1:34 pm

    Hi Marc ! Excellent work! thanks for writing it…
    however does it support capturing warnings? I did try but it didn’t find any warning (jsErrors comes empty list, though teher is a warning on the navigated page) . Kindly please update.

  35. Rashi said,

    April 9, 2014 at 6:43 pm

    When will this jar be available in Maven?

  36. kaat said,

    May 29, 2014 at 1:52 pm

    A maven jar would be really great

  37. October 3, 2014 at 10:06 pm

    […] WebDriver: capture JS errors while running tests | Marc … – Oct 11, 2011 · 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 …… […]

  38. sarose said,

    November 25, 2014 at 12:40 am

    Hi Marc,

    I have implemented this code in my script, to test it, I invoked some js errors on the web page, and executed this method, when I checked the log I am getting window.JSErrorCollector_errors is undefined
    Can you tell me what wrong am I doing here? I can email you the related code if you can take a look. thanks,



  39. November 30, 2014 at 6:09 am

    […] WebDriver: capture JS errors while running tests | Marc … – Oct 11, 2011 · January 28, 2013 at 3:03 pm. Mark, I am using JUnit webdriver to test my pages. I am trying to use your amazing extension in my firefox profile. You have …… […]

  40. December 29, 2014 at 6:53 pm

    […] using a technique I found here, to capture javascript errors for testing purposes. It’s a technique that is frequently […]

  41. Anuj said,

    January 13, 2016 at 10:04 am

    For me its not showing any errors(returns an empty list) though I see one error in the firefox console. Please suggest.

  42. Parth said,

    February 14, 2020 at 3:59 am

    Is there any way that I can get all the messages in the console (may or maynot be only Javascript errors) ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: