Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How do I create user-defined properties in SilkTest?

How do I create user-defined properties in SilkTest?

In the example below, we are going to create a new property for the ChildWin class called iChildCount. We will first define our new property, add it to our list of properties for that class and then write a method to assign the new property its value.

  1. Define the property

    [-] property iChildCount

  2. Define a LIST OF STRING variable called lsPropertyNames with the {...} constructor.

  3. Then add your property name to the lsPropertyNames list which will cause SilkTest to add the property to the list of available verification properties for the instances of the class that the property belongs to, and the new property is visible in the Verify Window. This means that in this example, iChildCountwill now be available for the class ChildWin.

    [-] LIST OF STRING lsPropertyNames = {...}
        [ ] "iChildCount"

  4. You should then create a Getmethod that will direct 4Test on how to actually evaluate the object and return the value for the property. You will write this method under the declaration of the property (created in step 1);

    [-] property iChildCount
       [-] hidecalls INTEGER Get ()
           [ ] return ListCount(this.GetChildren ())

    In this example, our Get method calls a GetChildren on the specified childwin and does a ListCount on what is returned to give us the value of the property.

  5. Alternatively, for a property which you require to be able to set the value, you can create a Set method that will assign a value to the property.

The finished winclass will look like this;

Now when you do a Ctrl-Alt over an object of the ChildWin class, you should be able to see your new property in the Verify Window like so;

You can then call this property directly in a testcase like so;

[-] testcase one () appstate none
    [ ] 
    [ ] GMO.SetActive ()
    [ ] 
    [ ] // this returns the value of the iChildCount property
    [ ] print (CustomerInformation.iChildCount)
    [ ] 
    [ ] // this verifies that the value is 27
    [ ] Verify (CustomerInformation.iChildCount, 27, "Child Count")
    [ ]

The testcase above will return the value 27.

This value will change depending on the number of children on the specific ChildWin the property is called against.

Old KB# 21125


Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2013-02-15 19:17
Updated by:
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.