Michael G Schwern wrote:
I'm doing some application/acceptance level testing of web apps. Selenium is
one option but for things like "check that every item has X attribute set" I
really want a program.
If you're talking about form elements, then it's pretty easy to use Mech +
HTML::Form to test form elements. But if you're talking about arbitrary HTML
elements then that won't work.
A combination of Test::WWW::Mechanize + HTML::TreeBuilder::XPath seems just
what I need. Test::HTML::Content has the ability to see if an XPath query
matches but nothing more. Web::Scraper looks interesting but a bit too high
level.
I think I'd rather see this in Test::HTML::Content instead. It's already doing
XPath queries and is a smaller interface, so adding more to it wouldn't seem as
cluttered as putting it in Mech.
my $html = xpath_extract_ok($mech->content, //t...@id='thing']);
like($html, qr/stuff/);
I can see the benefit of having these as methods on the mech object itself since
you wouldn't have to keep calling $mech->content explicitly. So maybe a
WWW::Mechanize::XPath subclass?
--
Michael Peters
Plus Three, LP