|
使用lr也一段时间了,但感觉在有些方面还是不完全清楚,今天做了如下的测试,来区别URL和HTML方式的不通,但没想明白。
对于url方式和html方式看过的资料如下:
1、基于浏览器的应用程序推荐使用HTML-Based Script。
2、不是基于浏览器的应用程序推荐使用URL-Based Script。
3、如果基于浏览器的应用程序中包含了Java Script并且该脚本向服务器产生了请求,比如DataGrid的分页按钮等,也要使用URL-Based Script方式录制。
4、基于浏览器的应用程序中使用了HTTPS安全协议,使用URL-Based Script方式录制。
今天测试用两种方法做测试,脚本如下:
1、html方式的脚本如下(脚本其实就是打开百度,增加了一个事物点,搜索‘mm'字段,查询完毕后停止)
#include "web_api.h"
Action()
{
web_add_cookie("BAIDUID=95365BBCE4C6412151BC3D9C92D8D55D:FG=1; DOMAIN=www.baidu.com");
web_url("www.baidu.com",
"URL=http://www.baidu.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
LAST);
lr_start_transaction("selectmm");
lr_think_time( 5 );
web_add_cookie("BAIDUID=95365BBCE4C6412151BC3D9C92D8D55D:FG=1; DOMAIN=s.baidu.com");
web_submit_form("s",
"Snapshot=t2.inf",
ITEMDATA,
"Name=wd", "Value=mm", ENDITEM,
EXTRARES,
"Url=http://s.baidu.com/w.gif?path=http://www.baidu.com/s?wd=mm&t=1225349094218", "Referer=http://www.baidu.com/s?wd=mm", ENDITEM,
LAST);
lr_end_transaction("selectmm", LR_AUTO);
return 0;
}
2、url方式的脚本如下(脚本过程同上)
Action()
{
web_add_cookie("BAIDUID=95365BBCE4C6412151BC3D9C92D8D55D:FG=1; DOMAIN=www.baidu.com");
web_url("www.baidu.com",
"URL=http://www.baidu.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTTP",
LAST);
web_add_cookie("BAIDUID=95365BBCE4C6412151BC3D9C92D8D55D:FG=1; DOMAIN=gimg.baidu.com");
web_concurrent_start(NULL);
web_url("baidu_logo.gif",
"URL=http://www.baidu.com/img/baidu_logo.gif",
"Resource=1",
"RecContentType=image/gif",
"Referer=http://www.baidu.com/",
LAST);
web_url("gs.gif",
"URL=http://gimg.baidu.com/img/gs.gif",
"Resource=1",
"RecContentType=image/gif",
"Referer=http://www.baidu.com/",
LAST);
web_concurrent_end(NULL);
lr_think_time( 4 );
lr_start_transaction("selectmm");
lr_think_time( 6 );
web_submit_data("s",
"Action=http://www.baidu.com/s",
"Method=GET",
"EncType=",
"RecContentType=text/html",
"Referer=http://www.baidu.com/",
"Snapshot=t2.inf",
"Mode=HTTP",
ITEMDATA,
"Name=wd", "Value=mm", ENDITEM,
LAST);
web_add_cookie("BAIDUID=95365BBCE4C6412151BC3D9C92D8D55D:FG=1; DOMAIN=c.baidu.com");
web_concurrent_start(NULL);
web_url("logo-yy.gif",
"URL=http://www.baidu.com/img/logo-yy.gif",
"Resource=1",
"RecContentType=image/gif",
"Referer=http://www.baidu.com/s?wd=mm",
LAST);
web_url("c.gif",
"URL=http://c.baidu.com/c.gif?t=0&q=mm&p=0&pn=1",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.baidu.com/s?wd=mm",
"Mode=HTTP",
LAST);
web_concurrent_end(NULL);
web_add_cookie("BAIDUID=95365BBCE4C6412151BC3D9C92D8D55D:FG=1; DOMAIN=s.baidu.com");
web_url("w.gif",
"URL=http://s.baidu.com/w.gif?path=http://www.baidu.com/s?wd=mm&t=1225349330734",
"Resource=1",
"RecContentType=image/gif",
"Referer=http://www.baidu.com/s?wd=mm",
LAST);
lr_end_transaction("selectmm", LR_AUTO);
return 0;
}
脚本录制完成后,运行url方式报错,运行日志如下:
Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(6): web_add_cookie was successful [MsgId: MMSG-26392]
Action.c(8): web_url("www.baidu.com") was successful, 2035 body bytes, 208 header bytes [MsgId: MMSG-26386]
Action.c(17): web_add_cookie was successful [MsgId: MMSG-26392]
Action.c(19): web_concurrent_start was successful [MsgId: MMSG-26392]
Action.c(21): Registering web_url("baidu_logo.gif") was successful [MsgId: MMSG-26390]
Action.c(28): Registering web_url("gs.gif") was successful [MsgId: MMSG-26390]
Action.c(35): web_concurrent_end was successful, 1580 body bytes, 568 header bytes [MsgId: MMSG-26386]
Action.c(39): Notify: Transaction "selectmm" started.
Action.c(43): web_submit_data("s") was successful, 7114 body bytes, 168 header bytes [MsgId: MMSG-26386]
Action.c(55): web_add_cookie was successful [MsgId: MMSG-26392]
Action.c(57): web_concurrent_start was successful [MsgId: MMSG-26392]
Action.c(59): Registering web_url("logo-yy.gif") was successful [MsgId: MMSG-26390]
Action.c(66): Registering web_url("c.gif") was successful [MsgId: MMSG-26390]
Action.c(66): Error -26563: Non-empty response body is invalid with HTTP Status Code 204 (No Content) for "http://c.baidu.com/c.gif?t=0&q=mm&p=0&pn=1" [issued at Action.c(74)] [MsgId: MERR-26563]
Action.c(66): Warning -26652: Response body length (1) does not match the Content-Length header specification (0) for "http://c.baidu.com/c.gif?t=0&q=mm&p=0&pn=1" [issued at Action.c(74)] [MsgId: MWAR-26652]
Action.c(74): web_concurrent_end highest severity level was "ERROR", 1619 body bytes, 402 header bytes [MsgId: MMSG-26388]
Action.c(74): Notify: Transaction "selectmm" ended with "Fail" status (Duration: 0.3087).Ending action Action.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.
问题:为什么会有这样的错误信息呢?为了避免url错误,那我使用html方式来录制脚本,但这两种录制对与测试结果的影响有那些。 |
|