loadRunner函数之web_find

int web_find( const char *StepName, <Attributes and Specifications list>, char *searchstring, LAST );

StepName:步骤名称,必选

Attributes and Specifications list:属性列表,可选

expect:定义返回成功的标准,found(默认)-表示找到字符串返回成功,notfound-表示未找到字符串返回成功

Matchcase:是否区分大小写,yes-表示区分大小写,no(默认)-表示不区分大小写

report:定义结果报告的内容,success-只包含成功,failure-只包含失败,always(默认)-包含所有

onfailure=abort:失败则终止脚本运行

RightOf:从指定字符串的右边开始查找

LeftOf:从指定字符串的左边开始查找

searchstring:查找的字符串,格式为:"What=stringxyz",必选

LAST:结束标记,必选

WebTours登录后页面展示的内容:

Welcome, jojo, to the Web Tours reservation pages.

Using the menu to the left, you can search for new flights to book, or review/edit the flights already booked. Don‘t forget to sign off when you‘re done!

1、web_find之expect属性:

Action()
{ 

    web_url("WebTours",
        "URL=http://127.0.0.1:1080/WebTours/",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t34.inf",
        "Mode=HTML",
        EXTRARES,
        "Url=../favicon.ico", "Referer=", ENDITEM,
        LAST); 

    web_submit_form("login.pl",
        "Snapshot=t35.inf",
        ITEMDATA,
        "Name=username", "Value=jojo", ENDITEM,
        "Name=password", "Value=bean", ENDITEM,
        "Name=login.x", "Value=52", ENDITEM,
        "Name=login.y", "Value=11", ENDITEM,
        LAST); 

    web_find("web_find",
        //期望返回成功的结果是找到字符串,因当前页面包含要查找的字符串,故返回结果是成功
        "expect=found",
        //当前页面中查找字符串"jojo"
        "What=jojo",
        LAST); 

    web_find("web_find",
        //期望返回成功的结果是未找到字符串,因当前页面包含要查找的字符串,故返回结果是失败
        "expect=notfound",
        //当前页面中查找字符串"jojo"
        "What=jojo",
        LAST); 

    return 0;
} 

代码执行结果:

Action.c(24): "web_find" successful. 1 occurrence(s) of "jojo" found (RightOf="", LeftOf="")   [MsgId: MMSG-27196]

Action.c(24): web_find was successful   [MsgId: MMSG-26392]

Action.c(31): Error -27195: "web_find" failed. 1 occurrence(s) of "jojo" found (RightOf="", LeftOf="")   [MsgId: MERR-27195]

Action.c(31): web_find highest severity level was "ERROR"   [MsgId: MMSG-26391]

2、web_find之Matchcase属性:

Action()
{ 

    web_url("WebTours",
        "URL=http://127.0.0.1:1080/WebTours/",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t34.inf",
        "Mode=HTML",
        EXTRARES,
        "Url=../favicon.ico", "Referer=", ENDITEM,
        LAST); 

    web_submit_form("login.pl",
        "Snapshot=t35.inf",
        ITEMDATA,
        "Name=username", "Value=jojo", ENDITEM,
        "Name=password", "Value=bean", ENDITEM,
        "Name=login.x", "Value=52", ENDITEM,
        "Name=login.y", "Value=11", ENDITEM,
        LAST); 

    web_find("web_find",
        //区分大小写,因当前页面不包含JOJO,故返回结果是失败
        "Matchcase=yes",
        //当前页面中查找字符串"JOJO"
        "What=JOJO",
        LAST); 

    web_find("web_find",
        //不区分大小写,因当前页面包含jojo,故返回结果是成功
        "Matchcase=no",
        //当前页面中查找字符串"JOJO"
        "What=JOJO",
        LAST); 

    return 0;
}  

代码执行结果:

Action.c(24): Continuing after Error -27195: "web_find" failed. 0 occurrence(s) of "JOJO" found (RightOf="", LeftOf="")   [MsgId: MERR-27195]

Action.c(24): web_find highest severity level was "continue on error"   [MsgId: MMSG-26391]

Action.c(24): Continuing after error in Vuser script.

Action.c(31): "web_find" successful. 1 occurrence(s) of "JOJO" found (RightOf="", LeftOf="")   [MsgId: MMSG-27196]

Action.c(31): web_find was successful   [MsgId: MMSG-26392]

3、web_find之onfailure属性:

Action()
{ 

    web_url("WebTours",
        "URL=http://127.0.0.1:1080/WebTours/",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t34.inf",
        "Mode=HTML",
        EXTRARES,
        "Url=../favicon.ico", "Referer=", ENDITEM,
        LAST); 

    web_submit_form("login.pl",
        "Snapshot=t35.inf",
        ITEMDATA,
        "Name=username", "Value=jojo", ENDITEM,
        "Name=password", "Value=bean", ENDITEM,
        "Name=login.x", "Value=52", ENDITEM,
        "Name=login.y", "Value=11", ENDITEM,
        LAST); 

    web_find("web_find",
        //如果函数返回结果失败,则终止脚本运行,根据运行结果可以发现,第二个web_find没有运行
        //注意:Continue on Error 设置了才能看到效果,否则的话,不管是否有该属性都会终止运行
        "onfailure=abort",
        //当前页面中查找字符串"JOJO"
        "What=jojo1",
        LAST); 

    web_find("web_find",
        //当前页面中查找字符串"JOJO"
        "What=jojo",
        LAST); 

    return 0;
}  

代码运行结果:

Action.c(24): Fatal Error -27195: "web_find" failed. 0 occurrence(s) of "jojo1" found (RightOf="", LeftOf="")   [MsgId: MERR-27195]

Action.c(24): web_find highest severity level was "FATAL ERROR"   [MsgId: MMSG-26391]

Abort was called from an action.

4、web_find之LeftOf、RightOf属性:

Action()
{ 

    web_url("WebTours",
        "URL=http://127.0.0.1:1080/WebTours/",
        "Resource=0",
        "RecContentType=text/html",
        "Referer=",
        "Snapshot=t34.inf",
        "Mode=HTML",
        EXTRARES,
        "Url=../favicon.ico", "Referer=", ENDITEM,
        LAST); 

    web_submit_form("login.pl",
        "Snapshot=t35.inf",
        ITEMDATA,
        "Name=username", "Value=jojo", ENDITEM,
        "Name=password", "Value=bean", ENDITEM,
        "Name=login.x", "Value=52", ENDITEM,
        "Name=login.y", "Value=11", ENDITEM,
        LAST); 

    web_find("web_find",
        //从, to the Web左边查找jojo
        "LeftOf=, to the Web",
        //从Welcome右边查找jojo
        "RightOf=Welcome, ",
        "What=jojo",
        LAST); 

    return 0;
} 

代码运行结果:

Action.c(24): "web_find" successful. 1 occurrence(s) of "jojo" found (RightOf="Welcome, ", LeftOf=", to the Web")   [MsgId: MMSG-27196]

Action.c(24): web_find was successful   [MsgId: MMSG-26392]

时间: 2024-10-29 02:34:37

loadRunner函数之web_find的相关文章

LoadRunner函数大全之中文解释

LoadRunner函数大全之中文解释

软件测试中LoadRunner函数中的几个陷阱

软件测试 中 LoadRunner 函数中的几个陷阱 1.atof 在 loadrunner 中如果直接用 float f; f=atof("123.00"); lr _output_message("%f",f); 输出的结果会是1244128.00,根本不是我们想要的. 因为float,double型在不同的平台下长度不一样,所以在loadrunner 软件测试中LoadRunner函数中的几个陷阱 1.atof 在loadrunner中如果直接用 float

myeclipse调用loadrunner函数开发测试脚本

myeclipse调用loadrunner函数开发测试脚本 一.使用myeclipse开发性能测试脚本 1.使用Eclipse新建一个Java工程,将目录%LoadRunner_Home%\classes\lrapi文件复制到java工程中,并打成jar包. 操作步骤:Java工程名称右键->Export->Java->Java file,next下一步选择保存位置. 2.新建Java工程,将lrapi.jar引入扩展库中 操作步骤:目标工程名右键->Build Path->

LoadRunner函数百科叒叒叒更新了!

首先要沉痛通知每周四固定栏目[学霸君]由于小编外派公干,本周暂停. 那么这周就由云层君来顶替了,当然要要说下自己做的内容啦,DuangDuang! <LoadRunner函数百科>更新通知,其实每周都在更新!!! 本套课程根据LoadRunner11函数手册的顺序依次介绍所有以lr_开头和web_开头的函数,不但包含该函数的使用方法还提及了该函数与界面及相关性能测试脚本开发中涉及到的扩展知识哈. 现在已经更新到第51个函数了,云层数了一下今年可以把所有Web开头的函数讲完啦. 访问腾讯课堂看看

LoadRunner函数示例:lr_paramarr_random()

lr_paramarr_random()函数的作用为:从一个参数数组中随机抽取一个值并以字符串形式返回.其使用方式及返回方式如下: char * lr_paramarr_random( const char * paramArrayName); 该函数在某些测试场景下或许比较有用,如随机选择页面中一个下拉框中的值. 本次测试的WEB页面源码如下: 1 <html> 2 <head> 3 </head> 4 <body> 5 <select id=&qu

LoadRunner 函数学习

(常用函数 一) 1.        Intweb_reg_save_param("参数名","LB=左边界","RB=右边界",LAST);/注册函数,在参数值出现的前面使用,注册成功时返回值为0,注册失败时返回值为1.左右边界需根据TreeView里相关步骤的SeverResponse代码来确定.用以上函数能获取第一个符合条件的数值. 2.        web_reg_save_param("参数名","LB=

loadrunner函数

1.web_submit_data() 函数语法:web_submit_data( const char *StepName, const char *Action, <List of Attributes>, ITEMDATA, <List of data>, [ EXTRARES, <List of Resource Attributes>,] LAST); 函数参数: StepName 为该操作步骤起的名字 Action URL:要访问的地址 List of At

loadrunner函数--lr_eval_string

[lr_eval_string] lr_eval_string 函数主要是返回脚本中的一个参数当前的值. char *lr_eval_string( const char *instring ); 示例: char *tmp="hello"; lr_save_string("192.168.10.35","ip); //将常量保存为参数ip lr_save_string(tmp,"miao"); //将变量tmp保存为参数miao lr

loadrunner函数--lr_save_string

[lr_save_string] int lr_save_string (const char *param_value, const char *param_name); lr_save_string函数主要是将程序中的常量或变量保存为lr中的参数. 参数说明: 1.param_value:param_value:要保存的值 2.param_name: 变量名称 示例: char *tmp="hello"; lr_save_string("192.168.10.35&quo