Re: [Httpunit-develop] cannot read "action" in multi-submit form; but works for multi-button form
Brought to you by:
russgold
From: Russell G. <rus...@ac...> - 2001-08-29 16:00:43
|
At 02:40 PM 8/29/2001 +0200, Alain RAVET wrote: >I'm trying to read the action value of a form that contains more than 1 >submit button. I doesn't work. It would if I could replace >all the "submit" by "button", but I cannot. > >How to reproduce the problem : > > java cod : > ----------- > > public static void main(String args[]) throws Exception { > WebConversation wc = new WebConversation(); > WebResponse resp = wc.getResponse( > "http://localhost:8080/jjjynet/spike.html" ); > String action = resp.getForms()[0].getRequest().getURL().getFile(); > System.out.println("action = " + action); > > } > > HTML page : > ----------- > > <HTML> > <HEAD><TITLE>spikeTest</TITLE> </HEAD> > <body> > <form action="anACtion" method="post"> > <input type=submit name=aName value=aValue> > <input type=submit name=aName2 value=aValue2> > </form> > </body> > </HTML> > > > > Result : > ----------- > This code produces : > >com.meterware.httpunit.IllegalUnnamedSubmitButtonException: This form has >no unnamed buttons > at com.meterware.httpunit.WebForm.getRequest(WebForm.java:233) > at com.meterware.httpunit.WebForm.getRequest(WebForm.java:178) > at spikes.FormAction.main(FormAction.java:11) This is correct. The call to Form.getRequest is ambiguous. You need to say: > String action = resp.getForms()[0].getRequest( "aName" > ).getURL().getFile(); to specify that the request should involve pressing the first button. It appears that the error message is not helpful. Perhaps it should say: "Form has multiple buttons (none unnamed), and you did not specify which one to use." > BUT : > ----------- > > It works fine if you replace "submit" by "button" : > > <form action="anAction" method="post"> > <input type=button name=aName value=aValue> > <input type=button name=aName2 value=aValue2> > </form> It "works" because <input type=button> is not a submit button. |