Friday 17 March 2023

Capture dynamic data and write it to an external file in LoadRunner

To capture dynamic data and write it to an external file in LoadRunner, you can use the web_reg_save_param function to capture the data and the standard C file I/O functions to write it to a file. Here's an sample code of mine.

Action()
{
char *dynamic_data;
web_reg_save_param("dynamic_data", "LB=<start>", "RB=<end>", LAST);
// Make the request that returns the dynamic data

web_url("example.com", "URL=http://example.com/", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", LAST);

// Retrieve the captured dynamic data

dynamic_data = lr_eval_string("{dynamic_data}");

// Write the captured data to a file

FILE *fp = fopen("output.txt", "w"); // Replace "output.txt" with your desired file name
if (fp != NULL)
{
fputs(dynamic_data, fp);
fclose(fp);
}
else
{
lr_error_message("Failed to open file for writing.");
}
return 0;
}

Here the web_reg_save_param will capture the dynamic data between the specified left and right boundaries, and store it in a parameter named "dynamic_data". Then, we make a request that returns the dynamic data, causing it to be captured and saved in the parameter. Next, we retrieve the captured dynamic data using lr_eval_string and store it in the dynamic_data variable. Finally, we use standard C file I/O functions to open a file named "output.txt" for writing, write the dynamic data to the file using fputs, and then close the file using fclose.

Resolving Performance Testing Issues with GWT | Google Web Toolkit in Performance Testing

If you're experiencing issues with GWT (Google Web Toolkit) in your performance testing, don't worry! There are a few steps you can take to solve these problems and improve your testing results.

First, ensure that you have the right version of the GWT Developer Plugin installed on your browser. If you're using an outdated version, you may encounter issues when recording your scripts.

Next, check your script for any errors or issues that may be causing problems with GWT. One common issue is the failure to properly handle asynchronous calls. To fix this, use the GWT synchronizer function to ensure that all asynchronous calls are completed before moving on to the next step in your script. You may also want to adjust your script's think time, or the amount of time between steps, to more accurately reflect real-world user behavior. GWT applications often have a high level of interactivity, so increasing think time can help ensure accurate test results.

Finally, check your server configuration to ensure that it can handle the load generated by your performance testing. This includes monitoring your CPU and memory usage, as well as ensuring that your server is properly configured to handle multiple simultaneous requests.

By following these steps, you should be able to resolve any issues you're experiencing with GWT in your performance testing and improve the accuracy of your test results.