Thomas Fuchs
Hi, I'm Thomas Fuchs. I'm the author of the script.aculo.us user interface JavaScript library, a member of the Prototype core team and a Ruby on Rails core alumnus.
You're using my JavaScript work every day, even if you're not aware of it!
@thomasfuchs on Twitter    Need consulting, corporate training or want me to speak at your conference? Contact me!

Automatic testing of your web pages with JavaScript

July 28th, 2005

Yes, this is possible.

A proof of concept (currently Firefox only) is included with the test file for the new AJAX in-place editor
(coming in the next script.aculo.us version).

Excerpt from the test case:

new Test.Unit.Runner({

  test_InPlaceEditor: function() { with(this) {
    inPlaceEditor = new Ajax.InPlaceEditor($('tobeedited'),
      'inplaceeditor_result.html');

    Event.simulateEvent('tobeedited','mouseover');
    assertEqual("rgb(238, 238, 238)",
      Element.getStyle('tobeedited','background-color'));

    Event.simulateEvent('tobeedited','mouseout');
    assertEqual("transparent",
      Element.getStyle('tobeedited','background-color'));

    Event.simulateEvent('tobeedited','mouseover');
    Event.simulateEvent('tobeedited','click');
    assertHidden($('tobeedited'));

    (...)

Kudos to Jon Tirsen to coming up with most of this!

What’s needed now is way to automatically record events and make a test case skeleton out of it. That would allow for complete automatic browser based tests. How cool is that?