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

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:

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

Replies are listed 'Best First'.
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.

    -- - 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.
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.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2016-10-26 11:38 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (340 votes). Check out past polls.