如何运行watij

sole 2008-05-29

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/)
  • 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("XWiki");
        ie.button("Google Search").click();
        assertTrue(ie.containsText("/Java wiki engine/"));
    }
}

 

Using BeanShell

 

Global site tag (gtag.js) - Google Analytics