HTML-based script和URL-based Script模式

来源:互联网 发布:淘宝购物车服务出错 编辑:程序博客网 时间:2024/06/16 17:28

 

选择Tools-Recording Options,打开设置页面

 

 

针对WebHTTP/HTML)协议,Loadrunner提供两种录制方式,HTML-based scriptURL-based Script模式。默认情况下,Loadrunner选择的是“HTML-based script

HTML-based script:为每个用户请求生成单独的函数

URL-based Script:捕获所有作为用户操作的结果发送给服务器的HTTP请求,并一一记录

 

测试用例:

 

 

步骤

步骤描述

预期结果

1

打开飞机订票系统登录页面

 

2

输入用户名“jojo”,密码“bean”点击“Login

 

3

点击“Sign Off

 

4

关闭页面

 

 使用两种录制方式录制的脚本分别如下:

HTML-Based script

/*HTML_Based*/

 

         web_url("WebTours",

                   "URL=http://127.0.0.1:1080/WebTours/",

                   "Resource=0",

                   "RecContentType=text/html",

                   "Referer=",

                   "Snapshot=t1.inf",

                   "Mode=HTML",

                   LAST);

 

         lr_think_time(9);

 

         web_submit_form("login.pl",

                   "Snapshot=t2.inf",

                   ITEMDATA,

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

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

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

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

                   LAST);

 

         web_image("SignOffButton",

                   "Alt=SignOffButton",

                   "Snapshot=t3.inf",

                   LAST);

 

         return0;

 

 


 

URL-Based Script

/*URL_Based*/

 

         web_url("WebTours",

                   "URL=http://127.0.0.1:1080/WebTours/",

                   "Resource=0",

                   "RecContentType=text/html",

                   "Referer=",

                   "Snapshot=t4.inf",

                   "Mode=HTTP",

                   LAST);

 

         web_concurrent_start(NULL);

 

         web_url("header.html",

                   "URL=http://127.0.0.1:1080/WebTours/header.html",

                   "Resource=0",

                   "RecContentType=text/html",

                   "Referer=http://127.0.0.1:1080/WebTours/",

                   "Snapshot=t5.inf",

                   "Mode=HTTP",

                   LAST);

 

         web_url("welcome.pl",

                   "URL=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=true",

                   "Resource=0",

                   "RecContentType=text/html",

                   "Referer=http://127.0.0.1:1080/WebTours/",

                   "Snapshot=t8.inf",

                   "Mode=HTTP",

                   LAST);

 

         web_concurrent_end(NULL);

 

         web_concurrent_start(NULL);

 

         web_url("hp_logo.png",

                   "URL=http://127.0.0.1:1080/WebTours/images/hp_logo.png",

                   "Resource=1",

                   "RecContentType=image/png",

                   "Referer=http://127.0.0.1:1080/WebTours/header.html",

                   "Snapshot=t6.inf",

                   LAST);

 

         web_url("webtours.png",

                   "URL=http://127.0.0.1:1080/WebTours/images/webtours.png",

                   "Resource=1",

                   "RecContentType=image/png",

                   "Referer=http://127.0.0.1:1080/WebTours/header.html",

                   "Snapshot=t7.inf",

                   LAST);

 

         web_concurrent_end(NULL);

 

         web_concurrent_start(NULL);

 

         web_url("home.html",

                   "URL=http://127.0.0.1:1080/WebTours/home.html",

                   "Resource=0",

                   "RecContentType=text/html",

                   "Referer=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=true",

                   "Snapshot=t9.inf",

                   "Mode=HTTP",

                   LAST);

 

         web_url("nav.pl",

                   "URL=http://127.0.0.1:1080/WebTours/nav.pl?in=home",

                   "Resource=0",

                   "RecContentType=text/html",

                   "Referer=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=true",

                   "Snapshot=t10.inf",

                   "Mode=HTTP",

                   LAST);

 

         web_concurrent_end(NULL);

 

         web_url("mer_login.gif",

                   "URL=http://127.0.0.1:1080/WebTours/images/mer_login.gif",

                   "Resource=1",

                   "RecContentType=image/gif",

                   "Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home",

                   "Snapshot=t11.inf",

                   LAST);

 

         lr_think_time(8);

 

         web_submit_data("login.pl",

                   "Action=http://127.0.0.1:1080/WebTours/login.pl",

                   "Method=POST",

                   "RecContentType=text/html",

                   "Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home",

                   "Snapshot=t12.inf",

                   "Mode=HTTP",

                   ITEMDATA,

                   "Name=userSession","Value=104960.867557716fDQiQctpzcfDcDQDpftHHf", ENDITEM,

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

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

                   "Name=JSFormSubmit","Value=off", ENDITEM,

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

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

                   LAST);

 

         web_concurrent_start(NULL);

 

         web_url("login.pl_2",

                   "URL=http://127.0.0.1:1080/WebTours/login.pl?intro=true",

                   "Resource=0",

                   "RecContentType=text/html",

                   "Referer=http://127.0.0.1:1080/WebTours/login.pl",

                   "Snapshot=t13.inf",

                   "Mode=HTTP",

                   LAST);

 

         web_url("nav.pl_2",

                   "URL=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home",

                   "Resource=0",

                   "RecContentType=text/html",

                   "Referer=http://127.0.0.1:1080/WebTours/login.pl",

                   "Snapshot=t14.inf",

                   "Mode=HTTP",

                   LAST);

 

         web_concurrent_end(NULL);

 

         web_concurrent_start(NULL);

 

         web_url("flights.gif",

                   "URL=http://127.0.0.1:1080/WebTours/images/flights.gif",

                   "Resource=1",

                   "RecContentType=image/gif",

                   "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home",

                   "Snapshot=t15.inf",

                   LAST);

 

         web_url("in_home.gif",

                   "URL=http://127.0.0.1:1080/WebTours/images/in_home.gif",

                   "Resource=1",

                   "RecContentType=image/gif",

                   "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home",

                   "Snapshot=t16.inf",

                   LAST);

 

         web_url("itinerary.gif",

                   "URL=http://127.0.0.1:1080/WebTours/images/itinerary.gif",

                   "Resource=1",

                   "RecContentType=image/gif",

                   "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home",

                   "Snapshot=t17.inf",

                   LAST);

 

         web_url("signoff.gif",

                   "URL=http://127.0.0.1:1080/WebTours/images/signoff.gif",

                   "Resource=1",

                   "RecContentType=image/gif",

                   "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home",

                   "Snapshot=t18.inf",

                   LAST);

 

         web_concurrent_end(NULL);

 

         web_url("SignOffButton",

                   "URL=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=1",

                   "Resource=0",

                   "RecContentType=text/html",

                   "Referer=http://127.0.0.1:1080/WebTours/nav.pl?page=menu&in=home",

                   "Snapshot=t19.inf",

                   "Mode=HTTP",

                   LAST);

 

         web_concurrent_start(NULL);

 

         web_url("home.html_2",

                   "URL=http://127.0.0.1:1080/WebTours/home.html",

                   "Resource=0",

                  "RecContentType=text/html",

                   "Referer=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=1",

                   "Snapshot=t20.inf",

                   "Mode=HTTP",

                   LAST);

 

         web_url("nav.pl_3",

                   "URL=http://127.0.0.1:1080/WebTours/nav.pl?in=home",

                   "Resource=0",

                   "RecContentType=text/html",

                   "Referer=http://127.0.0.1:1080/WebTours/welcome.pl?signOff=1",

                   "Snapshot=t21.inf",

                   "Mode=HTTP",

                   LAST);

 

         web_concurrent_end(NULL);

 

         return0;

 

 

 

原创粉丝点击