Thursday, August 31, 2006

Scripted Web Apps: Watij

Web App Testing with Watij

Kostyantyn found this really nifty java library that allows you to script IE from Java. You can, for example write programs like:

import junit.framework.TestCase;
import static watij.finders.SymbolFactory.*;
 
public class GoogleTest extends TestCase {
    public void testGoogleSearch() throws Exception {
        IE ie = new IE();
        ie.start("http://www.google.com");
        ie.textField(name,"q").set("XWiki");
        ie.button("Google Search").click();
        assertTrue(ie.containsText("/Java wiki engine/"));
    }
}

Best of all, you can drive it through Beanshell, so you can easily work up ad hoc scripts, such as:

Nice find Kostyantyn!

No comments:

Post a Comment