一、区别:

  为了更加直观的区别这两种录制方式,我们可以分别使用这两种方式录制同一场景(打开百度首页)然后进行对比,录制的代码如下:

  • HTML-based script方式打开百度首页:
Action()
{
web_url("www.baidu.com",
"URL=http://www.baidu.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t2.inf",
"Mode=HTML",
EXTRARES,
"Url=https://www.baidu.com/img/270x129gif_2_34efd039aeb80b72ae0708a039d15503.gif", "Referer=https://www.baidu.com/", ENDITEM,
"Url=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/global/img/icons_2df80e9d.png", "Referer=https://www.baidu.com/", ENDITEM,
"Url=https://www.baidu.com/img/baidu_jgylogo3.gif", "Referer=https://www.baidu.com/", ENDITEM,
"Url=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/global/js/all_instant_search1_6322b0cc.js", "Referer=https://www.baidu.com/", ENDITEM,
"Url=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/home/js/nu_instant_search_9b23bc7b.js", "Referer=https://www.baidu.com/", ENDITEM,
"Url=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/global/img/quickdelete_9c14b01a.png", "Referer=https://www.baidu.com/", ENDITEM,
"Url=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/sug/js/bdsug_input_event_89ba7d09.js", "Referer=https://www.baidu.com/", ENDITEM,
"Url=https://passport.baidu.com/passApi/js/uni_login_wrapper.js?cdnversion=1430055815464&_=1430055815291", "Referer=https://www.baidu.com/", ENDITEM,
"Url=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/baiduia/baiduia_b45d552b.js", "Referer=https://www.baidu.com/", ENDITEM,
"Url=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/plugins/every_cookie_09fe94e0.js", "Referer=https://www.baidu.com/", ENDITEM,
"Url=https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=&json=1&p=3&sid=13457_13387_1449_13074_12824_13381_12867_13323_12692_13410_10562_12722_13439_13287_13602_13161_13257_11800_13085_8498&req=2&cb=jQuery1102008927719119172578_1430055815292&_=1430055815293", "Referer=https://www.baidu.com/", ENDITEM,
"Url=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/baiduia/JSocket_9a52fc3e.swf?0.05", "Referer=https://www.baidu.com/", ENDITEM,
"Url=https://www.baidu.com/favicon.ico", "Referer=", ENDITEM,
"Url=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/plugins/env_5202315f.swf", "Referer=https://www.baidu.com/", ENDITEM,
LAST); return ;
}
  • URL-based script方式打开百度首页:
Action()
{ web_url("vus_main.js",
"URL=http://conf.xmp.kankan.com/vus/vipjs/vus_main.js",
"Resource=1",
"RecContentType=application/x-javascript",
"Referer=",
"Snapshot=t1.inf",
LAST); web_url("www.baidu.com",
"URL=http://www.baidu.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t3.inf",
"Mode=HTTP",
LAST); web_url("jquery-1.10.2.min_f2fb5194.js",
"URL=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/jquery/jquery-1.10.2.min_f2fb5194.js",
"Resource=1",
"RecContentType=application/javascript",
"Referer=https://www.baidu.com/",
"Snapshot=t4.inf",
LAST); web_concurrent_start(NULL); web_url("270x129gif_2_34efd039aeb80b72ae0708a039d15503.gif",
"URL=https://www.baidu.com/img/270x129gif_2_34efd039aeb80b72ae0708a039d15503.gif",
"Resource=1",
"RecContentType=image/gif",
"Referer=https://www.baidu.com/",
"Snapshot=t5.inf",
LAST); web_url("baidu_jgylogo3.gif",
"URL=https://www.baidu.com/img/baidu_jgylogo3.gif",
"Resource=1",
"RecContentType=image/gif",
"Referer=https://www.baidu.com/",
"Snapshot=t6.inf",
LAST); web_url("icons_2df80e9d.png",
"URL=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/global/img/icons_2df80e9d.png",
"Resource=1",
"RecContentType=image/png",
"Referer=https://www.baidu.com/",
"Snapshot=t7.inf",
LAST); web_url("all_instant_search1_6322b0cc.js",
"URL=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/global/js/all_instant_search1_6322b0cc.js",
"Resource=1",
"RecContentType=application/javascript",
"Referer=https://www.baidu.com/",
"Snapshot=t8.inf",
LAST); web_url("uni_login_wrapper.js",
"URL=https://passport.baidu.com/passApi/js/uni_login_wrapper.js?cdnversion=1430055705421&_=1430055705210",
"Resource=1",
"RecContentType=text/javascript",
"Referer=https://www.baidu.com/",
"Snapshot=t9.inf",
LAST); web_url("nu_instant_search_9b23bc7b.js",
"URL=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/home/js/nu_instant_search_9b23bc7b.js",
"Resource=1",
"RecContentType=application/javascript",
"Referer=https://www.baidu.com/",
"Snapshot=t10.inf",
LAST); web_url("bdsug_input_event_89ba7d09.js",
"URL=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/sug/js/bdsug_input_event_89ba7d09.js",
"Resource=1",
"RecContentType=application/javascript",
"Referer=https://www.baidu.com/",
"Snapshot=t11.inf",
LAST); web_url("quickdelete_9c14b01a.png",
"URL=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/global/img/quickdelete_9c14b01a.png",
"Resource=1",
"RecContentType=image/png",
"Referer=https://www.baidu.com/",
"Snapshot=t12.inf",
LAST); web_concurrent_end(NULL); web_custom_request("q.cgi",
"URL=http://masterconn.qq.com/q.cgi",
"Method=POST",
"Resource=1",
"Referer=",
"Snapshot=t13.inf",
"EncType=",
"BodyBinary=\\x00\\x02\\x00\\xA6\\x00\\x00\\x00\\x02\\x00\\x00\\x01\n\\x00\\x00\\x07\\xDA\\x00\\x00\\x00\\x00箲\\x0E哶C[褏4苶j虗X\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\t\\x10BR\\xCD\\x06\\x11(o%\\x80\\xC4\\xFF\\xF3'~鳩諣粷,U秡ㄚn.澅@得c\\xB4\\x0F\\x18$\\xD1$\n\\x8D+<4堲憭彫z>M邗\\x04\nyu崙'猩榆*¥貆眚m*程\\x185鱴臀\\xFC=兤\\x01\\xB9=\\xC19>\\x13寇嫖s貖葠\\x8C\\x0E=]慯1\\x15\\x8A"
"(筐敍\\x80u\\x12\\x14纁F迖斕鷠\\xED\\x1E边祗躁$魄\\x19ol*坡糎}, \\x10\\x1Cg\\x8A\\x16树c诩3\\x0E脁(\t薍o=魇eT\\x97\\x08\\x13緀岧&\\x1B\\xA5",
LAST); web_concurrent_start(NULL); web_url("su",
"URL=https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=&json=1&p=3&sid=13457_13387_1449_13074_12824_13381_12867_13323_12692_13410_10562_12722_13439_13287_13602_13161_13257_11800_13085_8498&req=2&cb=jQuery110208659240831750304_1430055705211&_=1430055705212",
"Resource=1",
"RecContentType=text/javascript",
"Referer=https://www.baidu.com/",
"Snapshot=t14.inf",
LAST); web_url("baiduia_b45d552b.js",
"URL=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/baiduia/baiduia_b45d552b.js",
"Resource=1",
"RecContentType=application/javascript",
"Referer=https://www.baidu.com/",
"Snapshot=t15.inf",
LAST); web_url("every_cookie_09fe94e0.js",
"URL=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/plugins/every_cookie_09fe94e0.js",
"Resource=1",
"RecContentType=application/javascript",
"Referer=https://www.baidu.com/",
"Snapshot=t16.inf",
LAST); web_url("JSocket_9a52fc3e.swf",
"URL=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/baiduia/JSocket_9a52fc3e.swf?0.05",
"Resource=1",
"RecContentType=application/x-shockwave-flash",
"Referer=https://www.baidu.com/",
"Snapshot=t17.inf",
LAST); web_url("env_5202315f.swf",
"URL=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/plugins/env_5202315f.swf",
"Resource=1",
"RecContentType=application/x-shockwave-flash",
"Referer=https://www.baidu.com/",
"Snapshot=t18.inf",
LAST); web_url("favicon.ico",
"URL=https://www.baidu.com/favicon.ico",
"Resource=1",
"RecContentType=image/x-icon",
"Referer=",
"Snapshot=t19.inf",
LAST); web_url("JSocket_9a52fc3e.swf_2",
"URL=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/baiduia/JSocket_9a52fc3e.swf?0.05",
"Resource=1",
"RecContentType=application/x-shockwave-flash",
"Referer=https://www.baidu.com/",
"Snapshot=t20.inf",
LAST); web_url("env_5202315f.swf_2",
"URL=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/plugins/env_5202315f.swf",
"Resource=1",
"RecContentType=application/x-shockwave-flash",
"Referer=https://www.baidu.com/",
"Snapshot=t21.inf",
LAST); web_concurrent_end(NULL); return ;
}

 从上面可以看出:

  • HTML-based script:这种方式录制的代码只生成了一个函数,所有请求全放在这个函数里面,即:一个操作(可能包含多个请求)会生成一个函数,这种方式看起来比较简洁
  • URL-based script:这种方式会生成很多函数,它将每个请求都单独成一个函数,这种方式更接近请求-响应的本质

二、HTML-based script模式下-->高级选项Sctipt type两种方式的区别:

  •   A script describing user actions(e.g. web_link,web_submit_form)
  •   A script containing explicit URLs only(e.g. web_url, web_submit_data)

同上面一样,我们还是通过录制同一场景的方法直接来对比这两种方式的区别(录制loadrunner自代的示例程序)

  • A script describing user actions(e.g. web_link,web_submit_form)
Action()
{
  //如果注释掉这个函数,执行时会失败
web_url("WebTours",
"URL=http://127.0.0.1:1080/WebTours/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t9.inf",
"Mode=HTML",
EXTRARES,
"Url=../favicon.ico", "Referer=", ENDITEM,
LAST);

  //提交表单,依赖上下文,如果没有上面的函数,会执行失败
web_submit_form("login.pl",
"Snapshot=t10.inf",
ITEMDATA,
"Name=username", "Value=jojo", ENDITEM,
"Name=password", "Value=bean", ENDITEM,
"Name=login.x", "Value=59", ENDITEM,
"Name=login.y", "Value=9", ENDITEM,
LAST);
return ;
}
  • A script containing explicit URLs only(e.g. web_url, web_submit_data)
Action()
{
  //注释掉这个函数,这个场景执行不会失败,因为web_submit_data的函数中包含了具体的URL(如下标红的action)
web_url("WebTours",
"URL=http://127.0.0.1:1080/WebTours/",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
EXTRARES,
"Url=http://conf.xmp.kankan.com/vus/vipjs/vus_main.js", "Referer=", ENDITEM,
LAST);   //提交数据到具体的URL,不依赖上下文
web_submit_data("login.pl",
"Action=http://127.0.0.1:1080/WebTours/login.pl",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
"Referer=http://127.0.0.1:1080/WebTours/nav.pl?in=home",
"Snapshot=t3.inf",
"Mode=HTML",
ITEMDATA,
"Name=userSession", "Value=115841.053786958fQfifHtpcAtVzzzHDfHfVpttfccf", 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=9", ENDITEM,
LAST);return ;
}

总结:

  • web_submit_form: 上下文相关的,依赖上下文才能提交,比较符合人们的操作习惯。
  • web_submit_data:  上下文不相关,每个函数都指定了具体的url地址,可以直接提交成功,如果只关注协议,不需要关注页面,可使用这种方式录制。

三、使用场景:

  • 基于浏览器的应用程序推荐使用HTML-based Script
  • 不是基于浏览器的应用程序推荐使用URL-based Script。
  • 如果基于浏览器的应用程序中包含了JavaScript 并且该脚本向服务器产生了请求,比如DataGrid 的分页按钮等,flash等,也要使用URL-based 方式录制
  • 基于浏览器的应用程序中使用了HTTPS 安全协议,使用URL-based 方式录制

LoadRunner基于HTML-based script和URL-based script方式录制的区别和各自的使用场景的更多相关文章

  1. LR:HTML-based script和URL-based script方式录制的区别

    转http://www.cnblogs.com/xiaojinniu425/p/6275257.html 一.区别: 为了更加直观的区别这两种录制方式,我们可以分别使用这两种方式录制同一场景(打开百度 ...

  2. LR中,URL -based script与HTML -based script区别

    在Web(HTTP/HTML)录制中,有2种重要的录制模式.用户该选择那种录制模式呢?HTML-mode录制是缺省也是推荐的录制模式.它录制当前网页中的HTML动作.在录制会话过程中不会录制所有的资源 ...

  3. (转)nginx下基于ThinkPHP框架的网站url重写

    nginx下基于ThinkPHP框架的网站url重写nginx下的基于thinkphp的应用的url重写,需了解thinkphp的各种url格式参数的处理逻辑以及nginx重写的原理.简单点说,无论哪 ...

  4. php 后台转发和重定向的区别及kohana框架当前url加参数方式

    1.重定向是浏览器行为,浏览器地址有变化:转发是后台服务器完成, url地址不变化. 2.kohana获取URL 当前url是http://soyoung.kohana.com/blog/add?id ...

  5. PHP+jQuery 长文章分页类 ( 支持 url / ajax 分页方式 )

    /* ******* 环境:Apache2.2.8 ( 2.2.17 ) + PHP5.2.6 ( 5.3.3 ) + MySQL5.0.51b ( 5.5.8 ) + jQuery-1.8 **** ...

  6. 【Loadrunner】如何通过loadrunner利用代理对手机端Web浏览器及APP进行录制?

    以下为作者操作并最终可以成功录制脚本并调试成功的方法实际操作中记录截图,都是干货哦~ 1.安装lr11补丁 百度网盘下载链接:https://pan.baidu.com/s/1TPoaAMYvi1cw ...

  7. script标签中defer和async属性的区别

    这篇文章来源于JS高级程序设计第三版中关于script标签的介绍,结合查阅的资料写下的学习笔记. 向html页面中插入javascript代码的主要方法就是通过script标签.其中包括两种形式,第一 ...

  8. echo '<script>alert("插入成功")</script>';

    echo '<script>alert("插入成功")</script>'; <?php if ( ! defined('BASEPATH')) ex ...

  9. 爬虫技术 -- 基础学习(三)理解URL和URI的联系与区别

    网络爬虫的基本操作是抓取网页.首先要了解下URL~~ 在理解URL之前,先了解下URI,这两个概念我曾经混淆过~@_@|| 什么是URI? Web上每种可用的资源,如:html文档.视频,图片等都由一 ...

随机推荐

  1. CListCtrlEx:一个支持文件拖放和实时监视的列表控件——用未公开API函数实现Shell实时监视

    一.需求无论何时,当你在Explorer窗口中创建.删除或重命名一个文件夹/文件,或者插入拔除移动存储器时,Windows总是能非常快速地更新它所有的视图.有时候我们的程序中也需要这样的功能,以便当用 ...

  2. 【转】解决Android因加载多个大图引起的OutOfMemoryError,内存溢出的问题

    本文来自:http://blog.csdn.net/wulianghuan/article/details/11548373,感谢原作者的分享. 目标是读取SD卡中的图片并且展示出来 主要思路是通过一 ...

  3. 《OSPF和IS-IS详解》

    <OSPF和IS-IS详解> 基本信息 作者: (美)Jeff Doyle 译者: 孙余强 出版社:人民邮电出版社 ISBN:9787115347886 上架时间:2014-4-25 出版 ...

  4. .NET培训 | JAVA培训 | 最课程

    最课程(www.zuikc.com) 软件开发培训,在线软件培训的创新者!我们的创新在于: 1:一次购买,终身服务.每个最课程学员都会分配一位专职教师及一位监管教师,点对点跟进课程进度,直到您学会课程 ...

  5. nginx源代码分析之内存池实现原理

    建议看本文档时结合nginx源代码. 1.1   什么是内存池?为什么要引入内存池? 内存池实质上是接替OS进行内存管理.应用程序申请内存时不再与OS打交道.而是从内存池中申请内存或者释放内存到内存池 ...

  6. Java hashCode() 和 equals()的若干问题解答<转载自skywang12345>

    第1部分 equals() 的作用equals()的作用是用来判断两个对象是否相等.equals()定义在JDK的Object类中.通过判断两个对象的地址是否相等(即,是否是同一个对象)来区分它们是否 ...

  7. Apache URL重写的配置 及其 apache500错误

    1:如果apache报500错误时 ----->原因:可能是你的ReWrite模块没有打开(有时在apache重装时会忘记打开该模块) 将apache--->httpd.conf文件中Lo ...

  8. C++ 内置宏定义 与 预编译指令

    内置宏和预编译指令, 在代码调试.单元测试.跨平台代码中经常会用到.这里记录一下. 1. 内置宏 (文件名,当前行号,当前日期,当前时间,当前执行方法名) __FILE____LINE____DATE ...

  9. json传输二进制的方案【转】

    本文转自:http://wiyi.org/binary-to-string.html json 是一种很简洁的协议,但可惜的是,它只能传递基本的数型(int,long,string等),但不能传递by ...

  10. [PowerShell Utils] Remotely install Hyper-V and Failover Cluster feature on a list of windows 2012 servers

    Hello everyone, this is the second post of the series. .   Background =============== In my environm ...