[Httpunit-commit] CVS: httpunit/test/com/meterware/httpunit/javascript FormScriptingTest.java,1.1,1.
Brought to you by:
russgold
From: Russell G. <rus...@us...> - 2002-08-19 18:52:30
|
Update of /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript In directory usw-pr-cvs1:/tmp/cvs-serv7684/test/com/meterware/httpunit/javascript Modified Files: FormScriptingTest.java Log Message: Added support for form.submit and Button.onClick Index: FormScriptingTest.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/test/com/meterware/httpunit/javascript/FormScriptingTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- FormScriptingTest.java 16 Aug 2002 18:52:51 -0000 1.1 +++ FormScriptingTest.java 19 Aug 2002 18:52:26 -0000 1.2 @@ -85,6 +85,42 @@ } + public void testSubmitViaScript() throws Exception { + defineResource( "DoIt?color=green", "You made it!" ); + defineResource( "OnCommand.html", "<html><head></head>" + + "<body>" + + "<form name=spectrum action='DoIt'>" + + " <input type=text name=color value=green>" + + " <input type=submit name=change value=color>" + + "</form>" + + "<a href='#' onClick='document.spectrum.submit(); return false;'>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + + response.getLinks()[ 0 ].click(); + assertEquals( "Result of submit", "You made it!", wc.getCurrentPage().getText() ); + } + + + public void testSubmitViaScriptButton() throws Exception { + defineResource( "DoIt?color=green", "You made it!" ); + defineResource( "OnCommand.html", "<html><head></head>" + + "<body>" + + "<form name=spectrum action='DoIt'>" + + " <input type=text name=color value=green>" + + " <input type=button id=submit value=submit onClick='this.form.submit();'>" + + "</form>" + + "<a href='#' onClick='document.spectrum.submit(); return false;'>" + + "</body></html>" ); + WebConversation wc = new WebConversation(); + WebResponse response = wc.getResponse( getHostPath() + "/OnCommand.html" ); + + response.getFormWithName( "spectrum" ).getButtons()[0].click(); + assertEquals( "Result of submit", "You made it!", wc.getCurrentPage().getText() ); + } + + public void testSetFormTextValue() throws Exception { defineResource( "OnCommand.html", "<html><head></head>" + "<body onLoad=\"document.realform.color.value='green'\">" + |