LoadRunner Performance Test-download file script

Source: Internet
Author: User

LoadRunner download file script

 

Action ()

{

Intflen; // define an integer variable to save and obtain the file size

Longfiledes; // save the file handle

Charfile [256] = "\ 0"; // save the file path and file name

Inttime;

 

// Set the maximum number of bytes received on the page. This setting should be larger than the size of the downloaded file. The value here is 1 MB.

Web_set_max_html_param_len ("1024000 ");

 

// Use the correlated function to obtain the downloaded object content

Web_reg_save_param_ex (

"Paramname = filecontent ",

"LB = ",

"RB = ",

Search_filters,

"Scope = body ",

"Requesturl = http: // 10.20.0.145/download. php? Userid = {userid} & bigmd5 = {userid} & offset = 0 ",

Last );

 

// Download an object

Lr_start_transaction ("Download ");

Web_url ("Download ",

"Url = http: // 10.20.0.145/download. php? Userid = {userid} & bigmd5 = {userid} & offset = 0 ",

Resource = 1 ",

"Reccontenttype = application/octet-stream ",

"Referer = ",

Last );

Lr_end_transaction ("Download", lr_auto );

 

/* Web_get_int_property returns the specific information of the previous HTTP request, such as http_info_download_size, http_info_download_time, http_info_return_code */

 

FLEN = web_get_int_property (http_info_download_size );

Lr_output_message ("download file size: % d", FLEN );

Time = web_get_int_property (http_info_download_time );

Lr_output_message ("download time: % d", time );

// Write the string "E: \ fsdownload \ % d.txt" to file.

Sprintf (file, "E: \ fsdownload \ % d.txt", Rand ());

Lr_output_message ("saved path: % s", file );

 

If (FLEN> 0 ){

If (filedes = fopen (file, "WB") = NULL ){

Lr_output_message ("openfile failed! ", Lr_eval_string (" {filecontent }"));

Return-1;

}

// Write filecontent to the file pointed by the filedes pointer, write FLEN each time, write once

Fwrite (lr_eval_string ("{filecontent}"), FLEN, 1, filedes );

Fclose (filedes );

}

Return0;

}


This article is from the "Swallow swallow test column" blog, please be sure to keep this source http://bobbleyan.blog.51cto.com/9111528/1568505

LoadRunner Performance Test-download file script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.