Loadrunner脚本录制与回放

一、 脚本录制与事务

1.录制登录功能
1.1 步骤
单击Create/Edit Scripts->选择Web(HTTP/HTML)->浏览器为IE8->Options(HTML-based script/URL-based script)->开始录制->输入jojo、
bean登录->结束录制。
1.2脚本(只要有传递信息的脚本)
HTML-based script模式:
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=HTML”,
ITEMDATA,
“Name=userSession”, “Value=128380.231915755zzADffipVHQVzzzHDQzcVpDtQAHf”, ENDITEM,
“Name=username”, “Value=jojo”, ENDITEM,
“Name=password”, “Value=bean”, ENDITEM,
“Name=JSFormSubmit”, “Value=off”, ENDITEM,
“Name=login.x”, “Value=47”, ENDITEM,
“Name=login.y”, “Value=6”, ENDITEM,
LAST);
URL-based script模式:
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=t23.inf”,
“Mode=HTTP”,
ITEMDATA,
“Name=userSession”, “Value=128376.068124747zzADDttpAAtVzzzHDQzcApAztAcf”, ENDITEM,
“Name=username”, “Value=jojo”, ENDITEM,
“Name=password”, “Value=bean”, ENDITEM,
“Name=JSFormSubmit”, “Value=off”, ENDITEM,
“Name=login.x”, “Value=48”, ENDITEM,
“Name=login.y”, “Value=8”, ENDITEM,
LAST);
1.3 采用加入事务的方式计算运行时间
运行时间为:0.7702s(HTML) 0.6227s(URL)

2.录制sign up now功能
2.1步骤
单击Create/Edit Scripts->选择Web(HTTP/HTML)->浏览器为IE8->Options
(HTML-based script/URL-based script)->开始录制->随便注册一个账号 ->结束录制。
2.2 日志内容
HTML-based script模式:
web_submit_data(“login.pl_2”,
“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=t17.inf”,
“Mode=HTML”,
ITEMDATA,
“Name=userSession”, “Value=128380.686431754zzADfiVpffiDDDDDDQzcVptiQDf”, ENDITEM,
“Name=username”, “Value=jojo”, ENDITEM,
“Name=password”, “Value=bean”, ENDITEM,
“Name=JSFormSubmit”, “Value=off”, ENDITEM,
“Name=login.x”, “Value=59”, ENDITEM,
“Name=login.y”, “Value=7”, ENDITEM,
LAST);
URL-based script模式:
web_submit_data(“login.pl_2”,
“Action=http://127.0.0.1:1080/WebTours/login.pl”,
“Method=POST”,
“RecContentType=text/html”,
“Referer=http://127.0.0.1:1080/WebTours/login.pl?username=&password=&getInfo=true”,
“Snapshot=t21.inf”,
“Mode=HTTP”,
ITEMDATA,
“Name=username”, “Value=ayu”, ENDITEM,
“Name=password”, “Value=bean”, ENDITEM,
“Name=passwordConfirm”, “Value=bean”, ENDITEM,
“Name=firstName”, “Value=y”, ENDITEM,
“Name=lastName”, “Value=my”, ENDITEM,
“Name=address1”, “Value=jiaxinglu”, ENDITEM,
“Name=address2”, “Value=jiaxing”, ENDITEM,
“Name=register.x”, “Value=55”, ENDITEM,
“Name=register.y”, “Value=13”, ENDITEM,
LAST);
2.3 采用加入事务的方式计算运行时间
运行时间为:1.2155s(HTML)1.5420s(URL)

3.录制login->Flights功能
3.1步骤
单击Create/Edit Scripts->选择Web(HTTP/HTML)->浏览器为IE8->Options
(HTML-based script/URL-based script)->开始录制->输入jojo、bean登录->flights->结束录制。
3.2 日志内容
HTML-based script模式:
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=t39.inf”,
“Mode=HTML”,
ITEMDATA,
“Name=userSession”, “Value=128380.912272175zzADfQDpVHfDQzcVpffQAf”, ENDITEM,
“Name=username”, “Value=jojo”, ENDITEM,
“Name=password”, “Value=bean”, ENDITEM,
“Name=JSFormSubmit”, “Value=off”, ENDITEM,
“Name=login.x”, “Value=64”, ENDITEM,
“Name=login.y”, “Value=13”, ENDITEM,
LAST);
URL-based script模式:
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=t62.inf”,
“Mode=HTTP”,
ITEMDATA,
“Name=userSession”, “Value=128380.939651681zzADfQtpfiDDDDDDDQzcVpfzHf”, ENDITEM,
“Name=username”, “Value=jojo”, ENDITEM,
“Name=password”, “Value=bean”, ENDITEM,
“Name=JSFormSubmit”, “Value=off”, ENDITEM,
“Name=login.x”, “Value=64”, ENDITEM,
“Name=login.y”, “Value=9”, ENDITEM,
LAST);
3.3 采用加入事务的方式计算运行时间
Flights运行时间为:0.0679(HTML)2.0887(URL)

二、 检查点
具体要求:分别采用web_find()和web_reg_find()针对HTML-based script及URL-based script两种模式抓取的脚本设置检查点,因此,它们的组合方式有四种。
1.针对登录功能web_find()HTML-based script模式下设置检查点.
1步骤
打开Tree->打开Action()->Submit Data:login.pl->Find Text->勾选Save count->输入num->Run
1.2 运行显示的主要参数
Action.c(128): Notify: Saving Parameter “num = 0”.
1.3 是否成功?如果没有成功原因是什么?
成功。

2.针对登录功能web_reg_find()HTML-based script模式下设置检查点
2.1步骤
打开Tree->打开Action()->Submit Data:login.pl->Find Text->勾选Save count->输入num->Run
2.2 运行显示的主要参数
Action.c(128): Notify: Saving Parameter “num = 0”.
2.3 是否成功?如果没有成功原因是什么?
成功。

3.针对登录功能web_find()在URL-based script模式下设置检
查点
3.1步骤
打开Tree->打开Action()->Submit Data:login.pl->Find Text->勾选Save count->输入num->Run
3.2 运行显示的主要参数

3.3 是否成功?如果没有成功原因是什么?
不能成功。URL-based script模式下只能设置web_reg_find()
4. 针对登录功能web_reg_find()在URL-based script模式下设置检查点
打开Tree->打开Action()->Url:login.pl_2->Find Text->勾选Save count->输入num->Run
4.1步骤
打开Tree->打开Action()->Submit Data:login.pl->Find Text->勾选Save count->输入num->Run
4.2 运行显示的主要参数
Action.c(128): Notify: Saving Parameter “num = 0”.
4.3 是否成功?如果没有成功原因是什么?
成功。

你可能感兴趣的:(软件测试,软件测试,loadrunner,html,http,脚本语言)