[Httpunit-commit] SF.net SVN: httpunit:[1012] trunk/httpunit/test/com/meterware/httpunit/ WebPageTe
Brought to you by:
russgold
|
From: <wol...@us...> - 2008-11-15 00:55:04
|
Revision: 1012
http://httpunit.svn.sourceforge.net/httpunit/?rev=1012&view=rev
Author: wolfgang_fahl
Date: 2008-11-15 00:55:03 +0000 (Sat, 15 Nov 2008)
Log Message:
-----------
Addition for BR [ 2100376 ] Unable to implement an XPath Predicate (which used to work)
by Stephane Mikaty
Modified Paths:
--------------
trunk/httpunit/test/com/meterware/httpunit/WebPageTest.java
Modified: trunk/httpunit/test/com/meterware/httpunit/WebPageTest.java
===================================================================
--- trunk/httpunit/test/com/meterware/httpunit/WebPageTest.java 2008-11-15 00:53:24 UTC (rev 1011)
+++ trunk/httpunit/test/com/meterware/httpunit/WebPageTest.java 2008-11-15 00:55:03 UTC (rev 1012)
@@ -503,7 +503,33 @@
final WebResponse targetResponse = wc.getOpenWindow(targetWindow).getCurrentPage();
assertEquals("Base URL of link in target document", targetBaseURL, targetResponse.getLinkWith("relative link").getBaseURL());
}
+
+ /**
+ * test case for BR [ 2100376 ] Unable to implement an XPath Predicate (which used to work)
+ * by Stephane Mikaty
+ * @throws Exception
+ */
+ public void testGetFirstMatchingForm() throws Exception {
+ defineResource( "SimplePage.html", "<html><title>Hello</title>"
+ + " <body><form action='blah' method='GET'><button type='Submit' value='Blah'>Blah</button></form>"
+ + " <form action='new' method='GET'>"
+ + " <p>Some Junk</p><button type='Submit' value='Save'>Save</button></form>"
+ + "</html>" );
+ defineResource( "new", "<html><body><p>Success.</p></body></html>" );
+ defineResource( "blah", "<html><body><p>Failure.</p></body></html>" );
+ WebConversation wc = new WebConversation();
+ WebResponse resp = wc.getResponse( getHostPath() + "/SimplePage.html" );
+
+ //find our desired Save form and submit it
+ WebForm form = resp.getFirstMatchingForm(new XPathPredicate( "//BUTTON[@value='Save']/ancestor::FORM" ),null );
+ assertNotNull("The form found should not be null",form);
+ resp = wc.sendRequest( form.getRequest() );
+
+ //check the response
+ assertTrue( resp.getText().indexOf( "Success" ) >= 0 );
+ }
+
/**
* Create a fragment of HTML defining JavaScript that writes a document into a different window.
* @param document the document to be written
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|