Correlation and checking in Results

Correlation and checking


In Previous post we have randomly selected value for depart and arrive.
Each Depart and arrive have a outboundFlight and returnFlight field, which changes according to the selected values.

For E.g.:
When we recorded the script with depart as “London” and arrive as “Paris” the below flight details was recorded accordingly to the selection.

    /*web_submit_form("reservations.pl_2", 
        "Snapshot=t5.inf", 
        ITEMDATA, 
        "Name=outboundFlight", "Value=241;97;03/28/2014", ENDITEM, 
        "Name=returnFlight", "Value=422;102;03/29/2014", ENDITEM, 
        "Name=reserveFlights.x", "Value=26", ENDITEM, 
        "Name=reserveFlights.y", "Value=8", ENDITEM, 
        LAST);
*/

As we see above the outboundFlight and returnFlight is hard coded and needs to be correlated according to the selected value.

So inserting the correlating statements as below. These values are returned by server according to the values selected:
//name=outboundFlight value=241;97;03/28/2014>
    web_reg_save_param("outbound","LB=name=outboundFlight value=","RB=>","ORD=2",LAST);
   
//name=returnFlight value=422;102;03/29/2014>
    web_reg_save_param("return","LB=name=returnFlight value=","RB=>","ORD=2",LAST);

//Here we are using “ORD=2”. Explanation follows
    lr_start_transaction("Find Flight");

    web_submit_data("reservations.pl",
        "Action=http://127.0.0.1:1080/cgi-bin/reservations.pl",
        "Method=POST",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:1080/cgi-bin/reservations.pl?page=welcome",
        "Snapshot=t4.inf",
        "Mode=HTML",
        ITEMDATA,
        "Name=advanceDiscount""Value=0"ENDITEM,
        "Name=depart""Value={depart}"ENDITEM,
        "Name=departDate""Value={departDate}"ENDITEM,
        "Name=arrive""Value={arrive}"ENDITEM,
        "Name=returnDate""Value={returnDate}"ENDITEM,
        "Name=numPassengers""Value=1"ENDITEM,
        "Name=roundtrip""Value=on"ENDITEM,
        "Name=seatPref""Value=Aisle"ENDITEM,
        "Name=seatType""Value=Coach"ENDITEM,
        "Name=.cgifields""Value=roundtrip"ENDITEM,
        "Name=.cgifields""Value=seatType"ENDITEM,
        "Name=.cgifields""Value=seatPref"ENDITEM,
        "Name=findFlights.x""Value=45"ENDITEM,
        "Name=findFlights.y""Value=6"ENDITEM,
        LAST);

    lr_end_transaction("Find Flight",LR_AUTO);

    lr_output_message("Output Flight:%s",lr_eval_string("{outbound}"));
    //Action.c(146): Output Flight:950;462;03/29/2014 checked -with ORD=1
    //Action.c(147): Output Flight:581;717;03/29/2014 - with ORD=2 (which is required to pass to below request)
    lr_output_message("Return Flight:%s",lr_eval_string("{return}"));
    //Action.c(149): Return Flight:220;0;04/01/2014 checked - with ORD=1
    //Action.c(149): Return Flight:851;717;04/01/2014 - with ORD=2 (which is required to pass to below request)
    
/* Note : Here we have used ORD=2 in correlation because if we used ORD=1 we are getting some extra characters in correlation, which are not required to pass in the value. So keeping ORD=2 is capturing the correct value.
*/

/*Now, once we captured the values of outbound and return Flights using correlation, passing the values in the below request.
*/

    lr_start_transaction("Select Flight");
   

web_submit_form("reservations.pl_2",
        "Snapshot=t5.inf",
        ITEMDATA,
        "Name=outboundFlight""Value={outbound}"ENDITEM,
        "Name=returnFlight""Value={return}"ENDITEM,
        "Name=reserveFlights.x""Value=26"ENDITEM,
        "Name=reserveFlights.y""Value=8"ENDITEM,
        LAST);
       
    lr_end_transaction("Select Flight",LR_AUTO);

    lr_start_transaction("Payment");

    web_submit_data("reservations.pl_3",
        "Action=http://127.0.0.1:1080/cgi-bin/reservations.pl",
        "Method=POST",
        "RecContentType=text/html",
        "Referer=http://127.0.0.1:1080/cgi-bin/reservations.pl",
        "Snapshot=t6.inf",
        "Mode=HTML",
        ITEMDATA,
        "Name=firstName""Value=Name"ENDITEM,
        "Name=lastName""Value=Lol"ENDITEM,
        "Name=address1""Value=Main Street"ENDITEM,
        "Name=address2""Value=City"ENDITEM,
        "Name=pass1""Value=Name"ENDITEM,
        "Name=creditCard""Value=3253253253253XXXX"ENDITEM,
        "Name=expDate""Value=11155"ENDITEM,
        "Name=oldCCOption""Value="ENDITEM,
        "Name=numPassengers""Value=1"ENDITEM,
        "Name=seatType""Value=Coach"ENDITEM,
        "Name=seatPref""Value=Aisle"ENDITEM,
        "Name=outboundFlight""Value={outbound}"ENDITEM,
        "Name=advanceDiscount""Value=0"ENDITEM,
        "Name=returnFlight""Value={return}"ENDITEM,
        "Name=JSFormSubmit""Value=off"ENDITEM,
        "Name=.cgifields""Value=saveCC"ENDITEM,
        "Name=buyFlights.x""Value=51"ENDITEM,
        "Name=buyFlights.y""Value=11"ENDITEM,
        LAST);

    lr_end_transaction("Payment",LR_AUTO);

We can verify the values are passed correctly in Test Results. As shown in the below screenshots.

Flight departing and arriving is same as in Replay Log



In the above we have still one hard coded value i.e. Everytime the second out of Four values in the Find Flight screen is getting selected.

Comments

Popular posts from this blog

How to use a value between two different threads in Jmeter

Steps to Analyze AWR Report in Oracle

Verifications and Error Handling in LoadRunner *Web_reg_find and Web_reg_save_param*