Using this approach, you can get HTML source code of any Web page and then downloade it to a local file.
LoadRunner video - How to capture the whole Web page?
There is a final LR script for capturing and saving Web page:
int hFile;
char *szFileName = "c:\\page.html";
//Mark that we will capture the whole body of Web page
//Note: Mark that web_reg_save_param should be placed *before* web_url
web_reg_save_param("prmPage", "LB=", "RB=", "Search=Body", "RelFrameID=1", LAST);
web_url("labs.google.com", "URL=http://labs.google.com/", LAST);
//Web page has been captured, so print it out
lr_output_message("Page is: \r\n%s", lr_eval_string("{prmPage}"));
//Truncate to zero length or create file for writing.
if ((hFile = fopen(szFileName, "wb")) == NULL)
{
lr_error_message("Cannot open %s", szFileName);
return LR_FAIL;
}
//Write captured Web page to an output file
fprintf(hFile, "%s", lr_eval_string("{prmPage}"));
//Close the file pointer.
fclose(hFile);
char *szFileName = "c:\\page.html";
//Mark that we will capture the whole body of Web page
//Note: Mark that web_reg_save_param should be placed *before* web_url
web_reg_save_param("prmPage", "LB=", "RB=", "Search=Body", "RelFrameID=1", LAST);
web_url("labs.google.com", "URL=http://labs.google.com/", LAST);
//Web page has been captured, so print it out
lr_output_message("Page is: \r\n%s", lr_eval_string("{prmPage}"));
//Truncate to zero length or create file for writing.
if ((hFile = fopen(szFileName, "wb")) == NULL)
{
lr_error_message("Cannot open %s", szFileName);
return LR_FAIL;
}
//Write captured Web page to an output file
fprintf(hFile, "%s", lr_eval_string("{prmPage}"));
//Close the file pointer.
fclose(hFile);
Related articles:
- How to record PDF file saving - LoadRunner video
- web_reg_find - How to verify web page content?
- How to select correct boundaries for web_reg_save_param LoadRunner function?
- All LoadRunner visual tutorials
Do you like this LoadRunner video tutorial? Would you like to receive them in the future?
If yes, please subscribe to this blog RSS feed or by Email. (How to subscribe? VIDEO guide)
3 comments:
what is the use of capturing the whole webpage.i want to know further?
You can capture the whole Web page to check that a server returns correct data (a page).
Or you can parsed this received page and extract required data.
Also, you can save this page to local disk for further processing, etc.
iam not getting sound....wat may be the problem..?
Post a Comment