2017-12-15 22 views
-1

ファイル操作部で何が間違っていますか?ファイルを作成していません。私は、2つまたは3つのレベルの深いフォルダ構造だけでなく、Dドライブだけでなく、Cドライブにファイルパスを入れようとしました。しかし、何らかの形でファイルが作成されていません。LoadRunnerファイル操作部で何が問題なのですか?

ファイルに入れようとしているすべての値が適切に生成されています。出力メッセージを出力して確認するために使用しています。

include <stdio.h> 
Action() 
{ 

int i; 
int imax; 
int rand1; 
char newVarName[500]; 
FILE* file_stream; 
char * filename = "d:\\RouteDetails.txt"; 

web_set_sockets_option("SSL_VERSION", "2&3"); 

web_set_max_html_param_len("32000"); 


web_set_user("CTS.COM\\180937", 
    lr_unmask("5a2f9911b093f34e3f8ca40aa7064d"), 
    "transport.xyz.com:443"); 

lr_start_transaction("Launch"); 

web_url("transport.xyz.com", 
    "URL=https://transport.xyz.com/", 
    "Resource=0", 
    "RecContentType=text/html", 
    "Referer=", 
    "Snapshot=t3.inf", 
    "Mode=HTML", 
    EXTRARES, 
    "Url=/IMAGES/banner_bg.jpg", 
"Referer=https://transport.xyz.com/AssociateHome.aspx", ENDITEM, 
    LAST); 

lr_end_transaction("Launch",LR_AUTO); 

lr_think_time(3); 

//********************************************************************************************************** 

lr_start_transaction("searchSchedule"); 

web_reg_save_param_attrib(
    "ParamName=__VIEWSTATEGENERATOR", 
    "TagName=input", 
    "Extract=value", 
    "Name=__VIEWSTATEGENERATOR", 
    "Id=__VIEWSTATEGENERATOR", 
    "Type=hidden", 
    SEARCH_FILTERS, 
    "IgnoreRedirections=No", 
    "RequestUrl=*/SearchService.aspx*", 
    LAST); 
web_reg_save_param_attrib(
    "ParamName=__VIEWSTATE", 
    "TagName=input", 
    "Extract=value", 
    "Name=__VIEWSTATE", 
    "Id=__VIEWSTATE", 
    "Type=hidden", 
    SEARCH_FILTERS, 
    "IgnoreRedirections=No", 
    "RequestUrl=*/SearchService.aspx*", 
    LAST); 

web_reg_save_param_attrib(
    "ParamName=__EVENTVALIDATION", 
    "TagName=input", 
    "Extract=value", 
    "Name=__EVENTVALIDATION", 
    "Id=__EVENTVALIDATION", 
    "Type=hidden", 
    SEARCH_FILTERS, 
    "IgnoreRedirections=No", 
    "RequestUrl=*/SearchService.aspx*", 
    LAST); 


web_link("Search Schedule", 
    "Text=Search Schedule", 
    "Ordinal=1", 
    "Snapshot=t4.inf", 
    EXTRARES, 
    "Url=/WebResource.axd? 
d=rcIyG2OcW8Jw0dVKAHKouB_qi7orHpXPRHHowC57SH37biy2txFUrKGEIgh8UEtEt0jJ- 
7enVMK28-Wwz3rF2yEmfcDrzHeufqr4EpqK9Wo1&t=635418424260000000", ENDITEM, 
    "Url=/WebResource.axd? 
d=hJgAHOWKmtlJ94s8P0gxTiQFUJpgzvWtwuVazXJ6sglaRQpqxuuT_S8s8fI7pyvl9Ckw2lX8f 
1RaAi6-WLJEDtCkNXEaqZWMG0FmPRYC9oQ1&t=635418424260000000", ENDITEM, 
    "Url=/Images/home_icon.jpg", ENDITEM, 
    "Url=/IMAGES/ss_ord.gif", ENDITEM, 
    "Url=/IMAGES/ms_over.gif", ENDITEM, 
    "Url=/IMAGES/ts_ord.gif", ENDITEM, 
    "Url=/IMAGES/rls_ord.gif", ENDITEM, 
    "Url=/IMAGES/es_ord.gif", ENDITEM, 
    LAST); 

lr_end_transaction("searchSchedule",LR_AUTO); 

//************************************************************************** 

lr_start_transaction("select boardingPoint"); 

web_url("GetBoardingPoints.aspx", 
    "URL=https://transport.xyz.com/GetBoardingPoints.aspx? 
id=BoardingPoint_idMs&name=txtBoardingpointNameMs&city_id=1", 
    "Resource=0", 
    "RecContentType=text/html", 
    "Referer=", 
    "Snapshot=t5.inf", 
    "Mode=HTML", 
    LAST); 

lr_end_transaction("select boardingPoint",LR_AUTO); 

//************************************************************************** 

lr_start_transaction("Search1"); 



web_reg_save_param_attrib(
    "ParamName=__VIEWSTATEGENERATOR", 
    "TagName=input", 
    "Extract=value", 
    "Name=__VIEWSTATEGENERATOR", 
    "Id=__VIEWSTATEGENERATOR", 
    "Type=hidden", 
    SEARCH_FILTERS, 
    "IgnoreRedirections=No", 
    "RequestUrl=*/SearchService.aspx*", 
    LAST); 
web_reg_save_param_attrib(
    "ParamName=__VIEWSTATE", 
    "TagName=input", 
    "Extract=value", 
    "Name=__VIEWSTATE", 
    "Id=__VIEWSTATE", 
    "Type=hidden", 
    SEARCH_FILTERS, 
    "IgnoreRedirections=No", 
    "RequestUrl=*/SearchService.aspx*", 
    LAST); 

web_reg_save_param_attrib(
    "ParamName=__EVENTVALIDATION", 
    "TagName=input", 
    "Extract=value", 
    "Name=__EVENTVALIDATION", 
    "Id=__EVENTVALIDATION", 
    "Type=hidden", 
    SEARCH_FILTERS, 
    "IgnoreRedirections=No", 
    "RequestUrl=*/SearchService.aspx*", 
    LAST); 



web_reg_save_param("RouteNo", "LB=<a href='javascript:OpenRouteMap(", 
"RB=,", LAST);   ////<a href='javascript:OpenRouteMap(

web_submit_data("SearchService.aspx", 
    "Action=https://transport.xyz.com/SearchService.aspx", 
    "Method=POST", 
    "RecContentType=text/html", 
    "Referer=https://transport.xyz.com/SearchService.aspx", 
    "Snapshot=t6.inf", 
    "Mode=HTML", 
    ITEMDATA, 
    "Name=__EVENTTARGET", "Value=", ENDITEM, 
    "Name=__EVENTARGUMENT", "Value=", ENDITEM, 
    "Name=__LASTFOCUS", "Value=", ENDITEM, 
    "Name=__VIEWSTATE", "Value={__VIEWSTATE}", ENDITEM, 
    "Name=__VIEWSTATEGENERATOR", "Value={__VIEWSTATEGENERATOR}", ENDITEM, 
    "Name=__EVENTVALIDATION", "Value={__EVENTVALIDATION}", ENDITEM, 
    "Name=ddlCityMs", "Value=1", ENDITEM, 
    "Name=txtBoardingpointNameMs", "Value=Adyar Depot", ENDITEM, 
    "Name=ddlMsEndLocation", "Value=135", ENDITEM, 
    "Name=btnMsSearch", "Value=Search", ENDITEM, 
    "Name=BoardingPoint_idMs", "Value=358", ENDITEM, 
    "Name=BoardingPoint_idEs", "Value=", ENDITEM, 
    EXTRARES, 
    "URL=/IMAGES/ts_ord_over.gif", ENDITEM, 
    LAST); 

lr_end_transaction("Search1",LR_AUTO); 
lr_think_time(3); 

//************************************************************* 

lr_start_transaction("GotoTimeBasedSearchTab"); 

web_reg_save_param_attrib(
    "ParamName=__VIEWSTATEGENERATOR", 
    "TagName=input", 
    "Extract=value", 
    "Name=__VIEWSTATEGENERATOR", 
    "Id=__VIEWSTATEGENERATOR", 
    "Type=hidden", 
    SEARCH_FILTERS, 
    "IgnoreRedirections=No", 
    "RequestUrl=*/SearchService.aspx*", 
    LAST); 
web_reg_save_param_attrib(
    "ParamName=__VIEWSTATE", 
    "TagName=input", 
    "Extract=value", 
    "Name=__VIEWSTATE", 
    "Id=__VIEWSTATE", 
    "Type=hidden", 
    SEARCH_FILTERS, 
    "IgnoreRedirections=No", 
    "RequestUrl=*/SearchService.aspx*", 
    LAST); 

web_reg_save_param_attrib(
    "ParamName=__EVENTVALIDATION", 
    "TagName=input", 
    "Extract=value", 
    "Name=__EVENTVALIDATION", 
    "Id=__EVENTVALIDATION", 
    "Type=hidden", 
    SEARCH_FILTERS, 
    "IgnoreRedirections=No", 
    "RequestUrl=*/SearchService.aspx*", 
    LAST); 

web_submit_data("SearchService.aspx_2", 
    "Action=https://transport.xyz.com/SearchService.aspx", 
    "Method=POST", 
    "RecContentType=text/html", 
    "Referer=https://transport.xyz.com/SearchService.aspx", 
    "Snapshot=t7.inf", 
    "Mode=HTML", 
    ITEMDATA, 
    "Name=__EVENTTARGET", "Value=", ENDITEM, 
    "Name=__EVENTARGUMENT", "Value=", ENDITEM, 
    "Name=__LASTFOCUS", "Value=", ENDITEM, 
    "Name=__VIEWSTATE", "Value={__VIEWSTATE}", ENDITEM, 
    "Name=__VIEWSTATEGENERATOR", "Value={__VIEWSTATEGENERATOR}", ENDITEM, 
    "Name=__EVENTVALIDATION", "Value={__EVENTVALIDATION}", ENDITEM, 
    "Name=ddlCityMs", "Value=1", ENDITEM, 
    "Name=txtBoardingpointNameMs", "Value=Adyar Depot", ENDITEM, 
    "Name=ddlMsEndLocation", "Value=135", ENDITEM, 
    "Name=BoardingPoint_idMs", "Value=358", ENDITEM, 
    "Name=BoardingPoint_idEs", "Value=", ENDITEM, 
    "Name=ibts.x", "Value=131", ENDITEM, 
    "Name=ibts.y", "Value=10", ENDITEM, 
    EXTRARES, 
    "URL=/IMAGES/ms_ord.gif", ENDITEM, 
    "URL=/IMAGES/ts_over.gif", ENDITEM, 
    LAST); 

web_reg_save_param_attrib(
    "ParamName=__VIEWSTATEGENERATOR", 
    "TagName=input", 
    "Extract=value", 
    "Name=__VIEWSTATEGENERATOR", 
    "Id=__VIEWSTATEGENERATOR", 
    "Type=hidden", 
    SEARCH_FILTERS, 
    "IgnoreRedirections=No", 
    "RequestUrl=*/SearchService.aspx*", 
    LAST); 
web_reg_save_param_attrib(
    "ParamName=__VIEWSTATE", 
    "TagName=input", 
    "Extract=value", 
    "Name=__VIEWSTATE", 
    "Id=__VIEWSTATE", 
    "Type=hidden", 
    SEARCH_FILTERS, 
    "IgnoreRedirections=No", 
    "RequestUrl=*/SearchService.aspx*", 
    LAST); 

web_reg_save_param_attrib(
    "ParamName=__EVENTVALIDATION", 
    "TagName=input", 
    "Extract=value", 
    "Name=__EVENTVALIDATION", 
    "Id=__EVENTVALIDATION", 
    "Type=hidden", 
    SEARCH_FILTERS, 
    "IgnoreRedirections=No", 
    "RequestUrl=*/SearchService.aspx*", 
    LAST); 

web_submit_data("SearchService.aspx_3", 
    "Action=https://transport.xyz.com/SearchService.aspx?param_id=5", 
    "Method=POST", 
    "RecContentType=text/html", 
    "Referer=https://transport.xyz.com/SearchService.aspx", 
    "Snapshot=t8.inf", 
    "Mode=HTML", 
    ITEMDATA, 
    "Name=__EVENTTARGET", "Value=ddlTsStartLocation", ENDITEM, 
    "Name=__EVENTARGUMENT", "Value=", ENDITEM, 
    "Name=__LASTFOCUS", "Value=", ENDITEM, 
    "Name=__VIEWSTATE", "Value={__VIEWSTATE}", ENDITEM, 
    "Name=__VIEWSTATEGENERATOR", "Value={__VIEWSTATEGENERATOR}", ENDITEM, 
    "Name=__EVENTVALIDATION", "Value={__EVENTVALIDATION}", ENDITEM, 
    "Name=ddlCityTs", "Value=1", ENDITEM, 
    "Name=ddlTsStartLocation", "Value=135", ENDITEM, 
    "Name=BoardingPoint_idMs", "Value=", ENDITEM, 
    "Name=BoardingPoint_idEs", "Value=", ENDITEM, 
    LAST); 
lr_end_transaction("GotoTimeBasedSearchTab",LR_AUTO); 

//******************** 

    lr_think_time(3); 


//**************************** 

lr_start_transaction("Search_TimeBased"); 


web_reg_save_param("RouteDetail", "LB=<td align=\"left\">", "RB=</td", 
"ORD=ALL", LAST); 

web_submit_data("SearchService.aspx_4", 
    "Action=https://transport.xyz.com/SearchService.aspx?param_id=5", 
    "Method=POST", 
    "RecContentType=text/html", 
    "Referer=https://transport.xyz.com/SearchService.aspx?param_id=5", 
    "Snapshot=t9.inf", 
    "Mode=HTML", 
    ITEMDATA, 
    "Name=__EVENTTARGET", "Value=", ENDITEM, 
    "Name=__EVENTARGUMENT", "Value=", ENDITEM, 
    "Name=__LASTFOCUS", "Value=", ENDITEM, 
    "Name=__VIEWSTATE", "Value={__VIEWSTATE}", ENDITEM, 
    "Name=__VIEWSTATEGENERATOR", "Value={__VIEWSTATEGENERATOR}", ENDITEM, 
    "Name=__EVENTVALIDATION", "Value={__EVENTVALIDATION}", ENDITEM, 
    "Name=ddlCityTs", "Value=1", ENDITEM, 
    "Name=ddlTsStartLocation", "Value=135", ENDITEM, 
    "Name=ddlTsTime", "Value=ALL", ENDITEM, 
    "Name=btnTsList", "Value=Search", ENDITEM, 
    "Name=BoardingPoint_idMs", "Value=", ENDITEM, 
    "Name=BoardingPoint_idEs", "Value=", ENDITEM, 
    LAST); 

lr_end_transaction("Search_TimeBased",LR_AUTO); 

file_stream = fopen(filename, "w"); 

imax= atoi(lr_eval_string("{RouteDetail_count}")); 
lr_output_message("count is %d", imax); 

for(i=1;i<=imax;i++) { 

    sprintf(newVarName, "{RouteDetail_%d}", i); 
    lr_output_message("string is %s", newVarName); 

    lr_save_string(lr_eval_string(newVarName), "stringtowrite"); 

    fprintf(file_stream,"%s,\n", lr_eval_string("{stringtowrite}")); 

} 

fclose(file_stream); 

//**************************** 

lr_think_time(3); 

lr_start_transaction("ClickRoute"); 

web_url("ShowRouteMap.aspx", 
    "URL=https://transport.xyz.com/ShowRouteMap.aspx?RouteNo={RouteNo}", 
    "Resource=0", 
    "RecContentType=text/html", 
    "Referer=", 
    "Snapshot=t10.inf", 
    "Mode=HTML", 
    LAST); 

lr_end_transaction("ClickRoute",LR_AUTO); 

lr_think_time(3); 
//*************************** 

lr_start_transaction("GoHome1"); 

web_url("AssociateHome.aspx", 
    "URL=https://transport.xyz.com/AssociateHome.aspx", 
    "Resource=0", 
    "RecContentType=text/html", 
    "Referer=https://transport.xyz.com/SearchService.aspx?param_id=5", 
    "Snapshot=t11.inf", 
    "Mode=HTML", 
    LAST); 

lr_end_transaction("GoHome1",LR_AUTO); 

lr_think_time(3); 
//***************************** 
for (i=1; i<=5; i++){ 


lr_start_transaction("SMSShortCodeList"); 

web_reg_save_param("RandomLetter", "LB=aspx?Letter=", "RB=&", "ORD=ALL", 
LAST);     //.aspx?Letter=A& 

web_link("Short Code list", 
    "Text=Short Code list", 
    "Snapshot=t12.inf", 
    EXTRARES, 
    "Url=/IMAGES/BPHELP.bmp", ENDITEM, 
    LAST); 

lr_end_transaction("SMSShortCodeList",LR_AUTO); 

lr_think_time(3); 

//*************************** 

lr_start_transaction("ClickALetter"); 


rand1 = (rand() % atoi(lr_eval_string("{RandomLetter_count}")) + 1);     
//Find out a rand no between 1 and count 
sprintf(newVarName, "{RandomLetter_%d}", rand1); 
lr_output_message("newVarName is %s", lr_eval_string(newVarName)); 
lr_save_string(lr_eval_string(newVarName), "newRandLetter"); 


web_url("BoardingPtShortCodeDisplay.aspx", 
    "URL=https://transport.xyz.com/BoardingPtShortCodeDisplay.aspx?Letter= 
{newRandLetter}&City=1", 
    "Resource=0", 
    "RecContentType=text/html", 
    "Referer=https://transport.xyz.com/BoardingPtShortCodeDisplay.aspx", 
    "Snapshot=t13.inf", 
    "Mode=HTML", 
    LAST); 

lr_end_transaction("ClickALetter",LR_AUTO); 

lr_think_time(3); 

} 

//end For loop 

//****************************** 

lr_start_transaction("GoHome2"); 

web_url("AssociateHome.aspx_2", 
    "URL=https://transport.xyz.com/AssociateHome.aspx", 
    "Resource=0", 
    "RecContentType=text/html", 
    "Referer=https://transport.xyz.com/BoardingPtShortCodeDisplay.aspx? 
Letter=R&City=1", 
    "Snapshot=t14.inf", 
    "Mode=HTML", 
    LAST); 

lr_end_transaction("GoHome2",LR_AUTO); 

lr_think_time(3); 
//********************************************************************************************************** 

lr_start_transaction("Logout"); 

web_link("Logout", 
    "Text=Logout", 
    "Snapshot=t15.inf", 
    LAST); 

lr_end_transaction("Logout",LR_AUTO); 
//**************************** 

return 0; 

}

+0

なぜデータを書き出すのか説明してください。あなたの目標を達成するためのより良い方法があります。このモデルと複数のユーザーの場合、複数のユーザーが排他的な書き込みハンドルを待つため、ローカルファイルシステムをドラッグアンカーにする可能性が高くなります。 –

答えて

0

file_streamがnullの場合、なぜあなたはチェックしませんか?

を含める:

#include <errno.h> 
#include <stdio.h> 

は先頭に追加:

err = fopen_s(&file_stream, filename, "w"); 
if (err != 0) 
{ 
    lr_output_message("Failed to open file (%s)",strerror(errno)); 
    lr_exit(LR_EXIT_VUSER, LR_FAIL); 
} 

これは正確にエラーが表示されます:int err; ファイルを開く方法を変更します。

関連する問題