【问题标题】:The count value is not getting saved to newly declared variable计数值未保存到新声明的变量中
【发布时间】:2020-03-01 14:09:20
【问题描述】:

已捕获 web_reg_save_param 并且计数值未保存到新声明的变量中。

我尝试过在全局和本地声明。

int ExsistingGoal;
char ParamName[50]; 
int i;

// {"id":"49F2DC5064524DC3962EE783959CA211","name":"Legacy Protection 1",


web_reg_save_param("c_ExsistingGoal","LB= 
     {\"id\":\"","RB=\",\"name\":\"","ORD=All",LAST);


web_add_header("Authorization:","Bearer {c_Token05}");

web_add_header("X-request-ID","8dd9e540-fa3c-11e9-8c6b-47e84a716a57");


web_url("goals_3", 
    "URL={pURL02}/wms/v1/plan/plans/{c_PlanID}/goals?entityId= {c_EntityID}", 
    "TargetFrame=", 
    "Resource=0", 
    "RecContentType=application/json", 
    "Referer={pURL02}/mwp/select-goals", 
    "Snapshot=t79.inf", 
    "Mode=HTML", 
    LAST);


ExsistingGoal= atoi(lr_eval_string("{c_ExsistingGoal_count}"));

c_ExsistingGoal_count 这个值应该被保存到变量中 ExsistingGoal.

但目前它正在显示一些随机值:153500656

【问题讨论】:

  • 您应该开始拆解该指令。 lr_eval_string 返回什么? c_ExsistingGoal_count 应该从哪里来?第一个“s”是错字吗?你的意思是c_ExistingGoal_count?顺便说一句:除了最后一个陈述之外,还有什么与您的问题有关吗?
  • c_ExsistingGoal --> 值是从请求中获取的 web_url("goals_3" web_reg_save_param(); 应该保存所有可能的值与我使用的左右边界相同 Ord=all O/P计数值应保存在贴花变量“ExsistingGoal”中。(lr_eval_string("{c_ExsistingGoal_count}") 应返回值:3
  • 我看到了很多“应该”。您是否验证了您的任何假设? lr_eval_string 返回什么?它返回一个字符串,还是NULL
  • 我可以回答 Gerhardh 的一些问题,值数组是由LaodRunner 服务函数 web_reg_save_param() 播种的,它充当一个筛子,通过它倾倒 HTML,LB 和 RB 条件定义什么被捕获。这会产生一个值数组,ORD=ALL 引用,_1 到 n。 n 的值存储在 _count 中。在这种情况下,参数名称是 c_ExsistingGoal。我最好的猜测是条件不会导致数组填充,它返回的是地址而不是值
  • 当您打开参数数据的日志记录时,在您进行转换和分配给 C 变量之前,您是否看到值被填充为数组的一部分

标签: c performance-testing loadrunner


【解决方案1】:

请使用下面的功能它会帮助你 -

web_reg_save_param("ExsistingGoal","LB=someText", "RB=\")", "Ord=ALL",LAST);

lr_output_message("PC:%d",atoi(lr_eval_string("{ExsistingGoal_count}")));

【讨论】:

    【解决方案2】:

    在我的 POV 中,James Pulley 回答了这个问题。 如果您在 web_reg_save_param 函数中使用 ORD=ALL。 LR 会将满足相关条件的计数保存在_count 中。如果您在这种情况下得到 153500656 的值,则表示 web_reg_save_param 函数关联了数组中的 153500656 个项目。

    //You can use the 1st correlated item
    ExsistingGoal_1= atoi(lr_eval_string("{c_ExsistingGoal_1"));
    
    //You can use the 153500656th correlated item
    ExsistingGoal_153500656= atoi(lr_eval_string("{c_ExsistingGoal_153500656"));
    
    //In frequently usage, you can judge flow by <paramname>_count, and output the specific <paramname>_<count>. 
    if(atoi(lr_eval_string("{c_ExsistingGoal_count}"))>0)
        {
            lr_output_message("c_ExsistingGoal_1=%s",lr_eval_string("{c_ExsistingGoal_1}"));        
            lr_end_transaction("Correlation Pass",LR_AUTO);
        }
        else
        {
            lr_end_transaction("Correlation Fail",LR_FAIL);
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-24
      • 1970-01-01
      • 2016-01-30
      • 1970-01-01
      • 2019-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多