[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit/javascript HTMLElementTest.java,1.2,1.3
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2003-03-28 03:22:40
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv15073/test/com/meterware/httpunit/javascript
Modified Files:
HTMLElementTest.java
Log Message:
add support for getElementsByName
Index: HTMLElementTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/HTMLElementTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- HTMLElementTest.java 9 Jan 2003 18:02:24 -0000 1.2
+++ HTMLElementTest.java 28 Mar 2003 03:22:34 -0000 1.3
@@ -2,7 +2,7 @@
/********************************************************************************************************************
* $Id$
*
- * Copyright (c) 2002, Russell Gold
+ * Copyright (c) 2002-2003, Russell Gold
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
@@ -62,17 +62,46 @@
WebConversation wc = new WebConversation();
wc.getResponse( getHostPath() + "/start.html" );
- assertElementTitle( wc, "there", "second" );
- assertElementTitle( wc, "perform", "fifth" );
- assertElementTitle( wc, "doIt", "sixth" );
- assertElementTitle( wc, "grouping", "third" );
- assertElementTitle( wc, "aCell", "fourth" );
- assertElementTitle( wc, "myDiv", "first" );
+ assertElementTitle( wc, "id", "there", "second" );
+ assertElementTitle( wc, "id", "perform", "fifth" );
+ assertElementTitle( wc, "id", "doIt", "sixth" );
+ assertElementTitle( wc, "id", "grouping", "third" );
+ assertElementTitle( wc, "id", "aCell", "fourth" );
+ assertElementTitle( wc, "id", "myDiv", "first" );
}
- private void assertElementTitle( WebConversation wc, final String id, final String title ) {
- assertEquals( "element '" + id + "' message", "element with id " + id + " has title " + title, wc.popNextAlert() );
+ public void testNameProperty() throws Exception {
+ defineResource( "start.html",
+ "<html><head><script language='JavaScript'>" +
+ "function showTitle( name ) {" +
+ " var elements = document.getElementsByName( name );" +
+ " for( i = 0; i < elements.length; i++) {" +
+ " alert( 'element with name ' + name + ' has title ' + elements[i].title );" +
+ " }" +
+ "}" +
+ "function showAll() {" +
+ " showTitle( 'there' ); showTitle( 'perform' ); showTitle( 'doIt' );" +
+ " showTitle( 'input' );" +
+ "}</script>" +
+ "</head><body onLoad='showAll();'>" +
+ "<a href='somewhere' name='there' title=second>here</a>" +
+ "<form name='perform' title=fifth><input type='text' name='input' title='input1'>" +
+ "<input type='hidden' name='input' title='input2'><input type='submit' name='doIt' title=sixth></form>" +
+ "</td></tr></table></div></body></html>" );
+ WebConversation wc = new WebConversation();
+ wc.getResponse( getHostPath() + "/start.html" );
+
+ assertElementTitle( wc, "name", "there", "second" );
+ assertElementTitle( wc, "name", "perform", "fifth" );
+ assertElementTitle( wc, "name", "doIt", "sixth" );
+ assertElementTitle( wc, "name", "input", "input1" );
+ assertElementTitle( wc, "name", "input", "input2" );
+ }
+
+
+ private void assertElementTitle( WebConversation wc, String propertyName, final String id, final String title ) {
+ assertEquals( "element '" + id + "' message", "element with " + propertyName + ' ' + id + " has title " + title, wc.popNextAlert() );
}
|