By: Josh Watts - seajosh
SAMIE documentation
2005-06-06 08:33
Here's my pass at documenting SAMie that I did a while ago and thought I'd post it here as well.
Win32::SAM - Simple Automation Mode for Internet Explorer
* NAME
* SYNOPSIS
* DESCRIPTION
o Methods
* AUTHORS
* SEE ALSO
NAME
Win32::SAM - Simple Automation Mode for Internet Explorer (SAMie)
SYNOPSIS
use strict;
use Win32::OLE;
use Win32::SAM;
$| = 1;
my $URL = 'http://samie.sourceforge.net/popupframes/basepage.html';
my $IEDocument;
my $seconds;
my $htmlseite;
my $item;
$Win32::OLE::Warn = 0;
StartIE();
Navigate($URL);
$IEDocument = GetDocument();
print "Calling WaitForDocumentComplete1\n";
print "Clicking Link one\n";
ClickLink("Link one");
print "Calling WaitForDocumentComplete2()\n";
print "Clicking Link two\n";
ClickLink("Link two");
print "Calling WaitForDocumentComplete3()\n";
print "Clicking Link three\n";
ClickLink("Link three");
print "Calling WaitForDocumentComplete4(8)\n";
SetEditBox("basepage","This is cool basepage");
SetEditBox("popup1","This is cool1");
SetEditBox("popup2","This is cool2");
SetEditBox("popup3","This is cool3");
DESCRIPTION
SAMie allows you to Automate Internet Explorer without having to pay the licensing fees of those ``other automation tools.''
It uses Win32::OLE to get the IE COM object and then a reference to the DOM. Once you have the DOM you're pretty much home free.
For more information on interfaces to the DOM elements, go to http://msdn.microsoft.com/workshop/browser/mshtml/reference/reference.asp
For more information on controlling the IE browser, go to http://msdn.microsoft.com/workshop/browser/webbrowser/browser_control_node_entry.asp
Methods
StartIE()
This class method starts IE and maximizes the IE window.
RefreshIE()
This class method refreshes the page currently loaded in IE.
Navigate($URL[,$POPUP])
This class method tells the browser to load the specified URL. The optional POPUP argument specifies that the URL will open in a popup window.
GetActiveObject()
This class method lets SAMie use a browser that is already open.
ClickBackButton()
This class method emulates clicking the browser's back button.
GetDocument()
This class method returns a reference to the DOM.
DismissSecurityAlert()
This class method closes a Security Alert window.
VerifyMessageBox($CAPTION,$EXPECTEDTEXT)
This class method verifies if EXPECTEDTEXT exists in a popup window with CAPTION in the title.
VerifyCheckBox($NAME,$VALUE)
This class method checks to see the checked status of a checkbox input element with name NAME & value VALUE. It returns 0 if it's checked and 1 if it's unchecked.
VerifyTextPresent($TEXT)
This class method verifies that TEXT is in the browser's document.
VerifyTextArrayPresent(@TEXTARRAY)
Need information here.
VerifyTextNotPresent($TEXT)
This class method verifies that TEXT is not in the browser's document.
ClickTreeNodeOrig($NODE)
Need information here.
ClickTreeNodeIcon($NODE)
Need information here.
ClickTreeNode(@NODES)
Need information here.
PrintAllObjects($IEObjectGroup,$IEObject,$i)
Prints element information for every element in the DOM.
VerifyLinkTextExists($LINKTEXT,$ISFAIL)
Returns 1 if a link with LINKTEXT exists; 0 otherwise. If ISFAIL is 1, the method stops execution of the script.
VerifyFormElementExists($NAME)
Returns if the form element NAME is found; stops execution of the script otherwise.
VerifyEditBox($NAME,$VALUE)
Returns 0 if the form element NAME exists and has a value VALUE; returns 1 if the element isn't found or the element is found but doesn't have a value VALUE.
VerifyTableText($TEXT)
Returns 0 if TEXT is found within a table; returns 1 otherwise.
VerifyListBoxItem($SELECTNAME,$ITEMNAME)
Returns 0 if ITEMNAME is found within select element SELECTNAME; returns 1 otherwise;
SetEditBox($NAME,$VALUE[,$ACTION[,$FORMNAME]])
Sets the text element NAME value to VALUE. If ACTION is 'onblur',the onblur and onchange events are fired. If FORMNAME is defined,looks for the the text element NAME within that form.
ClickDiv($ID)
Clicks the div element with an id of ID.
ClickButton($VALUE[,$WDC[,$POPUP]])
Clicks a button or submit element with a value of VALUE. If WDC is 0, SAMie doesn't wait for the browser to load a page,useful when clicking a link to download a file or display an alert. If POPUP is 1, SAMie waits for a popup window to load a document.
ClickTableData($TITLE)
Clicks a table cell with a title of TITLE.
LookForListBoxItem($ACCOUNTNUMBER,$ITEMNAME)
This function needs to be renamed.
ClickImage($IMAGENAME,$POPUP)
Clicks an image with a src or alt attribute of IMAGENAME and fires the onclick event. If POPUP is defined,SAMie waits for a doucment to load in a popup window.
ClickFormImage($IMAGENAME[,$POPUP[,$CHECKFORMESSAGEBOX]])
Clicks an image with a value or alt attribute of IMAGENAME within a form. If POPUP is defined,SAMie waits for a document to load in a popup window. If CHECKFORMESSAGEBOX is defined,processes an alert or similar message box.
ClickRadioButton($RADIONAME,$RADIOVALUE)
Sets the nth element,defined by RADIOVALUE,in a radio input group defined by RADIONAME.
VerifyRadioButton($RADIONAME,$RADIOVALUE,$STATE)
Returns 0 if the nth element,defined by RADIOVALUE,in a radio input group defined by RADIONAME is checked; returns 1 otherwise.
VerifyStatusBarMessage($STATUSBARMESSAGE)
Returns if the browser's status bar text is equal to $STATUSBARMESSAGE; stops the execution of the script otherwise.
ClickCheckBox($ITEMNAME)
Clicks the check box element with a name of ITEMNAME.
SetCheckBox($NAME,$VALUE[,$FORMNAME])
Sets the check box element' value with a name of NAME to VALUE. If FORMNAME is defined,SAMie only sets the check box element contained in the form FORMNAME.
ClickLink($LINKNAME[,$POPUP[,$CHECKFORMESSAGEBOX[,$INDEX[,$WDC]]]])
Clicks the link where the link's text is equal to LINKNAME. If POPUP is 1,SAMie waits for the document to load in a popup window. If CHECKFORMESSAGEBOX is 1,process an alert or similar message box. If INDEX is defined,clicks the nth link. If WDC is 1,SAMie waits for the document to load; otherwise,it returns from the function.
SetListBoxItem($SELECTNAME,$ITEMNAME[,$FORMNAME])
Sets the select input element's value,defined by SELECTNAME,to the option with a value or text of ITEMNAME. If FORMNAME is defined,only sets the select input element within that form.
GetCurrentListBoxItem()
This function needs to be reworked.
ClickFormButtonByIndex($BUTTONINDEX[,$POPUP[,$CHECKFORMESSAGEBOX[,$FORMNAME]]])
Clicks the nth button,defined by BUTTONINDEX. If POPUP is 1,waits for the document to load in a popup window. If CHECKFORMESSAGEBOX is 1,processes an alert or similar message box. If FORMNAME is defined, clicks the nth button in form FORMNAME.
ClickFormButtonByLabel($BUTTONLABEL,$POPUP,$WINDOWTITLE,$SKIPFIRINGONCLICKEVENT)
Not sure about this function.
ClickFormButton($BUTTONNAME[,$POPUP[,$CHECKFORMESSAGEBOX[,$FORMNAME[,$NOWAIT]]]])
Clicks a button or submit element with a value of VALUE. If POPUP is 1, SAMie waits for a popup window to load a document. If CHECKFORMESSAGEBOX is 1,processes an alert or similar message box. If FORMNAME is defined, clicks the nth button in form FORMNAME. If NOWAIT is 0, SAMie doesn't wait for the browser to load a page,useful when clicking a link to download a file or display an alert.
ClickAClassNameHyperlink($CLASSNAME[,$POPUP[,$CHECKFORMESSAGEBOX]])
Clicks the first link with a class name attribute of CLASSNAME. If POPUP is 1,SAMie waits for a popup window to load a document. If CHECKFORMESSAGEBOX is 1,processes an alert or similar message box.
ListNamespaces()
This function does not return any values.
SetFile($FILEINPUT,$FILEPATH)
Sets the file input element's $FILEINPUT value to $FILEPATH. Using this function uses the Win32::GuiTest SendKeys() function to set the value.
KillPopups($URL)
SAMie doesn't open popup windows with URL in the url of the popup window. Every call to this function adds URL to the array of popup urls to kill.
IgnoreURL($URL)
SAMie doesn't wait for a document to load with a url of URL. Every call to this function adds URL to the array of the urls to ignore.
WaitForRefresh()
This function returns after a document is refreshed.
SaveFile($FILENAME,$DIRECTORYNAME)
This function processes a 'Save File' dialog box. It saves the download file to FILENAME. If DIRECTORYNAME is ``yes'',it prepends the FILENAME argument to the orignal filename in the 'Save File' dialog box; otherwise,the FILENAME argument is an absolute path.
GetLinkURL($LINKNAME)
Gets the url of the link LINKNAME.
AUTHORS
Henry Wasserman,
Josh Watts,
SEE ALSO
Win32::SAM - Simple Automation Mode for Internet Explorer
No comments:
Post a Comment