RE: [Httpunit-develop] problem with hidden field
Brought to you by:
russgold
From: <Eri...@al...> - 2002-08-28 15:47:06
|
I'm running into this same problem with hidden fields. There is a JUnit test to verify that hidden fields CANNOT be changed. Why does this testcase exist? Part of html spec? We set hidden fields on a regular basis as part of our framework, and ie doesn't complain. For those interested, here is the test case from test/com/meterware/httpunit/WebFormTest.java public void testHiddenParameters() throws Exception { defineWebPage( "Default", "<form method=3DPOST action =3D \"/servlet/Login\">" + "<Input name=3D\"secret\" type=3D\"hidden\" value=3D\"surprise\">" + "<br><Input name=3Dtypeless value=3Dnothing>" + "<B>Enter the name 'master': <Input type=3DTEXT Name=3Dname></B>" + "<br><Input type=3Dsubmit value =3D = \"Log in\">" + "</form>" ); WebResponse page =3D _wc.getResponse( getHostPath() + "/Default.html" ); WebForm form =3D page.getForms()[0]; assertEquals( 3, form.getParameterNames().length ); WebRequest request =3D form.getRequest(); assertEquals( "surprise", request.getParameter( "secret" ) ); assertEquals( "nothing", request.getParameter( "typeless" ) ); form.setParameter( "secret", "surprise" ); assertEquals( "surprise", request.getParameter( "secret" ) ); try { form.setParameter( "secret", "illegal" ); fail( "Should have rejected change to hidden parameter 'secret'" ); } catch (IllegalRequestParameterException e) { } assertEquals( "surprise", request.getParameter( "secret" ) ); } Howard Ungar wrote: > In order to test this page (since httpUnit doesn't=20 > support javascript)=20 There is some javascript support in the cvs version, now. However, there is *no* testcase to deal with onsubmit and hidden fields. There is one to deal with onsubmit and NON hidden fields. I altered it to use hidden fields, and it failed. Here is the test cases: com.meterware.httpunit.javascript#testFormValidationOnSubmit > -----Original Message----- > From: Howard Ungar [mailto:how...@ya...] > Sent: Monday, August 26, 2002 4:12 PM > To: Htt...@li... > Subject: [Httpunit-develop] problem with hidden field >=20 >=20 > I have a page which uses javascript to set the value of=20 > a hidden field. >=20 > In order to test this page (since httpUnit doesn't=20 > support javascript)=20 > I was going to call setParameter for my hidden field. =20 > But httpunit=20 > is throwing a MissingParameterValueException stating=20 > that the parameter > "must have the value ''". I assume this means that you are not > supposed to set parameters for hidden fields. =20 >=20 > How do I test with hidden fields which are being populated by > javascript? >=20 >=20 >=20 > __________________________________________________ > Do You Yahoo!? > Yahoo! Finance - Get real-time stock quotes > http://finance.yahoo.com >=20 >=20 > ------------------------------------------------------- > This sf.net email is sponsored by: OSDN - Tired of that same old > cell phone? Get a new here for FREE! > = https://www.inphonic.com/r.asp?r=3Dsourceforge1&refcode1=3Dvs3390 > _______________________________________________ > Httpunit-develop mailing list > Htt...@li... > https://lists.sourceforge.net/lists/listinfo/httpunit-develop >=20 |