Professional Documents
Culture Documents
1. Regular Expressions :-
During execution some times QTP may not identify the objects due to the regular
changes in its properties values. To over come this situation one need to replace the
corresponding Constant value in the object repository with a suitable regular
expressions.
Example : To send number of orders thru fax
Example :
Function file
Function add(a,b) : function name is add
Total = a + b : adding to values to Total
add = Total : Retuning the result to the function name it self
End function
Example :
Open the cal application
Add the cal application’s object properties to Object Repository
Activate menu item Step
Select the option Action properties
Select Parameters tab
Declare the input parameters values by clicking (+) add button
Give the name (a) , Type ( number) and some default number
Similarly Give the name (b) , Type ( number) and some default number
Declare the output parameters by clicking (+) add button
Give the name (a) and Type ( number)
Click on OK
Write the script as below
' setting the input parameter to val1
VbWindow("Form1").VbEdit("val1").Set parameter("a")
' setting the input parameter to val2
VbWindow("Form1").VbEdit("val2").Set parameter("b")
VbWindow("Form1").VbButton("ADD").Click
' getting the value of Result and passing to var1
var1=vbwindow("Form1").VbEdit("res").GetROProperty("text")
' passing that var1 to Output parameter c
parameter("c")=var1
Make this test as re-usable
Activate menu item Step
Select the option Action properties
Select the check box Reusable action
Click on OK
Save it say (myTest) ( no extension is required)
Open the new test
Call that saved re-usable action
Note : RunAction "Action1 [myTest]", oneIteration, , ,r1 : used to enter the default values into val1 and val2
** Once we created virtual object , it will be available to All Tests except we delete it.
Example :
Open the virtual object application ( a window with colorbutton shape)
Activate menu item , select Virtual Objects option
Select the option New virtual Object
Virtual Object wizard will appear, click on Next
Select the standard class that nearly match to your object ( say button )
Click Next
Mark the object on the AUT screen, Height and width will be captured
Click Next
Select the option for parent of the virtual object
Select Next
Specify the name (button) and collection name ( Button_collections)
Click OK
Put the tool under recoding mode
Click on the area you selected as button and any area on the screen
Stop recording
Analyze the results
Virtual Object Manager : Which is a feature provided by QTP used for creating and maintaining the virtual
objects.
-: The End :-
Pls. leave your feed back (both +ve and –ve ) at kanakadria@yahoo.co.in