Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of markjugg (792)

Thursday June 29, 2006
02:58 PM

Using YAML to speed up creating WWW::Mechanize test scripts

[ #30100 ]
Test::WWW::Mechanize is a great web testing tool, but typing out the name/value pairs of a long form is no fun, at least when done in Perl hash syntax.

Today I experimented with using YAML to help with. YAML is more human friendly for data entry in that it doesn't usually need quoting, and the end-of-line-comma can be omitted.

Here's how I got two great tastes to test great together:

use YAML::Syck;
$mech->submit_form(
        fields => Load(q{
          first_name          : Mark
          last_name           : Stosberg
          street_address      : 211 NW I ST
          # ... lots more data...
}));

I further sped-up the process by using the 'mech-dump' give me the field names in the first place, which I copied in here. (This step only helps if you are sure you have the right fields on the form in the first place!).

With a little work, mech-dump could output YAML directly, making for a smooth round-trip workflow.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.