in reply to WWW::Mechanize and input type=image

When an image button is clicked, the coordinates of click are sent back as name.x and name.y values, where name is the NAME attribute of the input field. It would seem if you just need to automate form submission, any valid coordinates (e.g., 0,0) would work.

  • Comment on Re: WWW::Mechanize and input type=image

Replies are listed 'Best First'.
Re^2: WWW::Mechanize and input type=image
by dba (Monk) on Oct 16, 2004 at 15:11 UTC
    Thanks Steves. I have 2 follow-up questions.

    1. How do I find out the co-ordinates, as there are many other "image buttons" in the same page.

    Here is the expanded piece of HTML for clarity:
    <tr> <td bgcolor="white"><img height="1" width="1" src="px.gif"></t +d> <td bgcolor="white" colspan="2"><input type="password" name="h +tmPassword" size="10" class="rtnavinput"></td> <td bgcolor="white"><input type=image src="/images/btnGoRed.gi +f" width="15" height="15" border="0"></td> <td bgcolor="white"><img height="1" width="1" src="px.gif"></t +d> </tr>


    2. The syntax for "click" with coordinates is : $mech->click( $button [, $x, $y] ) What should I set $button to? There is no button name in the code.
      I created this HTML:
      <form action="test.cgi" method="GET"> <tr> <td bgcolor="white"><img height="1" width="1" src="px. +gif"></td> <td bgcolor="white" colspan="2"><input type="password" + name="htmPassword" size="10" class="rtnavinput"></td> <td bgcolor="white"><input type=image src="/images/btn +GoRed.gif" width="15" height="15" border="0"></td> <td bgcolor="white"><img height="1" width="1" src="px. +gif"></td> </tr> </form>

      to see what gets sent. It fetches:

      .../test.cgi?htmPassword=&x=8&y=10

      So maybe you need to do something like this:

      $mech->set_fields(x => 1, y => 1); $mech->submit();

      The script probably doesn't attention to the x and y, in which case you could do simply:

      $mech->submit();

      (Untested, and I'd never used WWW::Mechanize.)

        Thanks for your input. However, a simple submit or submit_form is not working.

        FYI, there are several forms in the same page.