Tuesday, July 19, 2011

Some common QTP Tips & Tricks:

Maximum no. of actions can be created:
From QTP 9.0(or later) max of 120 actions can be created. We can extend this by installing private patch.
From QTP 8.2(or below) max of 255 actions can be created.

How to find which version of vbscript you are using?
Search for vbscript.dll in c:\windows\system32. In properties -> Version tab
Programatically we can retrieve this by:
msgbox ScriptEngineMajorVersion &"."& ScriptEngineMinorVersion

Associating function library Vs executefile
Use to associate functional libraries to a test rather than using execute file.
By associating functional library, all actions in the test can access those functions.
By calling executefile, all functions are loaded in the calling action only.

Recovery Scenario Vs On Error Resume Next
Recovery scenarios can be used when we dont know where an error arises.
We can use On Error Resume Next when we know the occurance of an error and we dont want to halt the execution because of that error.

Loading function library at run-time
From QTP 11 onwards we can use "LoadFunctionLibrary" statement to load Function library at run-time.
We can load multiple functional libraries in a single call like
LoadFunctionLibrary "c:\flb1","c:\flb2" etc...

Generating Random number
Generating a random number between min and max.
Syntax is: Int((max-min+1)*Rnd +min)
The below example generates a random number between 10 to 50 in each iteration
For i=1 to 5
msgbox Int((50-10+1)*Rnd +10)
Next

Arrays with redim
Small example with arrays and redim preserve
a=Array(5,2,50,33,21)
For i=0 to ubound(a)
msgbox a(i)
Next
ReDim preserve a(7)
a(5)=10
a(6)=20
For i=0 to ubound(a)-1
msgbox a(i)
Next

1 comment:

sree said...

in qtp 10 max 255 actions can be created.Please revise your post