Friday, 28 February 2014

Qtp script executing in different url when execute it from LoadRunner

Problem detail:   I have a qtp script that was recorded with url A.

In my test settings, I have an user defined Environment file that refers where the test needs to be run on url B

<Environment>

<Variable>

<Name>BROWSER_ENV</Name>

<Value>IE</Value>

</Variable>

<Variable>

<Name>URL_ENV</Name>

<Value>B</Value>

</Variable>

</Environment>

In my qtp script, I am referring to this environment variable

Environment.LoadFromFile "......."

When I run this script in qtp, the test executes in correct browser B.

When I run this script from Loadrunner, the test executes in the browser A, I need it to run in B.

I have 10 scripts, 6 of them are executing in B and the rest of them are executing in A. I do not know where the reference is set that it is running in A and this is happening only when the script is run from Loadrunner.

Problem Solution:

When the script is executed from QTP, the script accesses the correct URL. However when the same script is run from the LoadRunner Controller, it accesses a different URL.

Response

Run the script through “The Silent Test Runner” application. It allows you to verify if a QTP test is compatible with LoadRunner.

To run QTP test via Silent Test Runner:

Go to Start -> All Programs -> QuickTest Professional -> Tools -> Silent Test Runner

Specify path to the QTP test and press 'Run Test' button

Once test finished replay, click on 'Test Run Log' button and check if it went to correct URL.

Loading the environment file just load the information of the file to the test, so that the user can use the “Environment(…)” statement to access the value of the environment variables specified in the file. In short, loading the environment variables file doesn’t mean you instruct the test to navigate to the specific URL.

In fact, there are different ways to instruct the test to navigate to the specific URL. One way to specify the test to open a specific URL is to use the option “Open the following address when a record or run session begins” and then specify the URL in the “Automation->Record and run settings->Web tab”.

For this, do the following:

1. Open the script in QuickTest Professional.

 

2. Then, go to QTP menu “Automation->Record and Run settings”, select “Web” tab. Make sure the option, “Open the following address when a record or run session begins” is still selected and change the url to the one that you wants.

Check to see if the script goes to the correct URL now.

The question now arises as to how-to delete the other URLs from 'Record and Run Settings', so that only one URL is available in the dropdown. In this way we can force the reference to only one URL.

The URLs are saved in the registry: "HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest\AddIn Manager\Web\Startup Settings\URL\History\". You'll see registry keys like 0, 1, 2, etc and the URL is saved in each of the keys.

11 comments: