images/littlesamie.jpg (853 bytes)

sub ClickFormButtonByLabel { #ButtonLabel, optional: $popup, $WindowTitle, $SkipFiringOnClickEvent
Description: Clicks on a  Form Button by it's Label on the page.

How To:

Find the button in your html with View Source:

Example:

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

$seconds = ClickFormButtonByLabel("Button Three");

Cookbook Recipe:

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

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

$Win32::OLE::Warn = 3;

StartIE();
$seconds = Navigate($URL);
print "simpleform.html page took $seconds seconds to load\n";
SetEditBox("name1","Groucho");
SetEditBox("age1","1");
SetEditBox("name2","Chico");
SetEditBox("age2","2");
SetEditBox("name3","Harpo");
SetEditBox("age3","3");
SetEditBox("name4","Zeppo");
SetEditBox("age4","4");
SetEditBox("name5","Ben Grimm");
SetEditBox("age5","5");
SetEditBox("name6","Reed Richards");
SetEditBox("age6","6");
$seconds = ClickFormButtonByLabel("Button Three");
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 $WindowTitle is optional. It tells samie that the name of the Window that contains the button. The fourth parameter $SkipFiringOnClickEvent is optional. It is used when you do not need to fire an OnClick Event.
images/littlesamie.jpg (853 bytes)