• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

LoadRunner中HTTP协议的录制及模式

发布: 2009-5-15 16:47 | 作者: 不详 | 来源: 测试时代采编 | 查看: 418次 | 进入软件测试论坛讨论

领测软件测试网

LoadRunner中HTTP协议的录制及两种录制模式的比较

  一,脚本编写

  1, “HTML –base scrīpt”和“URL-base scrīpt”的区别

  1)“HTML –base scrīpt”默认模式,为每个用户请求生成单独的函数

  如:

  Action()

  {

  web_url("WebTours",

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

  "Resource=0",

  "RecContentType=text/html",

  "Referer=",

  "Snapshot=t4.inf",

  "Mode=HTML",

  LAST);

  web_submit_form("login.pl",

  "Snapshot=t5.inf",

  ITEMDATA,

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

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

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

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

  LAST);

  return 0;

  }

  2)“URL-base scrīpt”可以捕获所有作为用户操作的结果发送到服务器的HTTP请求,然后一一记录下来。可以捕获非HTML应用程序,例如小程序和非浏览器应用程序。

  如:

  Action()

  {

  web_url("WebTours",

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

  "Resource=0",

  "RecContentType=text/html",

  "Referer=",

  "Snapshot=t1.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=t2.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=t5.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=t3.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=t4.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=t6.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=t7.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=t8.inf",

  LAST);

  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=t9.inf",

  "Mode=HTTP",

  ITEMDATA,

  "Name=userSession", "Value=97276.8320777643fAADzHHpAfDAAccpAzcD", ENDITEM,

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

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

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

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

  "Name=login.y", "Value=11", 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=t10.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=t11.inf",

  "Mode=HTTP",

  LAST);

  web_concurrent_end(NULL);

  web_concurrent_start(NULL);

  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=t12.inf",

  LAST);

  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=t13.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=t14.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=t15.inf",

  LAST);

  web_concurrent_end(NULL);

  return 0;

  }

  3)如何选择?什么时候选择url的录制方式:

  * 不是基于浏览器的

  * 基于浏览器但是包含javascrīpt,并且发送了请求到服务器

  * 使用了https 安全协议

  4)两种脚本的内容比较:

  * http脚本直观,易于理解和维护

  * url 内容多,可伸缩性强,记录了更详细的用户操作信息。

  2,HTML 高级选项:

  1) 默认是选择描述用户行为的脚本

  2) 仅包含明确的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",

  LAST);

  web_url("Update.htm",

  "URL=http://scdown.qq.com/download/Update.htm",

  "TargetFrame=",

  "Resource=0",

  "RecContentType=text/html",

  "Referer=",

  "Snapshot=t2.inf",

  "Mode=HTML",

  LAST);

  web_url("Update.htm_2",

  "URL=http://scdown.qq.com/download/Update.htm",

  "TargetFrame=",

  "Resource=0",

  "RecContentType=text/html",

  "Referer=",

  "Snapshot=t3.inf",

  "Mode=HTML",

  LAST);

  web_url("Update.htm_3",

  "URL=http://scdown.qq.com/download/Update.htm",

  "TargetFrame=",

  "Resource=0",

  "RecContentType=text/html",

  "Referer=",

  "Snapshot=t4.inf",

  "Mode=HTML",

  LAST);

  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=t5.inf",

  "Mode=HTML",

  ITEMDATA,

  "Name=userSession", "Value=97276.9197245848fAADziVpffiDDDDDDAAccpAiQDf", ENDITEM,

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

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

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

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

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

  LAST);

  return 0;

  }

3,录制header

  默认设置是不录制,选择需要录制的Headers,以便服务器能够正确处理编码信息。需要注意的是“accept-language”,像websphere这类服务器会根据HTTP 请求中的Header来确定编码。

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/

TAG: http HTTP Http loadrunner LoadRunner Loadrunner loadRunner 录制 模式 协议


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网