Thursday 21 July 2016

LR : How to create web_custom_request in LoadRunner


While working on the Flight Booking Application, 

I came across a scenario wherein there were multiple flights needed to be cancelled. The catch was that the count of flights to be cancelled was not fixed. Sometime, it could be 3, sometime 7 etc.


The cancellation request recorded via LoadRunner (in HTML mode) looked like below:


The solution to be above problem was to convert this request into a custom request to dynamically handle the number of flights.

Below is what I did,

I changed the recording options as below:



Then I regenerated the script via below option:


The cancellation request, after regeneration looked like below:


After close observation I understood that there is a repetition of below code, for every flight to be cancelled:

flightID=225259643-798-jB&
flightID=43296680-1568-jB&
flightID=163444829-2337-jB& and so on..

Additionally, there was a repetition of below as well,
.cgifields=33&
.cgifields=32&
.cgifields=90& and so on..

1.       I need to handle these in such a way as to capture each of these for every flight, concatenate them and then substitute in the request in step 3 above.

1.       Below is the code for the same:

a.       Correlations to be captured:-




b.       Code Logic:-



c.      Substitution in Cancellation Request:-


1.       Execution successful!!


Please note: There is a possibility that you might get the below error message during the script re-run:-


To resolve the above, all you need to do is to replace the failing request with its regenerated script counterpart. For ex: I got this error at sign off. So I replaced the Sign Off request as below, i.e. with its custom request:-


And the issue was resolved.

Cheers!!

Sunday 17 July 2016

LR : How to create a correlation rule in LoadRunner


~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
Steps:-
~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*

  • Set the Recording Options under Correlations section as below:-



  • Then start the recording (mercury tours application is used here for demo purpose):



    • Book the Flight. Then check the itinerary by clicking on the Itinerary button:-



    •  Sign Off and stop the recording



    • Following dialogue box is displayed once the recording completes:-


    • Click on the Details down arrow to display the recording section from where the correlation left and right boundaries can be captured:



    Mentioned here for reference (Line 17 – marked in yellow above):

    <input type="hidden" name="userSession" value="118948.659133252zVVitcVpzftVzzzHDzHVApfcQQcf"/>

    • Close the Design Studio as we will be coming back to it in a short while. Reason for not using the “Add as Rule…” option right away is that the Application name will have to be selected from the existing list (shown below) whereas the rules that we want to create doesn't specifically belong to any of the listed applications. 


    •       So, First we will create an application as shown in below step and then come back to the design studio to create the rule against our newly created application. Launch the recording options and create the application with user defined name, say, mercury






    • Select Mercury application and click on New Rule button on the right. Then enter the below details:-



    • Please note that the second dialogue box (Advanced Correlation Properties) in the above snapshot comes upon clicking the Advanced… button. Click on Test… button once the rule has been created and validate the created rule as shown below:



    • Now, Launch Design Studio available under Design menu option (this is the same screen that gets generated once the script is freshly recorded)



    • Click on Replay&Scan button. The rule(s) that we created in the above steps will now be visible in the Design Studio, as shown below:-



    •  Select the Rule and Click on Correlate. The Status column should now show status as applied.
    •  Kudos!! You have created a correlation rule and applied it successfully. In a similar fashion, remaining rules can be created.
    ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*