Highlighted
Absent Member.
Absent Member.
18923 views

Vugen Check file downloaded

Jump to solution

Hi
I used vugen 9.52 and I'd like to check that when I click on a file link (on web page) a popup windows opens and I can save the file.
How can I check this (that the file really exists). I don't need to check file content.
Regards,
Marc

 

P.S. This thread has been moved from Performance Center Support and News Forum to LoadRunner Support Forum. -HP Forum Moderator

1 Solution

Accepted Solutions
Highlighted
Super Contributor.
Super Contributor.

Re: Vugen Check file downloaded

Jump to solution
Perform a text check on part of the binary or output the file to the machine

1. Text check with web_reg_find.
For example, if you have a .pdf file, you can verify the information by using the regular text check function web_reg_find. Replay the script with extended log option "Data returned by server" to help to identify the piece of information to verify. If you decide to check on the text, the information could be in binary format, not as displayed in the Acrobat reader. If this is the case, then you can use the "/BIN" optioin to specify binary data.

2. Check the size of the download.
You can use the web_get_int_property() function with HTTP_INFO_DOWNLOAD_SIZE to check the size of the download is correct.

Example:
long i;

//Start a transaction to download the file.
lr_start_transaction("file_download");

//HTTP call to the .pdf file
web_url("");

//Get the download size.
i = web_get_int_property( HTTP_INFO_DOWNLOAD_SIZE );

//Check if the size if empty. If so, fail the transaction. You can set it to a specific number if you know the expected size.
if ( i == 0 ){
//End the transaction
lr_end_transaction("file_download", LR_FAIL);
}

else{
//End the transaction with passed status.
lr_end_transaction("file_download", LR_PASS);
}

3. Output the data to a file.
You can also output the data into a file (i.e., download the file, write it to the hard drive), then open it.

Example: (This is for a .pdf file.)
int fp;
long i;

//Truncate to zero length or create file for writing.
fp = fopen("c://my_file.pdf","wb");

//Start a transaction to time the download time.
lr_start_transaction("file_download");

//Set the parameter size large enough to save the data.
web_set_max_html_param_len("100000");

//Use web_reg_save_param with the correct boundary to capture the data returned by the server.
web_reg_save_param("FILED","LB=","RB=","Search=Body",LAST);

//HTTP call to the .pdf file
web_url("");

//Get the download size.
i = web_get_int_property( HTTP_INFO_DOWNLOAD_SIZE );

//Write the data saved to an output file.
fwrite(lr_eval_string("{FILED}"),i,1,fp);

//End the transaction
lr_end_transaction("file_download", LR_AUTO);

//Close the file pointer.
fclose(fp);

View solution in original post

7 Replies
Highlighted
Super Contributor.
Super Contributor.

Re: Vugen Check file downloaded

Jump to solution
Perform a text check on part of the binary or output the file to the machine

1. Text check with web_reg_find.
For example, if you have a .pdf file, you can verify the information by using the regular text check function web_reg_find. Replay the script with extended log option "Data returned by server" to help to identify the piece of information to verify. If you decide to check on the text, the information could be in binary format, not as displayed in the Acrobat reader. If this is the case, then you can use the "/BIN" optioin to specify binary data.

2. Check the size of the download.
You can use the web_get_int_property() function with HTTP_INFO_DOWNLOAD_SIZE to check the size of the download is correct.

Example:
long i;

//Start a transaction to download the file.
lr_start_transaction("file_download");

//HTTP call to the .pdf file
web_url("");

//Get the download size.
i = web_get_int_property( HTTP_INFO_DOWNLOAD_SIZE );

//Check if the size if empty. If so, fail the transaction. You can set it to a specific number if you know the expected size.
if ( i == 0 ){
//End the transaction
lr_end_transaction("file_download", LR_FAIL);
}

else{
//End the transaction with passed status.
lr_end_transaction("file_download", LR_PASS);
}

3. Output the data to a file.
You can also output the data into a file (i.e., download the file, write it to the hard drive), then open it.

Example: (This is for a .pdf file.)
int fp;
long i;

//Truncate to zero length or create file for writing.
fp = fopen("c://my_file.pdf","wb");

//Start a transaction to time the download time.
lr_start_transaction("file_download");

//Set the parameter size large enough to save the data.
web_set_max_html_param_len("100000");

//Use web_reg_save_param with the correct boundary to capture the data returned by the server.
web_reg_save_param("FILED","LB=","RB=","Search=Body",LAST);

//HTTP call to the .pdf file
web_url("");

//Get the download size.
i = web_get_int_property( HTTP_INFO_DOWNLOAD_SIZE );

//Write the data saved to an output file.
fwrite(lr_eval_string("{FILED}"),i,1,fp);

//End the transaction
lr_end_transaction("file_download", LR_AUTO);

//Close the file pointer.
fclose(fp);

View solution in original post

Highlighted
Absent Member.
Absent Member.

Re: Vugen Check file downloaded

Jump to solution
Thank's a lot LoadTest712
Works fine
Regards,
Marc
0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Vugen Check file downloaded

Jump to solution

Hello there,

 

Please  can you let me know a sample code for downloading an excel file.

0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Vugen Check file downloaded

Jump to solution

This really helps.

 

But can you please let me know How the downloaded file response time can be measured.

 

I am trying to perform Sharepoint 2013 file download as part of load testing.... and unable to find a way to measure file download response time using HP Loadrunner 12.01 ??  Please let me know if any code helps...

 

 

Thank you In advance.

Best Regards,

0 Likes
Highlighted
Frequent Contributor.. Frequent Contributor..
Frequent Contributor..

Re: Vugen Check file downloaded

Jump to solution

Awesome!!

0 Likes
Highlighted
Contributor.
Contributor.

Re: Vugen Check file downloaded

Jump to solution

Can you please let me know how we can do the same in TruClient protocol

0 Likes
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Re: Vugen Check file downloaded

Jump to solution

In TruClient protocol you can use the isExist API to check repeatedly for a file on disk, and that's how you can know when it has downloaded

IO.isExist(path[ string ]);

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.