Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on LoadRunner script reading csv file within the LoadRunner forums, part of the Software Testing category; Hi, I have a LoadRunner script which reads data from a csv file. Using the same web tours application, it is supposed to pick up rows from csv file for ...
|
|||||||
|
|||
|
LoadRunner script reading csv file
Hi,
I have a LoadRunner script which reads data from a csv file. Using the same web tours application, it is supposed to pick up rows from csv file for username, pwd, departure city, departure date, arrival city and return date. I have written a code, which works fine. I am new to LoadRunner, hence I am not sure if this is the optimal solution. I have correlated the dynamic value of session id and parametrized username, pwd, etc. My script reads csv file row into an array, then converts it into a string, then makes tokens. I have attached the parameter list screen shot. Please have a look at the code. Is there anyway of referring to the column names directly into the script? Action() { char *myarray, *tkn; char *token[80]; char tst[70], pwd,name,departurecity,departuredate, arrivalcity,returningdate; int j, i=0; // [WCSPARAM SessionID 41 100819.48254354fVifQAcpVDDDDDDDDVVVfptVci] Parameter {SessionID} created by Correlation Studio web_reg_save_param( "SessionID", "LB=userSession value=", "RB=>", "Ord=1", "IgnoreRedirections=Yes", "Search=Body", "RelFrameId=1.2.1", LAST ); web_url("WebTours", "URL=http://127.0.0.1:1080/WebTours/", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", LAST); myarray=lr_eval_string("{users}"); sprintf(tst,"%s",&myarray[0]); token[0] = (char *)strtok(tst,","); while(token[i]!= NULL) //ensure a pointer was found { i++; token[i] = (char *)strtok(NULL, ","); //continue to tokenize the string } for(j = 0; j <= i-1; j++) { tkn=token[j]; switch (j) { case 0: lr_save_string(&tkn[0],"name"); lr_output_message("Name is : %s", lr_eval_string ( "{name}" )); break; case 1: lr_save_string(&tkn[0],"pwd"); lr_output_message("Password is : %s", lr_eval_string("{pwd}") ); break; case 2: lr_save_string(&tkn[0],"departurecity"); lr_output_message("Departure City is: %s", lr_eval_string("{departurecity}") ); break; case 3: lr_save_string(&tkn[0],"departuredate"); lr_output_message("Departure Date is : %s", lr_eval_string("{departuredate}") ); break; case 4: lr_save_string(&tkn[0],"arrivalcity"); lr_output_message("Arrival City is : %s", lr_eval_string("{arrivalcity}") ); break; case 5: lr_save_string(&tkn[0],"returningdate"); lr_output_message("Return Date is : %s", lr_eval_string("{returningdate}") ); break; default: lr_output_message("Invalid option selected"); } } web_submit_data("login.pl", "Action=http://127.0.0.1:1080/WebTours/login.pl", "Method=POST", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home", "Snapshot=t2.inf", "Mode=HTML", ITEMDATA, "Name=userSession", "Value={SessionID}", ENDITEM, "Name=username", "Value={name}", ENDITEM, "Name=password", "Value={pwd}", ENDITEM, "Name=JSFormSubmit", "Value=on", ENDITEM, "Name=login.x", "Value=31", ENDITEM, "Name=login.y", "Value=11", ENDITEM, LAST); web_image("Search Flights Button", "Alt=Search Flights Button", "Snapshot=t3.inf", LAST); // [WCSPARAM WCSParam_Diff1 18 640;622;07/10/2009] Parameter {WCSParam_Diff1} created by Correlation Studio web_reg_save_param( "WCSParam_Diff1", "LB=outboundFlight value=", "RB= ", "Ord=1", "IgnoreRedirections=Yes", "Search=Body", "RelFrameId=1", LAST ); web_submit_form("reservations.pl", "Snapshot=t4.inf", ITEMDATA, "Name=depart", "Value={departurecity}", ENDITEM, "Name=departDate", "Value={departuredate}", ENDITEM, "Name=arrive", "Value={arrivalcity}", ENDITEM, "Name=returnDate", "Value={returningdate}", ENDITEM, "Name=numPassengers", "Value=1", ENDITEM, "Name=roundtrip", "Value= "Name=seatPref", "Value=None", ENDITEM, "Name=seatType", "Value=Coach", ENDITEM, "Name=findFlights.x", "Value=40", ENDITEM, "Name=findFlights.y", "Value=11", ENDITEM, LAST); web_submit_form("reservations.pl_2", "Snapshot=t5.inf", ITEMDATA, "Name=outboundFlight", "Value={WCSParam_Diff1}", ENDITEM, "Name=reserveFlights.x", "Value=34", ENDITEM, "Name=reserveFlights.y", "Value=6", ENDITEM, LAST); web_submit_form("reservations.pl_3", "Snapshot=t6.inf", ITEMDATA, "Name=firstName", "Value=Joseph", ENDITEM, "Name=lastName", "Value=Marshall", ENDITEM, "Name=address1", "Value=234 Willow Drive", ENDITEM, "Name=address2", "Value=San Jose/CA/94085", ENDITEM, "Name=pass1", "Value=Joseph Marshall", ENDITEM, "Name=creditCard", "Value=", ENDITEM, "Name=expDate", "Value=", ENDITEM, "Name=saveCC", "Value= "Name=buyFlights.x", "Value=38", ENDITEM, "Name=buyFlights.y", "Value=9", ENDITEM, LAST); /*sign off*/ web_image("SignOff Button", "Alt=SignOff Button", "Ordinal=1", "Snapshot=t7.inf", LAST); return 0; } |
| Sponsored Links |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reading a File in Local Machine | abujoy123 | Oracle | 2 | 01-02-2009 03:45 AM |
| Reading exe file by java code | guggi | Java | 1 | 08-13-2008 05:17 AM |
| Is there any limit to number of columns in excel file, when reading it from script? | sandeepdesai7 | WinRunner | 2 | 03-05-2008 09:46 AM |
| Run sample graph reading a file | sheker2007 | Data Warehousing | 2 | 09-25-2007 02:59 PM |
| Reading a TSR file | JobHelper | QTP | 1 | 07-27-2007 07:33 AM |