Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Test::WWW::Mechanize 1.40 adds scraping functions

by petdance (Parson)
on Apr 13, 2012 at 21:03 UTC ( [id://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.

xoxo,
Andy

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.

      xoxo,
      Andy

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlnews [id://964992]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-26 08:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found