Utility Objects in UFT

Meaning of Utility Objects:-
Utility objects are basically reserved keywords in UFT . This means their functionality is already defined in UFT compiler .For example in C language we used “Printf”  function, whose meaning was defined in  standard library of functions that were accessible by C program.

On the same tracks UFT provides lot of inbuilt utility objects whose functionality we can use at Runtime. These are not stored in object repository as objects.
Helps in retrieving or controlling UFT settings which can be used to modify the behavior of UFT at Runtime.
Some of the available Utility Objects:-
Datatable, Description, Dotnetfactory, Repository, RandomNumber, Environment
We need to generate Random number at runtime which can used to test the functionality of our application with random set of dat.
Scenario:- We want to test the addition functionality,  based on the random number
Solution: –We are going to use “RandomNumber” utility object.
‘Calling addition function 
Dim iFirstField,iSecondField
‘Assigning the random value between 1 and 100
iFirstField = RandomNumber(1,100)
‘Assigning the random value between 100 and 10000
iSecondField = RandomNumber(100,10000)
‘Function call
fnAdd iFirstField,iSecondField

public Function fnAdd(iFirstField,iSecondField)
    Dim iResult
    iResult = iFirstField + iSecondField
    msgbox (iResult)
End function

Leave a Reply

Your email address will not be published. Required fields are marked *