Update of /cvsroot/jwebunit/jWebUnit/test/net/sourceforge/jwebunit
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15415/test/net/sourceforge/jwebunit
Modified Files:
AllTests.java
Added Files:
TextAndElementWalkerReverseTest.java
Log Message:
Added possibility to walk DOM tree in reverse order, to find elements like
checkboxes placed before the text label.
--- NEW FILE: TextAndElementWalkerReverseTest.java ---
package net.sourceforge.jwebunit;
import junit.framework.TestCase;
import org.w3c.dom.Element;
import org.w3c.dom.Document;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
public class TextAndElementWalkerReverseTest extends TestCase {
public void testFindLabel() throws ParserConfigurationException {
Element form = buildSimpleForm();
TextAndElementWalker walker = new TextAndElementWalkerReverse(form,
new String[] { "input", "select", "textarea" });
assertNotNull("Should find the field before the text", walker
.getElementAfterText("Check"));
assertNotNull("Should find the field before the complete text", walker
.getElementAfterText(" Check 1"));
}
// <form method="GET" action="TargetPage">
// <input type="checkbox" name="chk" value="2" /> Check 1
// </form>
private Element buildSimpleForm() throws ParserConfigurationException {
Document doc = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().newDocument();
Element form = doc.createElement("form");
form.setAttribute("method", "GET");
form.setAttribute("action", "TargetPage");
// checkbox
Element param1 = doc.createElement("input");
param1.setAttribute("type", "checkbox");
param1.setAttribute("name", "chk");
param1.setAttribute("value", "2");
form.appendChild(param1);
// name
form.appendChild(doc.createTextNode(" Check 1"));
return form;
}
}
Index: AllTests.java
===================================================================
RCS file:
/cvsroot/jwebunit/jWebUnit/test/net/sourceforge/jwebunit/AllTests.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** AllTests.java 14 May 2005 03:02:37 -0000 1.19
--- AllTests.java 22 Dec 2005 16:19:11 -0000 1.20
***************
*** 37,40 ****
--- 37,41 ----
suite.addTestSuite(TableAssertionsTest.class);
suite.addTestSuite(TextAndElementWalkerTest.class);
+ suite.addTestSuite(TextAndElementWalkerReverseTest.class);
//not moved over to using jetty / JWebUnitAPITestCase
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Jwebunit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development