Note: Watij requires jdk 1.5 so if you don’t have it installed please do so here

Download Watij

  • Click here to get the current release of Watij
  • Unzip the watij_X_x.x.zip

Note: You can also [Get the Latest Source] and build it yourself

Setting up

  • Place the jniwrap.dll into your system32 folder (Typically C:/WINDOWS/system32/ or anywhere on your PATH)
  • Open your favorite IDE and create a project…our favorite is IntelliJ
  • Include watij.jar and all the jars in the lib folder in your classpath
  • Create a Junit TestCase and make sure you include “import static watij.finders.SymbolFactory.*;”
  • Try out the simple example test below!

Note: The best examples are in the Unit Tests – just look in the folder /watij_X_x.x/src/java-test/watij

Example Google Search Test

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("Watij");
        ie.button("Google Search").click();
        assertTrue(ie.containsText("/Web Application Testing in Java/"));
    }
}

Note: Don’t forget to check out the Javadoc API for Watij

Using BeanShell

Try following the example below!

Just download Watij, unzip, and double-click on the launchWatijBeanShell.bat and you are ready to start scripting in the BeanShell Desktop console.