Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Using Perl to Test a Web App that uses Javascript

by perrin (Chancellor)
on Jun 08, 2004 at 18:13 UTC ( #362475=note: print w/ replies, xml ) Need Help??


in reply to Using Perl to Test a Web App that uses Javascript

This has been covered many times before. You don't need to try and run the JavaScript any more than you need to try and render the HTML. The server only sees the HTTP interaction, so all you need to do is mimic what your browser actually sends to the server.

As it happens, you're in luck, because there is a recent article about how to capture this HTTP interaction with minimal effort:

http://www.perl.com/pub/a/2004/06/04/recorder.html


Comment on Re: Using Perl to Test a Web App that uses Javascript
Re^2: Using Perl to Test a Web App that uses Javascript
by McMahon (Chaplain) on Jun 08, 2004 at 18:24 UTC
    From the CPAN docs for HTTP::Recorder:

    "HTTP::Recorder won't record Javascript actions, or pages delivered via SSL."
      You're not listening to me. JavaScript is totally irrelevant. It runs on the client, then the client sends an HTTP request to the server. The only thing you have to do to test the server is mimic the end result of running the JavaScript, which will be captured perfectly be HTTP::Recorder.
        I would have thought that the testing would have to also validate that non-HTTP-interacting parts of the JavaScript also functioned. I'd want to know that things like for ( var ix = 0; ix < stuff.length; ix++ ) document.write( stuff[ ix ] ); had output the correct data, etc. There is more to testing this sort of thing than just what passes between the client and the server.
Re^2: Using Perl to Test a Web App that uses Javascript
by coolmichael (Deacon) on Jun 09, 2004 at 22:05 UTC
    I'm not sure about that. The javascript does more than form processing, it also manipulates the data and sets a couple inputs before submitting the form. I have tried HTTP::Recorder and WWW::Mechanize, but HTTP::Proxy had some problems and didn't work.

    --
    negativespace.net - all things inbetween.

      It doesn't matter what the JavaScript does. All that matters is what eventually gets sent back to the server after the JavaScript finishes. That can be captured and tested with Mechanize, since it's just an HTTP request like any other.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (12)
As of 2014-09-17 16:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (91 votes), past polls