1 package net.sourceforge.jwebunit.sample; 2 3 import junit.framework.TestCase; 4 import com.meterware.httpunit.WebResponse; 5 import com.meterware.httpunit.WebConversation; 6 import com.meterware.httpunit.WebForm; 7 import com.meterware.httpunit.WebRequest; 8 9 14 public class SearchExample extends TestCase { 15 16 public void testSearch() throws Exception { 17 WebConversation wc = new WebConversation(); 18 WebResponse resp = wc.getResponse( "http://www.google.com"); 19 WebForm form = resp.getForms()[0]; 20 form.setParameter("q", "HttpUnit"); 21 WebRequest req = form.getRequest("btnG"); 22 resp = wc.getResponse(req); 23 assertNotNull(resp.getLinkWith("HttpUnit")); 24 resp = resp.getLinkWith("HttpUnit").click(); 25 assertEquals(resp.getTitle(), "HttpUnit"); 26 assertNotNull(resp.getLinkWith("User's Manual")); 27 } 28 } | Popular Tags |