Are you experiencing slow execution of your scripts? Does it takes much time to execute your scripts than it should be? If you feel that your qtp script execution has slowed down or there is a need to increase the speed, consider the points below to improve the performance of qtp script execution.
1. Set QuickTest Run Mode to Fast
Consider changing the run mode to fast. You can do this at Tools >Options > Run tab. The Change in behavior can be seen at run-time. The yellow execution arrow which you see in left bar of your script statements will not be there now. The tests will not expand the tree and it will not show up the scripts for each actions as well.
2. Images and movie capture
Until unless you don’t need, do not put these settings ON. These settings are at Tools > Options> Run > Screen Capture. Uncheck ‘save movie results’ and ‘save still images’. If you really want images to be captured, set it ‘for errors’ instead of ‘always’
3. Load only the required Add-ins
Just load those add-ins which are required for your automation.
Uncheck all unwanted add-ins at Add-in Manger at start up.
4. Disable Active Screen
Active screen takes lots of disk space and it makes your script slower. You can notice while modifying your scripts, update of the active screen takes few seconds to load. So until unless you don’t need it, Close the Active screen window and do not save the tests with active screen. clear the option ‘Save active screen file’ in ‘Save’ Dialog.
If you really want to have this, consider checking the Capture level at Tools > Options > Active Screen.
5. Recovery Scenario
This is very crucial as far as performance is concerned. Try not to use them as far as possible. avoid having unwanted pop ups like for printers, anti-virus etc on the machine. Some browser popups can be disabled manually by selecting “do not show this next time” before actually automating scripts.
5. Importing sheet
If you are making use of external excel file and you are importing it into data table, then make sure you are doing it once, not for every iteration.
for example: If the first line of your script is Datatable.Import(filename) and you have enabled “run on all iterations”, you are simply importing the sheet every time unnecessarily.In such cases, set mode to “run one iteration only” and use a loop after import method
6. Declare variables
Scripts with variables declared are usually faster than the scripts where you don’t declare variables using DIM. If a variable is not declared it is always referenced by name every time it is used, which slows down the execution. Use OPTION EXPLICIT at the beginning of your script which forces to declare variables.
7. Avoid using Wait Statement
Use Exist or sync method for synchronization, rather using Wait statement.
8. Use Object Repository
Scripts run faster if all the objects are in the Object Repository rather using straight descriptive programming in the scripts. if you have a large object repository then also it creates performance issues. a mix of both should work better.
9. Use With Statement
Usage of with statements help in reducing number of function calls and so the execution time. Use with statements for a set of statements rather writing the same code multiple times.
So, these are some of the methods, which I would recommend to improve performance of your automation scripts.