Log Message:
-----------
New method HtmlPage.getAllForms() as per feature request 742515
Modified Files:
--------------
/cvsroot/htmlunit/htmlunit/src/xdocs:
changes.xml
/cvsroot/htmlunit/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html:
HtmlPageTest.java
/cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html:
HtmlPage.java
Revision Data
-------------
Index: changes.xml
===================================================================
RCS file: /cvsroot/htmlunit/htmlunit/src/xdocs/changes.xml,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- changes.xml 18 Jul 2003 13:04:10 -0000 1.116
+++ changes.xml 19 Jul 2003 18:19:36 -0000 1.117
@@ -142,6 +142,9 @@
<action type="update" dev="mbowler">
Upgraded the xerces to 2.4
</action>
+ <action type="new" dev="mbowler" id="742515">
+ New method HtmlPage.getAllForms()
+ </action>
</release>
</body>
Index: HtmlPageTest.java
===================================================================
RCS file: /cvsroot/htmlunit/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlPageTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- HtmlPageTest.java 10 Jun 2003 11:57:01 -0000 1.5
+++ HtmlPageTest.java 19 Jul 2003 18:19:36 -0000 1.6
@@ -927,5 +927,39 @@
assertEquals("Shift_JIS", page.getPageEncoding());
}
+
+
+ public void testGetAllForms() throws Exception {
+
+ final String content
+ = "<html>"
+ + "<head><title>foo</title></head>"
+ + "<body>"
+ + "<form name='one'>"
+ + "<a id='c' accesskey='c'>foo</a>"
+ + "</form>"
+ + "<form name='two'>"
+ + "<a id='c' accesskey='c'>foo</a>"
+ + "</form>"
+ + "<input name='foo' type='submit' disabled='disabled' id='foo' accesskey='f'/>"
+ + "<input name='bar' type='submit' id='bar'/>"
+ + "</form></body></html>";
+
+ final WebClient client = new WebClient();
+
+ final FakeWebConnection webConnection = new FakeWebConnection( client );
+ webConnection.setContent( content );
+ client.setWebConnection( webConnection );
+
+ final HtmlPage page = ( HtmlPage )client.getPage(
+ new URL( "http://www.gargoylesoftware.com" ),
+ SubmitMethod.POST, Collections.EMPTY_LIST );
+
+ final List expectedForms = Arrays.asList( new HtmlForm[]{
+ page.getFormByName("one"),
+ page.getFormByName("two")
+ } );
+ assertEquals( expectedForms, page.getAllForms() );
+ }
}
Index: HtmlPage.java
===================================================================
RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- HtmlPage.java 16 Jun 2003 21:03:24 -0000 1.47
+++ HtmlPage.java 19 Jul 2003 18:19:36 -0000 1.48
@@ -484,7 +484,14 @@
}
}
-
+ /**
+ * Return a list of all the forms in the page.
+ * @return All the forms.
+ */
+ public List getAllForms() {
+ return getHtmlElementsByTagNames( Arrays.asList(new String[]{"form"}) );
+ }
+
/**
* Return the WebClient that originally loaded this page
*
|