Amar has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks, I am using WWW::Mechanize scripts to automate a web application and I am fairly new to Mechanize. I am struck at a place where my web application waits for response from the network. If the response doesnot arrive it displays page A and if response is obtained it displays page B. To automate the above, I am using redirect_ok. But redirect_ok aborts the application. My Web application is using POST, for redirections under POST i added the line
push( @{$browser->requests_redirectable}, 'POST' );
to my code.

A few lines of my code looks like this

$response = $browser->get($url); checkResponseFromURL(); $response = $browser->click("btnFindXYZ"); checkResponseFromURL(); $browser->field("txtAddress", "some Text",1); $browser->redirect_ok(); $response = $browser->click("btnFind"); checkResponseFromURL();
Monks,Please help me out.

Sincerly

Amar

Replies are listed 'Best First'.
Re: WWW Mechanize (redirect_ok) problem
by gargle (Chaplain) on Sep 21, 2005 at 09:43 UTC

    Hi,

    How is the redirection in your web application implemented?

    I haven't looked really into the details of www::mechanize but I suspect your redirect_ok() isn't really finding a correct redirect and gets confused

    Or maybe that 'POST' param is wrong?

    --
    if ( 1 ) { $postman->ring() for (1..2); }
      Hi, Thanx for reply. The redirection is implemented like: page A displays page B
      page B will be displayed STILL COM wrappers sends a signal like yes or no. If yes page C is displayed and on no page D is diplayed. Its a server side redirect based on yes/No from COM Wrappers. regards amar

        Hi,

        Based on what you just said it seems you don't use http redirect.

        So I think you don't need the redirect_ok() but should check instead the html you receive to determine in which page you are.

        --
        if ( 1 ) { $postman->ring() for (1..2); }