[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit/javascript DocumentScriptingTest.java,1.
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2003-04-02 15:31:20
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv5947/test/com/meterware/httpunit/javascript
Modified Files:
DocumentScriptingTest.java
Log Message:
Added getElementsByTagName support
Index: DocumentScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/DocumentScriptingTest.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DocumentScriptingTest.java 19 Mar 2003 17:41:05 -0000 1.9
+++ DocumentScriptingTest.java 2 Apr 2003 15:31:12 -0000 1.10
@@ -40,6 +40,7 @@
super( name );
}
+
public void testDocumentTitle() throws Exception {
defineResource( "OnCommand.html", "<html><head><title>Amazing!</title></head>" +
"<body onLoad='alert(\"Window title is \" + document.title)'></body>" );
@@ -299,5 +300,36 @@
assertEquals("JavaScript no of forms", "No of forms: 1", wc.popNextAlert());
}
+
+ public void testTagProperty() throws Exception {
+ defineResource( "start.html",
+ "<html><head><script language='JavaScript'>" +
+ "function showFormsCount(oDOM){ " +
+ " var forms = oDOM.getElementsByTagName('form');" +
+ " for( i = 0; i < forms.length; i++) {" +
+ " alert( 'form with number ' + i + ' has ' + forms[i].getElementsByTagName('input').length + ' inputs' );" +
+ " }" +
+ "}" +
+ "function showAll() {" +
+ " showFormsCount(document);" +
+ "}" +
+ "</script></head><body onLoad='showAll();'>" +
+ "<a href='somewhere' name='there' title=second>here</a>" +
+ "<form name='perform1' title=fifth><input type='text' name='input' title='input1'></form>" +
+ "<form name='perform2' title=fifth><input type='text' name='input' title='input1'>" +
+ "<input type='hidden' name='input' title='input2'><input type='submit' name='doIt' title=sixth></form>" +
+ "</body></html>"
+ );
+ WebConversation wc = new WebConversation();
+ wc.getResponse( getHostPath() + "/start.html" );
+
+ assertElementTags( wc, "0", "1");
+ assertElementTags( wc, "1", "3");
+ }
+
+
+ private void assertElementTags( WebConversation wc, String number, final String counts) {
+ assertEquals( "form '" + number + "' message", "form with number " + number + " has " + counts +" inputs", wc.popNextAlert() );
+ }
}
|