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

Low hours here. I'm trying to log into a site (success on this one) with WWW::Mechanize. But then I want to navigate to another page. The content contains the following bit of HTML.
<input type="submit" name="btnSearchCustomer" value="Search Customers" + id="btnSearchCustomer" class="Buttons" style="width:140px;">
I assume with this new content obtained, I can now do something like this
$m->click('btnSearchCustomer');
But nothing works. Just basically, what do you do after a successful login? How do you navigate? Thank you.

Replies are listed 'Best First'.
Re: login to remote site and navigate
by 1nickt (Canon) on Jul 19, 2019 at 22:15 UTC
Re: login to remote site and navigate
by LanX (Saint) on Jul 19, 2019 at 22:15 UTC
    Please check if the site needs JavaScript to be enabled in the browser.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Re: login to remote site and navigate
by afoken (Chancellor) on Jul 20, 2019 at 13:56 UTC

    <input type=submit> should be part of a <form>, so you need to submit that form (instead of "pressing" the submit buttton). WWW::Mechanize has two methods for that: submit() and submit_form(). See WWW::Mechanize. Also read WWW::Mechanize::Cookbook and WWW::Mechanize::FAQ.

    If the form contains no other input than the submit button (i.e. no other <input> or <button> or <textarea> elements), and the form's method is set to GET, you could also issue a simple GET request ($mech->get(...)) to the form's action URL.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re: login to remote site and navigate
by bliako (Abbot) on Jul 22, 2019 at 16:06 UTC

    Perhaps you want to try WWW::Mechanize::Chrome which supports javascript but you need to install Chrome browser.

    If you intend to do some very specific things after login and you know the forms beforehand, then afoken's suggestion is the best. To make it easier to decipher the forms use Firefox (I am sure other browsers have similar capabilities) Tools->WebDeveloper->ToggleTools, click on the Network tab and you will be able to see any request your browser makes, GET/POST etc, and their parameters as a result of you clicking on a form's submit. Then you can issue those requests yourself via the $mech->GET(...), mentioned.

Re: login to remote site and navigate
by fatkatie (Initiate) on Jul 22, 2019 at 15:01 UTC
    Thanks all. The information was very helpful. It turns out javascript is required after the login. There is a form that has an input element that defines the number_of_records you wish to view. The submit is a link with a javascript action that fires a call back. I'll have to figure out how to fill in the form input value and 'click' the link. update I'm going to pack this up. The mechanized ports to chrome and firefox support old versions. My old reliables, cpan install fails and activeware's ppm shows no module. I'm sure this can be done but it's over my head. I started looking at curl/php but I have no idea if I'll run into the same javascript problem. Thanks all. If in the future I get this going, I'll copy success here.