1 6 package net.sourceforge.jwebunit; 7 8 import junit.framework.TestCase; 9 import org.w3c.dom.Element ; 10 import org.w3c.dom.Document ; 11 12 import javax.xml.parsers.DocumentBuilderFactory ; 13 import javax.xml.parsers.ParserConfigurationException ; 14 15 public class TextAndElementWalkerTest extends TestCase { 16 17 public void testFindLabel() throws ParserConfigurationException { 18 Element form = buildForm(); 19 TextAndElementWalker walker = 20 new TextAndElementWalker(form, 21 new String [] { "input", "select", "textarea" }); 22 assertNotNull(walker.getElementAfterText("First")); 23 } 24 25 26 private Element buildForm() throws ParserConfigurationException { 31 Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); 32 Element form = doc.createElement("form"); 33 form.setAttribute("method", "GET"); 34 form.setAttribute("action", "TargetPage"); 35 form.appendChild(doc.createTextNode("First : ")); 36 Element param1 = doc.createElement("input"); 37 param1.setAttribute("type", "text"); 38 param1.setAttribute("name", "param1"); 39 form.appendChild(param1); 40 form.appendChild(doc.createTextNode("Second : ")); 41 Element param2 = doc.createElement("input"); 42 param2.setAttribute("type", "text"); 43 param2.setAttribute("name", "param2"); 44 form.appendChild(param2); 45 return form; 46 } 47 48 } 49 | Popular Tags |