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

I am using Win32::IE::Mechanize module and want to click the sign off button,i used click_button(%opt)method but its not working. Please help me out.I am copying the source code of html page.
<HTML> <HTML> <HEAD> <TITLE>Cygent: Error</TITLE> <SCRIPT></SCRIPT> <SCRIPT LANGUAGE="JavaScript" SRC="ua/script/rollover.js"></SCRIPT> <SCRIPT SRC="common/script/js_common.js" language="javascript"></SCRIP +T> </HEAD> <BODY leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" BG +COLOR=#999999 LINK=#"0033CC" vlink="#0033CC" TEXT=#000000 onload="on +Load()"> <FORM NAME="mainForm" METHOD="POST" ACTION="/go" target="_top" onsubmi +t="return false;"> <INPUT TYPE=hidden NAME=from VALUE="UA_Error"> <INPUT TYPE=hidden NAME=to VALUE=""> <INPUT TYPE=hidden NAME=task VALUE=""> <!-- BEGIN Outer shell - sets minimum width for screen. Use 1004 for 1 +024 pixel screens and 780 for 800 pixel screens --> <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="100%" BGCOLOR="#FFF +FFF"> <!-- END title bars --> <TR> <TD ALIGN=LEFT VALIGN=TOP CLASS="FormBodyBGColor" COLSPAN="2"> <TABLE BORDER=0 CELLPADDING=10 CELLSPACING=0 WIDTH="100%"><TR><T +D ALIGN=LEFT VALIGN=TOP> <TABLE BORDER=0 CELLPADDING=10 CELLSPACING=0 WIDTH=620> <TR> <TD VALIGN=TOP> <FONT FACE="Arial" size="2">The following error has occurred:</f +ont> </TD> </TR> <TR> <TD VALIGN=TOP COLSPAN=2> <FONT FACE="Arial" size="2"> The system has encountered an error while processing your requ +est. <BR>Please click the &quot;sign off&quot; button provided below +, sign back into the system, and try your request again. </FONT> </TD> </TR> <TR> <TD COLSPAN=2> <FONT FACE="Arial" size="2"> Please click 'Go Back' button to return to the previous screen +, and continue from there. If you continue to encounter problems, ple +ase use the 'Sign Off' button to exit the application. </FONT> </TD> </TR> <TR> <TD> <A HREF="javascript:history.back()"> <IMG BORDER="0" SRC="ua/images/button_back.gif"></A></TD> <TD VALIGN=BOTTOM ALIGN=RIGHT><A HREF="javascript:subForm('UA_Sig +nin','signOff')"><IMG BORDER="0" SRC="ua/images/button-signoff.gif" a +lt=""></A></TD> </TR> </TABLE> </TD></TR></TABLE> </TD> </TR> </TABLE> <!-- END Outer shell --> </FORM> </BODY> </HTML>

20071219 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips

Replies are listed 'Best First'.
Re: How do I click Javascript button with Win32::IE::Mechanize
by marto (Cardinal) on Dec 19, 2007 at 11:43 UTC
    rshrivaQ,

    Please read the PerlMonks FAQ and How do I post a question effectively?. 'HiMonks,' is hardly an appropriate or descriptive title. You need to learn how to format your posts properly (you should have been asked to 'Preview' your post) so we can see all of the code or data you want us to look at.

    What error do you get? Perhaps showing us your Perl code would enable us to better advise you. Please note that you are not clicking a button here, this is an image with some JavaScript not a button, keep this in mind when reading the Win32::IE::Mechanize documentation for the $ie->click_button() method.

    Update:Thanks fenLisesi, s/Please not/Please note/

    Hope this helps

    Martin
      Thanks for clearing my doubts, but if you check the output of that html page you will see there are two buttons one is BACK and second one is SIGN OFF.So is there any other method or module by which i could click on that signoff button.
        You seem to be confusing the issue, you have an image ua/images/button-signoff.gif which may look like a 'button' but is not an HTML button. Now that Corion has edited your node so that people can actually see the HTML you are dealing with we can see that this has an anchor tag <A HREF="javascript:subForm('UA_Signin','signOff')">...</a>, so you want to look at using the $ie->follow_link() method to instruct IE to 'click' the link (again, this is not an HTML button) which should run the JavaScript.

        Update: Added the word method to the last sentence

        Hope this helps

        Martin