images/littlesamie.jpg (853 bytes)

sub ClickFormButtonByIndex { #$ButtonIndex, $popup, $CheckForMessageBox, $formname
Description: Clicks on a  Form Submit Button by it's index position on the page.

How To:

Find the submit index position in your html with View Source:
The first index position starts at 0.


<form action="action2.php" method="POST">
Name <input type="text" name="name1" />
Age <input type="text" name="age1" /><p>
<input type="submit" name="infotest" value="Button One"><p>
Name <input type="text" name="name2"/>
Age <input type="text" name="age2" /><p>
<input type="submit" name="infotest" value="Button Two"><p>
Name <input type="text" name="name3"/>
Age <input type="text" name="age3" /><p>
<input type="submit" name="infotest" value="Button Three"><p>
Name <input type="text" name="name4" />
Age <input type="text" name="age4" /><p>
<input type="submit" name="infotest" value="Button Four"><p>
Name <input type="text" name="name5" />
Age <input type="text" name="age5" /><p>
<input type="submit" name="infotest" value="Button Five"><p>
Name <input type="text" name="name6" />
Age <input type="text" name="age6" /><p>
<input type="submit" name="infotest" value="Button Six"><p>
If you want to click on the first submit button.


Cookbook Recipe:

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

$| = 1;
my $URL = "";
my $IEDocument;
my $seconds;

$Win32::OLE::Warn = 3;

$seconds = Navigate($URL);
print "simpleform.html page took $seconds seconds to load\n";
SetEditBox("name5","Ben Grimm");
SetEditBox("name6","Reed Richards");
$seconds = ClickFormButtonByIndex(0);
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)