首页 > 解决方案 > 如何在 web_reg_find 中使用 if 条件

问题描述

如何将 if 条件与web_reg_find 合并

例如

if
{

web_reg_find("Search=Body", "Text=Launch Title",    LAST);
 //----Passes
    {
  printf("%d\n", login successful);  /* user will login
}
 }

Else 
{

printf("%d\n", login not successful);  /* user will not login

}

代码结束

标签: loadrunner

解决方案


我会建议使用 web reg find 函数的 savecount 属性,它会保存在页面上找到文本的次数。

web_reg_find("Text=Welcome","SaveCount=Welcome_Count",LAST );
.........
......
if (atoi(lr_eval_string("{Welcome_Count}")) > 0){
        lr_output_message("Login successful.");
  }

 else{
     lr_error_message("Login failed");
     return(0);
   }

推荐阅读