Re: Getting a specific page using WWW::Mechanize [SOLVED]

2017-04-25 Thread SSC_perl
I found my error.  I ended up using $mech->save_content(‘result.html’) 
at the end of my script and, lo and behold, it produced the confirm.htm page 
with an error.  I had forgotten to add the cardholder’s name field to the final 
form submission, so of course, SurfShop was returning the same page and asking 
for it to be filled in.  Talk about embarrassing. :\  Oh, well, everything is 
working fine now and I have a super little script to place test orders 
automatically.  It’s turned out to be a great tool for solving problems.  
Before this, I was manually placing test orders, filling in every field by 
hand, which gets old real fast when you have to do it repeatedly.

If anyone is looking to automate tasks like this for testing or 
whatever else, I whole heartedly recommend WWW::Mechanize.  It’s a real time 
saver.

Thanks again to Chas for the reply.

Frank
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Getting a specific page using WWW::Mechanize

2017-04-25 Thread SSC_perl
> On Apr 25, 2017, at 10:09 AM, Chas. Owens  wrote:
> 
> Are you using JavaScript to redirect the user to the sorry page?

Nope.  All navigation is handled by perl.  Thanks for the link, though.

Frank

Re: Getting a specific page using WWW::Mechanize

2017-04-25 Thread Chas. Owens
Are you using JavaScript to redirect the user to the sorry page?  If so
then WWW::Mechanise won't redirect.  It doesn't understand JavaScript.
Happily, there are drop in replacements for it that do:

http://search.cpan.org/~oalders/WWW-Mechanize-1.84/lib/WWW/Mechanize/FAQ.pod#Which_modules_work_like_Mechanize_and_have_JavaScript_support
?

On Tue, Apr 25, 2017 at 12:06 PM SSC_perl  wrote:

> Here’s more information on this situation.  SurfShop uses two main
> HTML templates, main.htm and secure.htm.  Then there are sub-templates that
> get loaded as the content of those two main templates.
>
> During checkout, secure.htm is used.  If the order is successful,
> receipt.htm is used as the sub-template, if not, then sorry.htm is shown
> with the error message.  This, of course, works as expected when placing an
> order by hand.
>
> When placing a successful order with WWW::Mechanize, receipt.htm
> is shown correctly in $mech->content().  However, if the order was
> declined, that’s when Mech returns the same page it was on when the
> ‘processTransaction’ button was clicked, which is confirm.htm.
>
> Up until this point, Mech performs just like when I manually place
> an order, so what could be causing it to get mixed up at the end?  I don’t
> think I'm doing anything special, but you never know.  Here’s a snippet of
> the code where the process fails:
>
>
> $mech->submit_form(
> form_name => 'ccForm',
> fields=> {
>   Ecom_Payment_Card_Type  => 'VISA',
>   Ecom_Payment_Card_Number=> ‘',
>   Ecom_Payment_Card_Verification  => '123',
>   Ecom_Payment_Card_ExpDate_Month => '05',
>   Ecom_Payment_Card_ExpDate_Year  => '2024',
>  },
> button=> 'processTransaction',
> );
>
> As you can see, it’s pretty standard stuff.
>
> Is there another method I can use besides $mech->content() to see
> what’s being returned?  The more tests I can do on this, the more it will
> help me find where I went wrong.
>
> Frank
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


Re: Getting a specific page using WWW::Mechanize

2017-04-25 Thread SSC_perl
Here’s more information on this situation.  SurfShop uses two main HTML 
templates, main.htm and secure.htm.  Then there are sub-templates that get 
loaded as the content of those two main templates.

During checkout, secure.htm is used.  If the order is successful, 
receipt.htm is used as the sub-template, if not, then sorry.htm is shown with 
the error message.  This, of course, works as expected when placing an order by 
hand.

When placing a successful order with WWW::Mechanize, receipt.htm is 
shown correctly in $mech->content().  However, if the order was declined, 
that’s when Mech returns the same page it was on when the ‘processTransaction’ 
button was clicked, which is confirm.htm.

Up until this point, Mech performs just like when I manually place an 
order, so what could be causing it to get mixed up at the end?  I don’t think 
I'm doing anything special, but you never know.  Here’s a snippet of the code 
where the process fails:


$mech->submit_form(
form_name => 'ccForm',
fields=> {
  Ecom_Payment_Card_Type  => 'VISA',
  Ecom_Payment_Card_Number=> ‘',
  Ecom_Payment_Card_Verification  => '123',
  Ecom_Payment_Card_ExpDate_Month => '05',
  Ecom_Payment_Card_ExpDate_Year  => '2024',
 },
button=> 'processTransaction',
);

As you can see, it’s pretty standard stuff.

Is there another method I can use besides $mech->content() to see 
what’s being returned?  The more tests I can do on this, the more it will help 
me find where I went wrong.

Frank
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Getting a specific page using WWW::Mechanize

2017-04-25 Thread SSC_perl
I’ve written a script using WWW::Mechanize to place test orders in 
SurfShop.  I wish I had know it could do this before. :\  For some reason, I 
was under the impression that it was only good for scraping.  

The script works great, but I need to find a way to get the contents of 
the receipt page in the cart to test if a credit card order was accepted or 
denied.  Using $mech->content at the end of the script gives me the penultimate 
page - not the last one.

How can I get the contents of the final page of the checkout process?

Thanks,
Frank
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/