images/littlesamie.jpg (853 bytes)

sub ClickFormButton { #$ButtonName, [$popup, $CheckForMessageBox, $formname, $nowait]
Description: Clicks on a  Form Submit Button

How To:

Find the submit name in your html with View Source:

Example:

<form METHOD=POST ACTION="http://www.2kweb.net/cgi-bin/formmail.cgi">
     <input TYPE="text" NAME="persons-name" SIZE="40" MAXLENGTH="40">
     <input TYPE="hidden" NAME="recipient" SIZE="40" MAXLENGTH="40">
     <input TYPE="password" NAME="password" SIZE="10" MAXLENGTH="10">
     <input TYPE="submit" NAME="Request" VALUE="Submit This Form">
     <input TYPE="reset" NAME="Clear" VALUE="Clear Form and Start Over">
</form>

If you want to click on the Request submit button.

ClickFormButton("Request");

Cookbook Recipe:

use Win32::OLE;
use Win32::SAM;
#use Win32::Slingshot:

$| = 1;
my $URL = "http://samie.sf.net/simpleform.html";
my $IEDocument;
my $seconds;

$Win32::OLE::Warn = 3;

StartIE();
$seconds = Navigate($URL);
print "simpleform.html page took $seconds seconds to load\n";
SetEditBox("name","samie");
SetEditBox("age","about 2 years old now");
$seconds = ClickFormButton("infotest");
print "Answer Page took $seconds seconds to load\n";
Further Notes:
The second parameter $popup is optional. It tells samie that the FormButton is going to raise a popup window.
The third parameter $CheckForMessageBox is optional. It tells samie that a message box will appear when this button is clicked. With this paramter set to 1 samie will resume the process to react to the message box.
This process must first be started with a call to VerifyMessageBox. The fourth parameter $formname is optional. It is used when there is more than one form on a page The fifth parameter $nowwait is optional. It is used when you don't want samie to call WaitForDocumentComplete or WaitForDocumentCompleteForPopup after you click the button.

images/littlesamie.jpg (853 bytes)