A method is a routine that applies to a particular class of objects. Once an object is declared, you can refer to it by its identifier when calling methods.
Find.SetActive ()
You can call methods for a window that has not previously been declared using a special identifier for dynamic instantiation. The syntax varies depending on whether you use INC files. When you record a test case with the Open Agent, Silk Test Classic creates locator keywords in an INC file to create scripts that use dynamic object recognition and window declarations. You can also manually create test cases that use dynamic object recognition without an INC file. Dynamic object recognition uses a Find or FindAll function and an XPath query to locate the objects that you want to test. No INC file, window declarations, or tags are required.
class("tag").class("tag"). ...
MainWin("Text Editor -*").DialogBox("Find").SetActive ()
Findclass name(locator). ...
FindMainWin("@caption=’Text Editor -*’").FindDialogBox("Login"). FindTextField("@priorlabel=’password’").TypeKeys("top secret")
A function is a routine that does not pertain to any particular object. Silk Test Classic provides some functions that are available in most other programming languages, such as functions for manipulating strings and numbers, and some functions that are unique to testing requirements.
First = Abs (iFirst)
Consider the SetMultiText method, which can accept three arguments:
textfield.SetMultiText(lsText [, iStartLine, iNumLines])
The first argument, lsText, is required; you must include it when calling SetMultiText. The two arguments shown inside of brackets are optional. However, if you use the first one, you must also use the second because iNumLines counts lines of text starting from iStartLine.
newDT = AddDateTime(Datetime[, iDays, iHours, iMins, iSecs, iMsecs])
The first argument, Datetime, is required; the five arguments shown inside of brackets are optional. However, if you specify one, you must also specify any of the optional arguments that precede that one.
newDateTime = AddDateTime (datetime, NULL,1)
Some functions and methods have arguments specified as inout or out. These specifications indicate that the function or method can change the value of the argument. For more information, see Function Declaration.
Some methods and functions return values. You can provide a variable to hold the returned value, as in the first example below, or use the function or method call in another expression, so that the returned value becomes the value passed to the expression.
// return GUITYPE to variable gtype GUITYPE gtype = GetGuiType () // pass font size to Verify function Verify (MyDialog.RichEdit1.GetFontSize (4, 1), 12)
The second example passes the font size of the character in the first column of the fourth row to the Verify function, which verifies that the size is 12.
You can use the ArgListCall keyword to pass the name of the function or method, along with its arguments, at runtime in data-driven tests.