Web Application Performance Issue
Web Application Performance Issue
COM
Question: How can we increase performance of our scripts for a web application with deep paths (objects
within the objects for an example webtablewithin several webtables)?
Description: We are using Descriptive programing in our project. From the performance point of view our
scripts are very slow even if a single text box has to be populated with a specific text, it takes several minutes
to perform the Action. It seems too many similar objects are the reason.
Question by: Sachin Ratra
Answer: Sachin, the issue was obviously because of several object of similar kind but it wasnt the only issue,
there was something very basic which was triggering the issue.
Lets go step by step and see what all may cause delays in QTP scripts and how can we overcome them:
Step 1 Defining the Objects:
Set oBrowser=Description.Create
oBrowser(title).value=Create Assignment
oBrowser(index).value=0
Most of us describe the objects like this only, either we dont know whats wrong with this or we never consider
performance aspects of the code we write:
Every object created (using Description.Create method) in QTP has a RegularExpression Property, which
specifies whether the value of a Property object in the Properties collection is a regular expression or not.
And By default,value of all Property objects added to a Properties collection are treated as regular expressions.
Which clearly means that if every value would be considered as a regular expression, matching a regular
expression would take more time as compare to matching a constant with several values in the available object
pool. Although generally we do not experience such issues, but if your object pool grows significantly large you
will surely see a significant difference (as in case of your application).
So, its always advisable to set the RegularExpression property to false. Now the question is how would you
do it in practical scenario, because it doesnt seem practical to set RegularExpression property to false for every
single definition. If you will do it for every value you will land up with increasing several
lines of code and code will look like as follows:
Set oBrowser = Description.Create
oBrowser(title).value=Create Assignment
oBrowser(title).RegularExpression=false
oBrowser(index).value=0
oBrowser(index).RegularExpression=false
Hence, to avoid this you have to do two things:
1. Identify what all objects are eating up most of the time while identification
2. Set RegularExpression property to false for these objects, using a custom Function/Procedure,
you may write a function like the following one to set all defined TO properties
Copyright
2011-2012, www.Technodivine.com
Sub SetRegularExpressionOFF(oObject)
For i=0 to oObject.Count-1
sPropertyname=oObject.Item(i).name
oObject(sPropertyname).RegularExpression =False
Next
End Sub
Above procedure can be called after define the object (only for those objects wherein identification take too
long)
Creating an Object for a Browser
Set oBrowser=Description.Create
oBrowser(title).value=Create Assignment
oBrowser(index).value=0
SetRegularExpressionOFF oBrowser
Regards,
Bharat Kakkar
Copyright
2011-2012, www.Technodivine.com