Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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.

xoxo,
Andy

Comment on Test::WWW::Mechanize 1.40 adds scraping functions
Select or Download Code
Re: Test::WWW::Mechanize 1.40 adds scraping functions
by Anonymous Monk on Apr 13, 2012 at 22:36 UTC
      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

      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!"

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2014-07-31 07:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (245 votes), past polls