in reply to using and debuging www Mechanize

Hello and welcome!

If you want to see "where" you are with a WWW::Mechanize object, you can use HTML::Display to display the current page in a browser, or, and this is most likely easier in your situation, just use

$mech->dump_forms();

to get a feel for the names of the fields on the forms. You will also in the long run need to learn some HTML. The name for the "username" field is ctl00$ctl00$cphserver$cphLogin$txtUser, and you'll find the name for the "password" field quier easily from that.

Replies are listed 'Best First'.
Re^2: using and debuging www Mechanize
by yantar (Initiate) on Jun 08, 2009 at 12:51 UTC
    Thanx! So if my code looks like this
    $mech->submit_form( form_number => 1, fields => { 'ctl00$ctl00$cphVeriCentre$cphLogin$txtUser' => 'someone', 'ctl00$ctl00$cphVeriCentre$cphLogin$txtPW' => 'pass', 'ctl00$ctl00$cphVeriCentre$cphLogin$ddlServers' => +'Live', }, ); die unless ($mech->success); $mech->dump_forms();
    I should see the new page i got directed to after submitting the form?
    Because i don't.
    I also noticed there are two type="submit" parts in the source code, the second one is in another panel, can that cause a problem?

    Thank you

      HTML does not have "panel"s, so it's kinda hard to tell what you mean by this. If you're not ending up at the page you expect to, you'll need to debug that issue, possibly by looking at whether the HTML contains some error message or something.

      Mechanize will use the "submit" button associated with your form. Maybe take another look at what ->dump_forms() outputs.

        When i use ->dump_forms() after i ran the Submit_form i get:
        ctl00$ctl00$cphServer$cphLogin$txtUser=someone (text) ctl00$ctl00$cphServer$cphLogin$txtPW= (password) ctl00$ctl00$cphServer$cphLogin$ddlServers=Live (option) [*Live|Tes +t] ctl00$ctl00$cphServer$cphLogin$btnSignIn=Sign-In (submit) ctl00$ctl00$cphServer$cphLogin$btnConfigure=Configure (submit)
        And i see there are two Submit lines, how i can make sure submit_form is using the correct one?