WWW::Mechanize::Plugin::Display released

markjugg on 2007-05-11T15:11:27

WWW::Mechanize is great, but it can be tedious to debug why a Mech script fails, because you can't easily "see" what was on the page at the time of failure.

At least, until now. I made a small plugin, which connects Mech with the great HTML::Display package, which is makes it easy to display a Mech HTML page in a local browser.

I usually use Mech over an 'ssh' connection, so what's "local" to Mechanize is usually not my desktop where there's a graphical browser running. So in the example, I show how to use the great console browser, w3m, for display. It (sort of) renders tables, which is usually enough to at least give me an idea of what went wrong. Here's how I might use it with Test::WWW::Mechanize:

  $mech->get_ok($url) || $mech->display();

If this test fails, I'll see the result in the browser. I don't always leave the calls to "display()" in the code when I'm done, since this wouldn't make sense in the content of a smokebot.

See WWW::Mechanize::Plugin::Display on CPAN.


$ENV ?

mpeters on 2007-05-14T13:39:24

This would be great and easy to use if you could turn it on/off from the command line when running your tests. I'd suggest an environment variable.