|
本帖最后由 jylizhihui 于 2017-7-10 14:05 编辑
测试软件为:LoadRunner Software 11.00
lr_save_string将"hello world"参数化为ParamTest1后无法用lr_eval_string取出参数ParamTest1的值hello world,日志中打印出来的值为参数名ParamTest1。
请问该如何才能取出参数{ParamTest1}的值hello world,并在日志中打印出来?试了几种情况都无效。
情形一
脚本如下:
Action()
{
lr_start_transaction("Test");
lr_think_time(2);
lr_save_string("hello world","{ParamTest1}");
lr_log_message("~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~");
lr_log_message("The value of {ParamTest1} is: %s ! ",lr_eval_string("{ParamTest1}"));
lr_log_message("~~~~~~~~~~~~~ End ~~~~~~~~~~~~~");
lr_end_transaction("Test",LR_AUTO);
return 0;
}
日志如下:
Starting iteration 1. [MsgId: MMSG-15968]
Starting action Action. [MsgId: MMSG-15919]
Action.c(12): Notify: Transaction "Test" started. [MsgId: MMSG-16999]
Action.c(13): lr_think_time: 2.00 seconds. [MsgId: MMSG-15948]
Action.c(14): Notify: Saving Parameter "{ParamTest1} = hello world". [MsgId: MMSG-13798]
~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
The value of {ParamTest1} is: {ParamTest1} ! [MsgId: MMSG-17999]
~~~~~~~~~~~~~ End ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
Action.c(20): Notify: Transaction "Test" ended with "Pass" status (Duration: 2.0008 Think Time: 2.0002). [MsgId: MMSG-16872]
Ending action Action. [MsgId: MMSG-15918]
Ending iteration 1. [MsgId: MMSG-15965]
情形二
脚本如下:
Action()
{
lr_start_transaction("Test");
lr_think_time(2);
lr_save_string("hello world","{ParamTest1}");
lr_log_message("~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~");
lr_log_message("The value of \"ParamTest1\" is: %s ! ",lr_eval_string("ParamTest1"));
lr_log_message("~~~~~~~~~~~~~ End ~~~~~~~~~~~~~");
lr_end_transaction("Test",LR_AUTO);
return 0;
}
日志如下:
Starting iteration 1. [MsgId: MMSG-15968]
Starting action Action. [MsgId: MMSG-15919]
Action.c(12): Notify: Transaction "Test" started. [MsgId: MMSG-16999]
Action.c(13): lr_think_time: 2.00 seconds. [MsgId: MMSG-15948]
Action.c(14): Notify: Saving Parameter "{ParamTest1} = hello world". [MsgId: MMSG-13798]
~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
The value of "ParamTest1" is: ParamTest1 ! [MsgId: MMSG-17999]
~~~~~~~~~~~~~ End ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
Action.c(20): Notify: Transaction "Test" ended with "Pass" status (Duration: 2.0070 Think Time: 2.0063). [MsgId: MMSG-16872]
Ending action Action. [MsgId: MMSG-15918]
Ending iteration 1. [MsgId: MMSG-15965]
情形三
脚本如下:
Action()
{
lr_start_transaction("Test");
lr_think_time(2);
lr_save_string("hello world","ParamTest1");
lr_log_message("~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~");
lr_log_message("The value of {ParamTest1} is: %s ! ",lr_eval_string("{ParamTest1}"));
lr_log_message("~~~~~~~~~~~~~ End ~~~~~~~~~~~~~");
lr_end_transaction("Test",LR_AUTO);
return 0;
}
日志如下:
Starting iteration 1. [MsgId: MMSG-15968]
Starting action Action. [MsgId: MMSG-15919]
Action.c(12): Notify: Transaction "Test" started. [MsgId: MMSG-16999]
Action.c(13): lr_think_time: 2.00 seconds. [MsgId: MMSG-15948]
Action.c(15): Notify: Saving Parameter "ParamTest1 = hello world". [MsgId: MMSG-13798]
~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
The value of {ParamTest1} is: {ParamTest1} ! [MsgId: MMSG-17999]
~~~~~~~~~~~~~ End ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
Action.c(20): Notify: Transaction "Test" ended with "Pass" status (Duration: 2.0036 Think Time: 2.0029). [MsgId: MMSG-16872]
Ending action Action. [MsgId: MMSG-15918]
Ending iteration 1. [MsgId: MMSG-15965]
情形四
脚本如下:
Action()
{
lr_start_transaction("Test");
lr_think_time(2); //lr_save_string("hello world","{ParamTest1}");
lr_save_string("hello world","ParamTest1");
lr_log_message("~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~");
lr_log_message("The value of \"ParamTest1\" is: %s ! ",lr_eval_string("ParamTest1"));
lr_log_message("~~~~~~~~~~~~~ End ~~~~~~~~~~~~~");
lr_end_transaction("Test",LR_AUTO);
return 0;
}
日志如下:
Starting iteration 1. [MsgId: MMSG-15968]
Starting action Action. [MsgId: MMSG-15919]
Action.c(12): Notify: Transaction "Test" started. [MsgId: MMSG-16999]
Action.c(13): lr_think_time: 2.00 seconds. [MsgId: MMSG-15948]
Action.c(15): Notify: Saving Parameter "ParamTest1 = hello world". [MsgId: MMSG-13798]
~~~~~~~~~~~~~ Begin ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
The value of "ParamTest1" is: ParamTest1 ! [MsgId: MMSG-17999]
~~~~~~~~~~~~~ End ~~~~~~~~~~~~~ [MsgId: MMSG-17999]
Action.c(20): Notify: Transaction "Test" ended with "Pass" status (Duration: 2.0142 Think Time: 2.0133). [MsgId: MMSG-16872]
Ending action Action. [MsgId: MMSG-15918]
Ending iteration 1. [MsgId: MMSG-15965]
|
|