QTP hangs when trying to run the scripts

If you are facing issues in QTP while hitting F5 or when trying to run your automation test scripts, then please try these QTP tips to see if it works for you.

Tips to overcome QTP Hangs issues

Go to start -> Run -> %temp%

Then clear all the temporary objects created at this location

You may need to close your applications and close QTP for you to be able to delete the temporary objects

Some of these are the local object repositories of your action files

See how this works and let me know through comments.

How to set QTP Object Repositories at runtime

As you all know we can set Shared Object Repository path for our test scripts by associating repositories using QTP option. The only drawback here is that if you are using an absolute path for the Shared Object Repository then this becomes a dependency in case you are delivering the scripts to the client or in case you want to run the scripts from another machine.

As long as you are maintaining the path as same then we don't face any issues.

Else what you need to do to set the Object Repository path at run time?

You need to create or get an handle to the QTP APP object

Create a collection of QTP Repositories

Make sure that both the above variables are global in nature - accessible to all actions

Example: This will work in QTP 10

Set colQTPRepositories = App.Test.Actions(Environment("ActionName")).ObjectRepositories
colQTPRepositories.SetAsDefault
colQTPRepositories.Add "SORPath", 1

It is even better if you read the SOR Path from a configuration file.

Ensure that you set the created objects to nothing as appropriate

Please leave a comment to know more on this.