Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Test::WWW::Mechanize 1.40 adds scraping functions

by petdance (Parson)
on Apr 13, 2012 at 21:03 UTC ( #964992=perlnews: print w/replies, xml ) Need Help??

The new 1.40 release of Test::WWW::Mechanize adds functions to help scrape text from your HTML as you test it. This should make things much easier for your integration test of your web apps.

For example, if you want to make sure that this shows up:

<h1>My awesome page!</h1>

then you can add an id attribute to the <h1>

<h1 id="pagetitle">My awesome page!</h1>

and your test can check for it:

$mech->scraped_id_is( 'pagetitle', 'My Awesome Page!' );

Two other functions are added to help in your text extraction: ->scrape_text_by_id() and ->scrape_text_by_attr().

Will these functions help your testing? Do you have other methods that you use to aid testing? As always, I welcome your feedback.


Replies are listed 'Best First'.
Re: Test::WWW::Mechanize 1.40 adds scraping functions
by Anonymous Monk on Apr 13, 2012 at 22:36 UTC
      Why are about 1 in 4 test results failures...

      Those tend to be due to ISPs which break DNS.

      "We know you made a typo and tried to look up a name which doesn't exist for a TLD which doesn't exist, but we're redirecting you to this webpage so you can look at some ads!"

      Are you having a problem with your install, or are you just asking for the hell of it?

      If the former, mail me or make a ticket in Github.

      If the latter, I don't know or care.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlnews [id://964992]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2018-05-25 00:33 GMT
Find Nodes?
    Voting Booth?