博客导读网

一个让你随便看看的地方

web test LoadRunner Solar

推荐
天行健 - Lindows

// lr_convert_string_encoding 在下列编码之间转换字符串编码:系统区域设置、Unicode 和 UTF-8。

// 该函数将结果字符串(包括其终止 // 结果字符串 NULL)保存在参数 paramName 中。

int lr_convert_string_encoding ( const char *sourceString, const char *fromEncoding, const char *toEncoding, const char *paramName);

// lr_output_message 函数将带有脚本部分和行号的消息 // 发送到输出窗口和日志文件。 int lr_output_message (const char * format, exp1, exp2,...expn.);

-- Sends a Vuser message to the log file and output window with location information.

// lr_log_message -- Sends a message to the Vuser log file.

// lr_message -- Sends a message to the log file and output window. 

// lr_save_string 函数将指定的以 null 终止的 // 字符串赋给参数。该函数可用于关联 // 查询。要确定参数值,请使用 // 函数 lr_eval_string。

int lr_save_string (const char *param_value, const char *param_name);

// lr_eval_string 函数在评估任何嵌入的参数之后 // 返回输入字符串。如果字符串 // 实参 (argument) 只包含一个形参 (parameter),该函数 // 返回形参的当前值。 char * lr_eval_string (const char * instring );

 

 

HP LoadRunner Online Function Reference > C Language Functions > Example: strcpy

// strcat 连接两个字符串。 char *strcat ( char *to, const char *from );

-- The following example uses strcat to append a backslash to the directory name, fullpath. It then appends filename to fullpath.

// strcpy 将一个字符串复制给另一个。 char *strcpy ( char *dest, const char *source );

-- The following example uses strcpy to copy the string "c:\\tmp" to the character array fullpath.

Action()
{
	 char fullpath[1024], *filename = "logfile.txt";

     strcpy(fullpath, "c:\\tmp");

	 lr_output_message("fullpath after strcpy: %s", fullpath);
	 strcat(fullpath, "\\");
     strcat(fullpath, filename);
     lr_output_message("Full path of file is %s", fullpath);
	 lr_output_message( "We are on iteration #%s", lr_eval_string( "{iteration}" ) );
	 lr_log_message( "We are on iteration #%s", lr_eval_string( "{iteration}" ) ); 

	 lr_output_message("111");
	 lr_log_message("222");
	 lr_message("333");

	return 0;
}
 

 

O utput:
Action.c(6): fullpath after strcpy: c:\tmp
Action.c(10): Full path of file is c:\tmp\logfile.txt

ReplayLog:

Virtual User Script started at : 2012-01-10 11:42:18
Starting action vuser_init.
Web Turbo Replay of LoadRunner 11.0.0 for Windows 7; build 8859 (Aug 18 2010 20:14:31)      [MsgId: MMSG-27143]
Run Mode: HTML      [MsgId: MMSG-26000]
Run-Time Settings file: "D:\dev_test\loadrunner_scripts\function_test\\default.cfg"      [MsgId: MMSG-27141]
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(7): fullpath after strcpy: c:\tmp
Action.c(12): Full path of file is c:\tmp\logfile.txt
Action.c(13): We are on iteration #{iteration}
We are on iteration #{iteration}
Action.c(16): 111
222
333
Ending action Action.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.

 

 

Action()
{
   int i;
   for(i=0;i<10;i++)
   {
 
   char tmp1[100];
 
 
   lr_convert_string_encoding( lr_eval_string("{KeyWord}"),
    LR_ENC_SYSTEM_LOCALE,
    LR_ENC_UTF8,
    "EncodedSearchTerm" );
   

   strcpy( tmp1, lr_eval_string("{EncodedSearchTerm}") );
    lr_save_string( tmp1, "sorvalue_book" );
   


    web_url("SNGetKeywordCmd",
        "URL=http://b2cpre.********.com/emall/SNGetKeywordCmd?keyWord={sorvalue_book}",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=http://b2cpre.********.com/",
        "Snapshot=t4.inf",
        "Mode=HTML",
        LAST);

/*
...............................

*/

    return 0;

    }

}
 

 


LoadRunner lr_eval_string() 函数使用及LR中变量、参数的简单使用

http://blog.csdn.net/oobibigo/article/details/3321558

lr_eval_string()

函数的主要作用:返回脚本中的一个参数当前的值,

返回值类型:char

一般多用在调试脚本时输出参数的值.具体用法如下:
lr_output_message("The parameter1's value is %s",lr_eval_string("{parameter1}")),其中参数parameter1在之前已经定义了的参数

lr_log_message(lr_eval_string("{parameter1}"))

 

1.参数的赋值和取值

lr_save_string("hello world","param");
lr_eval_string("{param}");
2.变量到参数
int x;
x=10;
lr_save_string(x,"param");
lr_eval_string("{param}");
3.变量读参数
char x[100];
x="{param}";
lr_save_string("hello world","param");
lr_eval_string(x);

end



已有 0 人发表留言,猛击->>这里<<-参与讨论


ITeye推荐



原文地址:http://lindows.iteye.com/blog/1338893

天行健 - Lindows的其他文章
my ReadBook_4juan my ReadBook_guanlixinxixitong / 02382
my ReadBook_guanlixueyuanli / 00054 my ReadBook_zhongguowenhuagailun / 00321
my ReadBook_dianzishangwu / 2020216 my soft_AndroidSoft
db vfp / Visual FoxPro my ReadBook_liutongjingjixue / circulation economics
my ReadBook_wangluoyingxiaoyucehua / network marketing db base database
更多...

© 2010 博客导读网 BlogABC.NET 本站所有内容皆由网友推荐而来,所有博文的版权归原作者所有,如有冒犯,请邮件告知。uncracker#gmail.com