Click here to get back home

HTTP::Recorder and WWW::Mechanize for testing web sites

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
HTTP::Recorder and WWW::Mechanize for testing web sites M.O.B. i L. 04-18-2008
Get Chitika Premium
Posted by M.O.B. i L. on April 18, 2008, 12:33 pm
Please log in for more thread options
Hi,
WWW::Mechanize is a Perl module that simulates a web browser.
You can use HTTP::Recorder to write WWW::Mechanize code automatically as
you surf, see the article:
http://www.perl.com/pub/a/2004/06/04/recorder.html

Then you can improve this code with variables and loops and use it for
testing of web sites.

I saved the proxy server program in the article and started it:
./proxy.pl &

I reconfigured Firefox to use the proxy server in
Preferences/Advanced/Network/Connection Settings. It's on port 8080 on
localhost, and use this for all protocols. Remember to remove localhost
and 127.0.0.1 from 'No Proxy for' if you test against a local web server.

Then I test my web application using a newly reseted test database.

After that I stop the proxy:
kill -15 %1

And reset the database.

I then edit the file with output from the proxy script and add at top:
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
# use Test::More qw(no_plan);
my $agent = WWW::Mechanize->new();
$agent->cookie_jar(HTTP::Cookies->new);

I run this program. This should run without errors.

I can also check my web application and see that it is in the state it
should be.

Now I have a test script that I can use after major changes to the web
application to test that everything is still working.

Hidden form fields are considered read-only by HTTP::Recorder and
WWW::Mechanize. I sometimes change them from JavaScript. I solved this
by making them type="text" and setting the style="display:none".

There is a bug in 0.05 of HTTP::Recorder that bothered me but it can be
fixed, see:
http://cpanratings.perl.org/dist/HTTP-Recorder


Regards,
// Mikael

Similar ThreadsPosted
using http::recorder September 27, 2006, 11:29 am
Problem With WWW::Mechanize With July 14, 2005, 1:05 pm
Total Recorder -> iTunes/iPod on Windows December 21, 2004, 8:21 am
perl sites down? September 12, 2005, 3:40 pm
Here are the BEST Porn Sites I've come across ; ) July 21, 2007, 12:12 am
google search in multiple sites May 12, 2005, 1:17 pm
Newbie question about NTLM and web sites August 12, 2004, 9:16 am
HTTP Proxy via HTTP Layer by Perl? October 19, 2004, 5:56 pm
Perl on TRIPOD hosted sites..file uploading question.. April 5, 2005, 2:09 pm
use WWW::Mechanize; May 11, 2006, 6:28 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap