http://www.perlmonks.org?node_id=796511

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

Hi All,


I am trying to automate an interaction with the web page and i am using Win32::IE::Mechanize module as the page involves javascripting. I am able to login to the page and access all the information i need but the problem arises when i try to log off from the page. The button is not associated to any form tag.


Below is the HTML code of the page i am trying to access.
<form action="#" name="colorset"><input type="hidden" id="clr" + name="c" value=""></form> <fieldset class="buttonbartop"> <input class="titlebutton" type="button" name="searchcases" value="S +earch All Cases" onclick="javascript:searchcases();"> <input class="titlebutton" type="button" name="getnew" value="Get N +ew Case" onclick="javascript:searchcase();"> <input class="titlebutton" type="button" name="create" value="Creat +e Case" onclick="javascript:makecase();"> <input class="titlebutton" type="button" name="addressbook" value=" +Address Book" onclick="javascript:addressbook();"> <input class="newfeaturebtn" type="button" name="userhistory" value +="My History" onclick="javascript:showhistory();"> <input class="newfeaturebtn" type="button" name="usersettings" valu +e="Settings" onclick="javascript:showsettings();"> <input class="titlebutton" type="button" name="reportproblem" value +="Report a Problem" onclick="javascript:reportproblem();"> <input class="titlebutton" type="button" name="logoff" value="Log O +ff" onclick="javascript:snag('?logoff');"> </fieldset>



My Perl code is given below:
#!C:/perl/bin/perl.exe use Win32::IE::Mechanize; my $url = 'http://mallet'; my $ie = Win32::IE::Mechanize->new(visible => 1); $ie->get($url); sleep(2); #wait for 2 sec so that the requested page will be displayed +. $ie->click_button(value => 'Log Off');



Though the above code is not returning any error, it's not loggin off. I know i can try WWW::Selenium module but i have written most part of my code using Win32::IE::Mechanize module and i think there might be a way to accomplish this.


Any suggestions would be greatly appreciated!!!


Thanks