Unable to use local variable in web_submit_data (476 Views)
Reply
Occasional Advisor
MadhuGandhi
Posts: 12
Registered: ‎01-25-2013
Message 1 of 4 (476 Views)

Unable to use local variable in web_submit_data

Hi all,

 

I am try to use local variable in the below web_submit_data function.

 

But when I pause and check the run time view, the SeatNumber textbox is filled with the value SeatNo, instead of 35. kindly help me in this issue.

 

LR VuGen Version = 11.51

 

int SeatNo=35;

 

web_submit_data("default.aspx",
 "Action=http://lazarus/flightnet/default.aspx",
 "Method=POST",
 "TargetFrame=",
 "RecContentType=text/html",
 "Referer=http://lazarus/flightnet/",
 "Snapshot=t7.inf",
 "Mode=HTML",
 ITEMDATA,
 "Name=SeatNumber", "Value=SeatNo", ENDITEM,
 "Name=SeatLoc", "Value=", ENDITEM,
 LAST );

Regular Advisor
LoadRunner421
Posts: 79
Registered: ‎02-20-2013
Message 2 of 4 (459 Views)

Re: Unable to use local variable in web_submit_data

You have to convert the int into a LoadRunner parameter and then do paramaterization, like this:

 

int SeatNo=35;

 

lr_save_intSeatNo, "SeatNoParameter");

 

web_submit_data("default.aspx",
 "Action=http://lazarus/flightnet/default.aspx",
 "Method=POST",
 "TargetFrame=",
 "RecContentType=text/html",
 "Referer=http://lazarus/flightnet/",
 "Snapshot=t7.inf",
 "Mode=HTML",
 ITEMDATA,
 "Name=SeatNumber", "Value={SeatNoParameter}", ENDITEM,
 "Name=SeatLoc", "Value=", ENDITEM,
 LAST );



 

Or you could just do this without the initial declaration:

 

lr_save_int( 35, "SeatNoParameter");

 

web_submit_data("default.aspx",
 "Action=http://lazarus/flightnet/default.aspx",
 "Method=POST",
 "TargetFrame=",
 "RecContentType=text/html",
 "Referer=http://lazarus/flightnet/",
 "Snapshot=t7.inf",
 "Mode=HTML",
 ITEMDATA,
 "Name=SeatNumber", "Value={SeatNoParameter}", ENDITEM,
 "Name=SeatLoc", "Value=", ENDITEM,
 LAST );

 

 

Or you could just make a parameter file and do it that way. Depends on where you're getting the data from.

 

 

 

 

Occasional Advisor
MadhuGandhi
Posts: 12
Registered: ‎01-25-2013
Message 3 of 4 (447 Views)

Re: Unable to use local variable in web_submit_data

Hi,

 

Thnak you very much for the tip. It was realyy helpful. I have a quick question. I have the web_submit_data, where I need to submit sead ids for close to 10 seats.

 

So is there a way to create an array for parameter SeatNoParameter?

 

 

web_submit_data("default.aspx",
 "Action=http://lazarus/flightnet/default.aspx",
 "Method=POST",
 "TargetFrame=",
 "RecContentType=text/html",
 "Referer=http://lazarus/flightnet/",
 "Snapshot=t7.inf",
 "Mode=HTML",
 ITEMDATA,
 "Name=SeatNumber01", "Value={SeatNoParameter}", ENDITEM, // 35
 "Name=SeatLoc01", "Value=", ENDITEM,
 "Name=SeatNumber02", "Value=36", ENDITEM,
 "Name=SeatLoc02", "Value=", ENDITEM,

 "Name=SeatNumber03", "Value=37", ENDITEM,
 "Name=SeatLoc03", "Value=", ENDITEM,

.

.

.

.

 "Name=SeatNumber10", "Value=44", ENDITEM,
 "Name=SeatLoc10", "Value=", ENDITEM,

LAST );

Regular Advisor
LoadRunner421
Posts: 79
Registered: ‎02-20-2013
Message 4 of 4 (436 Views)

Re: Unable to use local variable in web_submit_data

Sounds like you need to use a parameter file.

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.