Highlighted
Absent Member.
Absent Member.
81 views

Can LR Open File, Grab Data, Post Data, & Close File

I am new to LoadRunner. I believe that I know the answer to this question but wanted to see if anyone has done this successfully. First, I am using an Ajax protocol. I use a SQL SSIS package to generate XML files and store them in a directory. I need LR to open each individual file, grab the XML, post to an Ajax app, and then close. Can this be done in recording? (I don't believe so). Or can someone post a scripting example to assist in doing this?
0 Likes
3 Replies
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Can LR Open File, Grab Data, Post Data, & Close File

It depends on your app but from what information you've provided, it seems to be a combination of recording and coding.

You 'should' be able to record the Ajax post function and close the app. However, you'll need to use c code to read the xml file, save the contents into a string or parameter, then use the string or parameter in the Ajax post.

Here's a quick and dirty example. Please check syntax since I have not used it in some time.

long downloaded;
char *buffer;

if ((downloaded=fopen("","r")) == NULL )
{
lr_error_message("Cannot open file");
}
else
{
buffer=(char*)malloc(500000);
while (!feof(downloaded))
{
fread(buffer, sizeof(char), 500000, downloaded);
}
lr_error_message("%s",buffer);
}

lr_save_string(buffer, "xml_post");
lr_error_message("parmaeter %s",lr_eval_string("{xml_post}"))
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Can LR Open File, Grab Data, Post Data, & Close File

Thanks for your assistance on this. This got me going in the right direction!
0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Can LR Open File, Grab Data, Post Data, & Close File

You're welcome. Glad that you found it helpful.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.