Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- M.O.B. i L.
April 18, 2008, 4:33 pm
rate this thread
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:
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:
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:
# use Test::More qw(no_plan);
my $agent = WWW::Mechanize->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
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
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