[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit/javascript FormScriptingTest.java,1.19,1
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2003-03-14 17:41:45
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript
In directory sc8-pr-cvs1:/tmp/cvs-serv754/test/com/meterware/httpunit/javascript
Modified Files:
FormScriptingTest.java ScriptingTest.java
Log Message:
Return resultant page from WebClient.getResponse
Index: FormScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- FormScriptingTest.java 13 Mar 2003 18:20:50 -0000 1.19
+++ FormScriptingTest.java 14 Mar 2003 17:41:30 -0000 1.20
@@ -728,6 +728,21 @@
}
+ public void testSubmitOnLoad() throws Exception {
+ defineResource( "test2.txt?Submit=Submit", "You made it!", "text/plain" );
+ defineResource( "OnCommand.html", "<html><body onload='document.myform.btn.click();'>" +
+ "<form name='myform' action='test2.txt'>" +
+ " <input type='submit' id='btn' name='Submit' value='Submit'/>" +
+ "</form></body></html>" );
+ WebConversation wc = new WebConversation();
+ WebResponse wr = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ assertEquals( "current page URL", getHostPath() + "/test2.txt?Submit=Submit", wc.getCurrentPage().getURL().toExternalForm() );
+ assertEquals( "current page", "You made it!", wc.getCurrentPage().getText() );
+ assertEquals( "returned page URL", getHostPath() + "/test2.txt?Submit=Submit", wr.getURL().toExternalForm() );
+ assertEquals( "returned page", "You made it!", wr.getText() );
+ }
+
+
public void testSelectValueProperty() throws Exception {
defineResource( "OnCommand.html", "<html><head><script language='JavaScript'>" +
"function testProperty( form ) {\n" +
Index: ScriptingTest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/ScriptingTest.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- ScriptingTest.java 12 Mar 2003 15:39:46 -0000 1.50
+++ ScriptingTest.java 14 Mar 2003 17:41:30 -0000 1.51
@@ -68,9 +68,10 @@
"</body></html>" );
WebConversation wc = new WebConversation();
WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
- response.getLinks()[0].click();
+ WebResponse myPage = response.getLinks()[0].click();
assertEquals( "Alert message", "Hi there!", wc.popNextAlert() );
assertEquals( "Current page URL", getHostPath() + "/OnCommand.html", wc.getCurrentPage().getURL().toExternalForm() );
+ assertEquals( "Returned page URL", getHostPath() + "/OnCommand.html", myPage.getURL().toExternalForm() );
}
@@ -422,6 +423,21 @@
response.getScriptableObject().doEvent( "window.location.href='" + getHostPath() + "/Target.html'" );
assertEquals( "5th page URL", getHostPath() + "/Target.html", wc.getCurrentPage().getURL().toExternalForm() );
assertEquals( "5th page", "You made it!", wc.getCurrentPage().getText() );
+ }
+
+
+ public void testLocationPropertyOnLoad() throws Exception {
+ defineResource( "Target.html", "You made it!" );
+ defineResource( "OnCommand.html", "<html><head><title>Amazing!</title>" +
+ "</head>" +
+ "<body onLoad=\"document.location='" + getHostPath() + "/Target.html';\">" +
+ "</body>" );
+ WebConversation wc = new WebConversation();
+ WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" );
+ assertEquals( "current page URL", getHostPath() + "/Target.html", wc.getCurrentPage().getURL().toExternalForm() );
+ assertEquals( "current page", "You made it!", wc.getCurrentPage().getText() );
+ assertEquals( "returned page URL", getHostPath() + "/Target.html", response.getURL().toExternalForm() );
+ assertEquals( "returned page", "You made it!", response.getText() );
}
|