loadrunner編寫下載文件

Action()
{
    int flen;
    long fileContent;
    char fileName[20]="";
    char *strNumber;

    web_set_max_html_param_len("40000");

    lr_start_transaction("xiazai");

    web_reg_save_param("fcontent",
        "LB=",
        "RB=",
        "Search=Body",
        LAST);

    web_url("exportReport",
        "URL=下載地址的url",
        "Resource=1",
        "RecContentType=application/msword",
        "Referer=",
        "Snapshot=t187.inf",
        LAST);

    flen=
    web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);

    strNumber=lr_eval_string( "{NewParam}" );

    strcat( fileName,
        "c:\\test\\" );

    strcat( fileName,
        strNumber );

    strcat( fileName,
        ".doc" );

    if(flen > 0)
    {
    fileContent=fopen( fileName,
        "wb" );

        if(fileContent == NULL){

    lr_end_transaction("xiazai", LR_FAIL);

return -1;

        }

    fwrite( lr_eval_string("{fcontent}"),
        flen,
        1,
        fileContent );

    fclose( fileContent );

    }

    lr_end_transaction("xiazai", LR_AUTO);

return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章