|Perl: the Markov chain saw|
HTTP::Form and invalid radio button valuesby cees (Curate)
|on Dec 19, 2003 at 05:06 UTC||Need Help??|
cees has asked for the
wisdom of the Perl Monks concerning the following question:
I am trying to write some UI tests for a web app using WWW::Mechanize. I have however run into a snag while writing tests to handle some edge cases. I am trying to make sure my backend code can handle an enduser messing with radio button values (ie saving the form, changing the radio button values and re-submitting).
While writing these tests I found out that I can not submit a form using WWW::Mechanize with an invalid entry entered into a radio button field. WWW::Mechanize uses the HTML::Form module to handle form parsing/filling/submitting, and that module happens to be very strict about the values you can assign to a field that is a radio button (or a select box for that matter)...
Has anyone run into this before? Is there a clean solution? Did I miss something obvious?
A quick example of what I am trying follows:
The above code will fail and die at the call to $a->field(...). I have tried making calls directly to the HTML::Form object to no avail, but it looks like according to the perldocs for HTML::Form that it is working exactly as advertized. Is there another way to do what I want?
Update:I was silly for not including the error message I got. HTML::Form is doing exactly what is advertized in the docs. It will die with an error message when an bad value is assigned to a radio button or select box. I am looking for another way of doing the same thing (ie using something besides HTML::Form to build a request object, or convincing HTML::Form to accept a bad value...)
The error message HTML::Form spits out is as follows: Illegal value 'invalid_value' for field 'a_radio_button' at /usr/local/share/perl/5.8.2/HTML/Form.pm line 426