Thomas Fuchs
Hi, I'm Thomas Fuchs. I'm the author of Zepto.js, of script.aculo.us, and I'm a Ruby on Rails core alumnus. With Amy Hoy I'm building cheerful software, like Noko Time Tracking and Every Time Zone and write books like Retinafy.me.
   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?