转http://www.cnblogs.com/xiaojinniu425/p/6275257.html

一、区别:

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

  • 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 方式录制

LR:HTML-based script和URL-based script方式录制的区别的更多相关文章

  1. LoadRunner基于HTML-based script和URL-based script方式录制的区别和各自的使用场景

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

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

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

  3. LR 两种html与url录制

    一直在使用LR,对于Html_based script和Url-based script 两种录制方式之间,要如何选择,仍是一知半解.最近测试时遇到同样的业务功能,两种录制方式的脚本,单次执行时间差别 ...

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

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

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

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

  6. document.write('<script type=\"text/javascript\"><\/script>')

    document.write('<script type=\"text/javascript\"><\/script>')

  7. unity can't add the script behaviour CallbackExecutor. The script needs ...

    记一次Unity3D小问题 当我打开VS2017编辑完C#脚本,要将脚本拖到一个3D组件上时,发生了以下错误 unity can't add the script behaviour Callback ...

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

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

  9. 哪种写法更好?<script></script> vs/or <script type=”text/javasript”></script>

    一直很奇怪 哪种写法更好<script type=“text/javascript”>…</script> or <script>…</script>? ...

随机推荐

  1. 【贪心+前缀】C. Fountains

    http://codeforces.com/contest/799/problem/C [题意] 有n做花园,有人有c个硬币,d个钻石 (2 ≤ n ≤ 100 000, 0 ≤ c, d ≤ 100 ...

  2. hdu 4790 数学

    /* 题意:给你二个区间[a,b]和[c,d] 分别从中选一个数x和y使的(x+y)%p=m; 可以这样来求,先求出(0->b和0->d区间段的值)-(区间0->a-1和0-> ...

  3. linux service命令解析(重要)

    我们平时都会用service xxx start来启动某个进程,那么它背后究竟执行了什么? 其实service的绝对路径为/sbin/service ,打开这个文件cat /sbin/service, ...

  4. oc温习六:预处理指令

    预处理:分析程序前先处理的语句,它可以识别散布在程序中的特定语句.所有的预处理语句都适用“#”开头,这个符号必须是一行中的第一个非空字符. 预处理可以大概分为三类:文件包含.宏定义和条件编译. 1.文 ...

  5. delphi操作xml学习笔记 之一 入门必读

    Delphi 对XML的支持---TXMLDocument类       Delphi7 支持对XML文档的操作,可以通过TXMLDocument类来实现对XML文档的读写.可以利用TXMLDocum ...

  6. P1093||T1142 奖学金 洛谷||codevs

    http://codevs.cn/problem/1142/ || https://www.luogu.org/problem/show?pid=1093 题目描述 某小学最近得到了一笔赞助,打算拿出 ...

  7. easyUI排序问题

    使用easyUI时,需要在点击页面的某一列进行desc或asc排序,那么在jsp中可以把该列js的sortable 设置true. 加在某字段上时,该字段点击时页面会出现一小三角图案 ,此时easyU ...

  8. MySQL入门笔记 - 数据类型

    参考书籍<MySQL入门很简单> 数据类型是数据的一种属性,可以决定数据的存储方式.有效范围和相应的限制. 1.整数类型   1.1 MySQL的整数类型 MySQL中int类型和inte ...

  9. 【C++基础 02】深拷贝和浅拷贝

    我的主题是.每天积累一点点. =========================================== 在类定义中,假设没有提供自己的拷贝构造函数,则C++提供一个默认拷贝构造函数. C ...

  10. 深度学习综述(LeCun、Bengio和Hinton)

    原文摘要:深度学习可以让那些拥有多个处理层的计算模型来学习具有多层次抽象的数据的表示.这些方法在很多方面都带来了显著的改善,包含最先进的语音识别.视觉对象识别.对象检測和很多其他领域,比如药物发现和基 ...