[Kc] Testing Forms

Andrew Moore amoore at mooresystems.com
Wed Jan 12 09:57:34 PST 2011


On Wed, Jan 12, 2011 at 11:31 AM, djgoku <djgoku at gmail.com> wrote:
> When you used Selenium did you do form testing? I am not sure what all
> needs to be tested.
>
> I currently have this(Test::WWW::Mechanize):
> $mech->get_ok('http://localhost:3000/form');
> $mech->title_is('AppName', 'Make sure were on the AppName page');
> $mech->submit_form_ok({form_number => 1, fields => { name => 'test'
> }}, 'adding a name worked');
>
> But if I change submit_form_ok to (the test still passes even though I
> didn't pass in the name field):
> $mech->submit_form_ok({form_number => 1}, 'adding a name shouldn''t work');

It looks to me like that probably should pass. It's checking that you
were able to successfully submit the form. Now, you may want to check
that the page that you received is the form again (and not the
"success" page) and has some kind of error message on it, like "You
forgot to fill out the name field" or some such.

Does that make sense?

-Andy


More information about the kc mailing list