码迷,mamicode.com
首页 > 其他好文 > 详细

Loadrunner 检查点

时间:2018-05-22 12:34:10      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:failure   ring   去掉   不一致   bst   arc   for   tty   not   

loadrunner帮助文档给的示例:
Example 2 is the same as example 1, but because Save Count is used, the script execution is not halted on failure. Instead, the error is handled in the code.

    // Run the Web Tours sample

    web_url("MercuryWebTours",

        "URL=http://localhost/MercuryWebTours/",

        "Resource=0",

        "RecContentType=text/html",

        "Referer=",

        "Snapshot=t1.inf",

        "Mode=HTML",

        LAST );

// Set up check for successful login by looking for "Welcome"

    web_reg_find("Text=Welcome",

        "SaveCount=Welcome_Count",

        LAST );

// Now log in

    web_submit_form("login.pl",

        "Snapshot=t2.inf",

        ITEMDATA,

        "Name=username", "Value=jojo", ENDITEM,

        "Name=password", "Value=bean", ENDITEM,

        "Name=login.x", "Value=35", ENDITEM,

        "Name=login.y", "Value=14", ENDITEM,

        LAST );

// Check result

    if (atoi(lr_eval_string("{Welcome_Count}")) > 0){

        lr_output_message("Log on successful.");

        }

     else{

        lr_error_message("Log on failed");

        return(0);

     }



注册提交的脚本:

submit() {
//int registercount = 0; web_reg_find("Search=Body", "SaveCount=registerflag",, "Text=Thank you, <b>{username}</b>",//此处检查的是服务器返回的内容,而不是展示的内容,当去掉<b></b>标签后,无法检查到内容,运行结果是失败的 LAST); lr_think_time(5); web_submit_data("login.pl_2", "Action=http://127.0.0.1:1080/cgi-bin/login.pl", "Method=POST", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/cgi-bin/login.pl?username=&password=&getInfo=true", "Snapshot=t7.inf", "Mode=HTML", ITEMDATA, "Name=username", "Value={username}", ENDITEM, "Name=password", "Value=123", ENDITEM, "Name=passwordConfirm", "Value=123", ENDITEM, "Name=firstName", "Value=", ENDITEM, "Name=lastName", "Value=", ENDITEM, "Name=address1", "Value=", ENDITEM, "Name=address2", "Value=", ENDITEM, "Name=register.x", "Value=45", ENDITEM, "Name=register.y", "Value=11", ENDITEM, LAST); //registercount = atoi(lr_eval_string("{registerflag}")); if(atoi(lr_eval_string("{registerflag}")) > 0) lr_output_message("注册成功"); else lr_output_message("注册失败,错误的账号是:%s",lr_eval_string("{username}")); return 0; }
atoi(lr_eval_string("{registerflag} 返回结果是一个数,通过atoi函数将结果转换成int,可以将注释的去掉,if(registercount > 0)也可以有同样效果。
执行过程中多次脚本不报错,但实际结果与运行结果不一致,可以适当手动重复步骤,然后通过浏览器查看源文件可以查看到检查点周围是否有在浏览器界面不展示的信息。
web_reg_find()函数是一个注册函数,需要写在检查内容前面。判断语句写在后面。


添加了<b></b>标签的运行结果日志:提示消息正确,账号注册成功
Starting action vuser_init.
Web Turbo Replay of LoadRunner 12.0.0 for Windows 7; build 2079 (Jun 17 2014 10:56:12)      [MsgId: MMSG-27143]
Run mode: HTML      [MsgId: MMSG-26993]
Run-Time Settings file: "D:\lrtest\lrregister\lr-register\\default.cfg"      [MsgId: MMSG-27141]
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Maximum number of concurrent connections per server: 6      [MsgId: MMSG-26989]
Starting action openurl.
openurl.c(4): web_url("index.htm") started      [MsgId: MMSG-26355]
openurl.c(4): Detected non-resource "http://127.0.0.1:1080/WebTours/header.html" in "http://127.0.0.1:1080/WebTours/index.htm"      [MsgId: MMSG-26574]
openurl.c(4): Detected non-resource "http://127.0.0.1:1080/cgi-bin/welcome.pl?signOff=true" in "http://127.0.0.1:1080/WebTours/index.htm"      [MsgId: MMSG-26574]
openurl.c(4): Found resource "http://127.0.0.1:1080/WebTours/images/hp_logo.png" in HTML "http://127.0.0.1:1080/WebTours/header.html"      [MsgId: MMSG-26659]
openurl.c(4): Found resource "http://127.0.0.1:1080/WebTours/images/webtours.png" in HTML "http://127.0.0.1:1080/WebTours/header.html"      [MsgId: MMSG-26659]
openurl.c(4): Detected non-resource "http://127.0.0.1:1080/cgi-bin/nav.pl?in=home" in "http://127.0.0.1:1080/cgi-bin/welcome.pl?signOff=true"      [MsgId: MMSG-26574]
openurl.c(4): Detected non-resource "http://127.0.0.1:1080/WebTours/home.html" in "http://127.0.0.1:1080/cgi-bin/welcome.pl?signOff=true"      [MsgId: MMSG-26574]
openurl.c(4): Found resource "http://127.0.0.1:1080/WebTours/images/mer_login.gif" in HTML "http://127.0.0.1:1080/cgi-bin/nav.pl?in=home"      [MsgId: MMSG-26659]
openurl.c(4): web_url("index.htm") was successful, 10080 body bytes, 2371 header bytes, 24 chunking overhead bytes      [MsgId: MMSG-26385]
Ending action openurl.
Starting action registerinfo.
registerinfo.c(4): web_url("login.pl") started      [MsgId: MMSG-26355]
registerinfo.c(4): Found resource "http://127.0.0.1:1080/WebTours/profileValidate.js" in HTML "http://127.0.0.1:1080/cgi-bin/login.pl?username=&password=&getInfo=true"      [MsgId: MMSG-26659]
registerinfo.c(4): Found resource "http://127.0.0.1:1080/WebTours/images/button_next.gif" in HTML "http://127.0.0.1:1080/cgi-bin/login.pl?username=&password=&getInfo=true"      [MsgId: MMSG-26659]
registerinfo.c(4): web_url("login.pl") was successful, 14475 body bytes, 838 header bytes, 12 chunking overhead bytes      [MsgId: MMSG-26385]
Ending action registerinfo.
Starting action submit.
submit.c(5): web_reg_find started      [MsgId: MMSG-26355]
submit.c(5): Notify: Parameter Substitution: parameter "username" =  "test1"
submit.c(5): Registering web_reg_find was successful      [MsgId: MMSG-26390]
submit.c(14): web_submit_data("login.pl_2") started      [MsgId: MMSG-26355]
submit.c(14): Notify: Parameter Substitution: parameter "username" =  "test1"
submit.c(14): Resource "http://127.0.0.1:1080/WebTours/images/button_next.gif" is in the cache already and will not be downloaded again      [MsgId: MMSG-26655]
submit.c(14): Registered web_reg_find successful for "Text=Thank you, <b>test1</b>" (count=1)      [MsgId: MMSG-26364]
submit.c(14): Notify: Saving Parameter "registerflag = 1".
submit.c(14): web_submit_data("login.pl_2") was successful, 1078 body bytes, 345 header bytes, 12 chunking overhead bytes      [MsgId: MMSG-26385]
submit.c(34): Notify: Parameter Substitution: parameter "registerflag" =  "1"
submit.c(35): 注册成功
Ending action submit.


未添加了<b></b>标签的运行结果日志:提示消息错误,账号实际是注册成功的。

Virtual User Script started at : 2018/5/22 10:46:51
Starting action vuser_init.
Web Turbo Replay of LoadRunner 12.0.0 for Windows 7; build 2079 (Jun 17 2014 10:56:12)      [MsgId: MMSG-27143]
Run mode: HTML      [MsgId: MMSG-26993]
Run-Time Settings file: "D:\lrtest\lrregister\lr-register\\default.cfg"      [MsgId: MMSG-27141]
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Maximum number of concurrent connections per server: 6      [MsgId: MMSG-26989]
Starting action openurl.
openurl.c(4): web_url("index.htm") started      [MsgId: MMSG-26355]
openurl.c(4): Detected non-resource "http://127.0.0.1:1080/WebTours/header.html" in "http://127.0.0.1:1080/WebTours/index.htm"      [MsgId: MMSG-26574]
openurl.c(4): Detected non-resource "http://127.0.0.1:1080/cgi-bin/welcome.pl?signOff=true" in "http://127.0.0.1:1080/WebTours/index.htm"      [MsgId: MMSG-26574]
openurl.c(4): Found resource "http://127.0.0.1:1080/WebTours/images/hp_logo.png" in HTML "http://127.0.0.1:1080/WebTours/header.html"      [MsgId: MMSG-26659]
openurl.c(4): Found resource "http://127.0.0.1:1080/WebTours/images/webtours.png" in HTML "http://127.0.0.1:1080/WebTours/header.html"      [MsgId: MMSG-26659]
openurl.c(4): Detected non-resource "http://127.0.0.1:1080/cgi-bin/nav.pl?in=home" in "http://127.0.0.1:1080/cgi-bin/welcome.pl?signOff=true"      [MsgId: MMSG-26574]
openurl.c(4): Detected non-resource "http://127.0.0.1:1080/WebTours/home.html" in "http://127.0.0.1:1080/cgi-bin/welcome.pl?signOff=true"      [MsgId: MMSG-26574]
openurl.c(4): Found resource "http://127.0.0.1:1080/WebTours/images/mer_login.gif" in HTML "http://127.0.0.1:1080/cgi-bin/nav.pl?in=home"      [MsgId: MMSG-26659]
openurl.c(4): web_url("index.htm") was successful, 10076 body bytes, 2371 header bytes, 24 chunking overhead bytes      [MsgId: MMSG-26385]
Ending action openurl.
Starting action registerinfo.
registerinfo.c(4): web_url("login.pl") started      [MsgId: MMSG-26355]
registerinfo.c(4): Found resource "http://127.0.0.1:1080/WebTours/profileValidate.js" in HTML "http://127.0.0.1:1080/cgi-bin/login.pl?username=&password=&getInfo=true"      [MsgId: MMSG-26659]
registerinfo.c(4): Found resource "http://127.0.0.1:1080/WebTours/images/button_next.gif" in HTML "http://127.0.0.1:1080/cgi-bin/login.pl?username=&password=&getInfo=true"      [MsgId: MMSG-26659]
registerinfo.c(4): web_url("login.pl") was successful, 14475 body bytes, 838 header bytes, 12 chunking overhead bytes      [MsgId: MMSG-26385]
Ending action registerinfo.
Starting action submit.
submit.c(5): web_reg_find started      [MsgId: MMSG-26355]
submit.c(5): Notify: Parameter Substitution: parameter "username" =  "test1"
submit.c(5): Registering web_reg_find was successful      [MsgId: MMSG-26390]
submit.c(13): web_submit_data("login.pl_2") started      [MsgId: MMSG-26355]
submit.c(13): Notify: Parameter Substitution: parameter "username" =  "test1"
submit.c(13): Resource "http://127.0.0.1:1080/WebTours/images/button_next.gif" is in the cache already and will not be downloaded again      [MsgId: MMSG-26655]
submit.c(13): Registered web_reg_find successful for "Text=Thank you, test1"      [MsgId: MMSG-26362]
submit.c(13): Notify: Saving Parameter "registerflag = 0".
submit.c(13): web_submit_data("login.pl_2") was successful, 1078 body bytes, 345 header bytes, 12 chunking overhead bytes      [MsgId: MMSG-26385]
submit.c(33): Notify: Parameter Substitution: parameter "registerflag" =  "0"
submit.c(36): Notify: Parameter Substitution: parameter "username" =  "test1"
submit.c(36): 注册失败,错误的账号是:test1
Ending action submit.
Ending iteration 1.
 
 
 

Loadrunner 检查点

标签:failure   ring   去掉   不一致   bst   arc   for   tty   not   

原文地址:https://www.cnblogs.com/Pythonstart/p/9070865.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!